16-1 Last time □ Reliable Data Transfer with packet loss ♦ rdt3.0 □ Pipelining ♦ Problems with stop-and-wait ♦ Go-Back-N ♦ Selective-Repeat.

Slides:



Advertisements
Similar presentations
Introduction 1 Lecture 13 Transport Layer (Transmission Control Protocol) slides are modified from J. Kurose & K. Ross University of Nevada – Reno Computer.
Advertisements

Transport Layer3-1 TCP. Transport Layer3-2 TCP: Overview RFCs: 793, 1122, 1323, 2018, 2581 r full duplex data: m bi-directional data flow in same connection.
Data Communications and Computer Networks Chapter 3 CS 3830 Lecture 16 Omar Meqdadi Department of Computer Science and Software Engineering University.
1 Chapter 3 Transport Layer. 2 Chapter 3 outline 3.1 Transport-layer services 3.2 Multiplexing and demultiplexing 3.3 Connectionless transport: UDP 3.4.
1 Transport Layer Lecture 9 Imran Ahmed University of Management & Technology.
Transport Layer3-1 Summary of Reliable Data Transfer Checksums help us detect errors ACKs and NAKs help us deal with errors If ACK/NAK has errors sender.
Week 9 TCP9-1 Week 9 TCP 3 outline r 3.5 Connection-oriented transport: TCP m segment structure m reliable data transfer m flow control m connection management.
Transport Layer1 TCP: Overview RFCs: 793, 1122, 1323, 2018, 2581 r reliable, in-order byte steam: m no “message boundaries” r pipelined: m TCP congestion.
Chapter 3 outline 3.1 transport-layer services
2: Application Layer 1 Socket programming Socket API r introduced in BSD4.1 UNIX, 1981 r explicitly created, used, released by apps r client/server paradigm.
Transport Layer 3-1 Transport Layer r To learn about transport layer protocols in the Internet: m TCP: connection-oriented protocol m Reliability protocol.
2: Application Layer1 Data Communication and Networks Lecture 12 Java Sockets November 30, 2006.
1 Overview r Socket programming with TCP r Socket programming with UDP r Building a Web server.
Transport Layer Transport Layer: TCP. Transport Layer 3-2 TCP: Overview RFCs: 793, 1122, 1323, 2018, 2581 r full duplex data: m bi-directional.
Transport Layer 3-1 Transport Layer r To learn about transport layer protocols in the Internet: m TCP: connection-oriented protocol m Reliability protocol.
1 Announcement r Project 2 out m Much harder than project 1, start early! r Homework 2 due next Tuesday.
Transport Layer3-1 Chapter 3 Transport Layer Computer Networking: A Top Down Approach Featuring the Internet, 3 rd edition. Jim Kurose, Keith Ross Addison-Wesley,
Announcement Project 2 out –Much harder than project 1, start early! Homework 2 due next Tu.
Chapter 3 Transport Layer
The Future r Let’s look at the homework r The next test is coming the 19 th (just before turkey day!) r Monday will finish TCP canned slides r Wednesday.
Transport Layer3-1 Data Communication and Networks Lecture 7 Transport Protocols: TCP October 21, 2004.
2: Application Layer1 Socket Programming. 2: Application Layer2 Socket-programming using TCP Socket: a door between application process and end- end-transport.
Announcement Homework 1 graded Homework 2 out –Due in a week, 1/30 Project 2 problems –Minet can only compile w/ old version of gcc (2.96). –Only tlab-login.
Transport Layer session 1 TELE3118: Network Technologies Week 9: Transport Layer Basics Some slides have been taken from: r Computer Networking:
1 Network Layers Application Transport Network Data-Link Physical bits.
2: Application Layer 1 Socket Programming Computer Networking: A Top Down Approach Featuring the Internet, 3 rd edition. Jim Kurose, Keith Ross Addison-Wesley,
2: Application Layer 1 Socket Programming TCP and UDP.
2: Application Layer1 Chapter 2: Application layer r 2.1 Principles of network applications r 2.2 Web and HTTP r 2.3 FTP r 2.4 Electronic Mail  SMTP,
2: Application Layer1 Socket programming Socket API r introduced in BSD4.1 UNIX, 1981 r explicitly created, used, released by apps r client/server paradigm.
CS 3830 Day 11 Introduction : Application Layer 2 Server-client vs. P2P: example Client upload rate = u, F/u = 1 hour, u s = 10u, d min ≥ u s.
Transport Layer3-1 TCP sender (simplified) NextSeqNum = InitialSeqNum SendBase = InitialSeqNum loop (forever) { switch(event) event: data received from.
Network LayerII-1 RSC Part III: Transport Layer 3. TCP Redes y Servicios de Comunicaciones Universidad Carlos III de Madrid These slides are, mainly, part.
Transport Layer1 Reliable Transfer Ram Dantu (compiled from various text books)
Chapter 2 Application Layer Computer Networking: A Top Down Approach, 5 th edition. Jim Kurose, Keith Ross Addison-Wesley, April A note on the use.
Winter 2002Suprakash Datta1 Socket programming Socket API introduced in BSD4.1 UNIX, 1981 explicitly created, used, released by apps client/server paradigm.
-1- Georgia State UniversitySensorweb Research Laboratory CSC4220/6220 Computer Networks Dr. WenZhan Song Associate Professor, Computer Science.
Socket Programming Lee, Sooyong
3: Transport Layer3b-1 TCP: Overview RFCs: 793, 1122, 1323, 2018, 2581 r full duplex data: m bi-directional data flow in same connection m MSS: maximum.
2: Transport Layer 21 Transport Layer 2. 2: Transport Layer 22 TCP: Overview RFCs: 793, 1122, 1323, 2018, 2581 r full duplex data: m bi-directional data.
Socket Programming Tutorial. Socket programming Socket API introduced in BSD4.1 UNIX, 1981 explicitly created, used, released by apps client/server paradigm.
2: Application Layer1 Socket programming Socket API Explicitly created, used, released by apps Client/server paradigm Two types of transport service via.
September 26 th, 2013 CS1652 The slides are adapted from the publisher’s material All material copyright J.F Kurose and K.W. Ross, All Rights.
1 Socket programming Socket API r introduced in BSD4.1 UNIX, 1981 r explicitly created, used, released by apps r client/server paradigm r two types of.
Transport Layer3-1 Chapter 3 outline r 3.1 Transport-layer services r 3.2 Multiplexing and demultiplexing r 3.3 Connectionless transport: UDP r 3.4 Principles.
Transport Layer3-1 Chapter 3 Transport Layer Computer Networking: A Top Down Approach 5 th edition. Jim Kurose, Keith Ross Addison-Wesley, April 2009.
Transport Layer3-1 Transport Layer If you are going through Hell Keep going.
Chapter 3 Transport Layer Computer Networking: A Top Down Approach 6 th edition Jim Kurose, Keith Ross Addison-Wesley March 2012 A note on the use of these.
Data Communications and Computer Networks Chapter 2 CS 3830 Lecture 11 Omar Meqdadi Department of Computer Science and Software Engineering University.
CSEN 404 Transport Layer II Amr El Mougy Lamia AlBadrawy.
@Yuan Xue A special acknowledge goes to J.F Kurose and K.W. Ross Some of the slides used in this lecture are adapted from their.
09-Transport Layer: TCP Transport Layer.
Chapter 3 outline 3.1 Transport-layer services
Chapter 3 outline 3.1 transport-layer services
CS 1652 Jack Lange University of Pittsburgh
TCP: Overview RFCs: 793, 1122, 1323, 2018, 2581 full duplex data:
Introduction to Networks
CS1652 TCP Jack Lange University of Pittsburgh
Review: UDP demultiplexing TCP demultiplexing Multiplexing?
Socket programming with TCP
Chapter 3 Transport Layer
Transport Layer Goals: Overview:
Chapter 2: outline 2.1 principles of network applications
Socket programming - Java
Chapter 3 outline 3.1 Transport-layer services
Socket Programming.
Socket Programming 2: Application Layer.
CPSC 441 UDP Socket Programming
Chapter 2: Application layer
Chapter 3 Transport Layer
Socket Programming with UDP
Presentation transcript:

16-1 Last time □ Reliable Data Transfer with packet loss ♦ rdt3.0 □ Pipelining ♦ Problems with stop-and-wait ♦ Go-Back-N ♦ Selective-Repeat

16-2 This time □ UDP socket programming □ TCP

16-3 Chapter 2: Application layer □ 2.1 Principles of network applications □ 2.2 Web and HTTP □ 2.3 FTP □ 2.4 Electronic Mail ♦ SMTP, POP3, IMAP □ 2.5 DNS □ 2.6 P2P file sharing □ 2.7 Socket programming with TCP □ 2.8 Socket programming with UDP □ 2.9 Building a Web server

16-4 Socket programming Socket API □ introduced in BSD4.1 UNIX, 1981 □ explicitly created, used, released by apps □ client/server paradigm □ two types of transport service via socket API: ♦ unreliable datagram ♦ reliable, byte stream-oriented a host-local, application-created, OS-controlled interface (a “door”) into which application process can both send and receive messages to/from another application process socket Goal: learn how to build client/server application that communicate using sockets

16-5 Socket programming with UDP UDP: no “connection” between client and server □ no handshaking □ sender explicitly attaches IP address and port of destination to each packet □ server must extract IP address, port of sender from received packet UDP: transmitted data may be received out of order, or lost application viewpoint UDP provides unreliable transfer of groups of bytes (“datagrams”) between client and server

16-6 Client/server socket interaction: UDP close clientSocket Server (running on hostid ) read reply from clientSocket create socket, clientSocket = new DatagramSocket() Clien t Create, address ( hostid, port=x), send datagram request using clientSocket create socket, port= x, for incoming request: serverSocket = new DatagramSocket(x) read request from serverSocket write reply to serverSocket specifying client host address, port number

16-7 Example: Java client (UDP) Output: sends packet Input: receives packet Client process client UDP socket

16-8 Example: Java client (UDP) import java.io.*; import java.net.*; class UDPClient { public static void main(String args[]) throws Exception { BufferedReader inFromUser = new BufferedReader(new InputStreamReader(System.in)); DatagramSocket clientSocket = new DatagramSocket(); InetAddress IPAddress = InetAddress.getByName("hostname"); byte[] sendData = new byte[1024]; byte[] receiveData = new byte[1024]; String sentence = inFromUser.readLine(); sendData = sentence.getBytes(); Create input stream Create client socket Translate hostname to IP address using DNS

16-9 Example: Java client (UDP), cont. DatagramPacket sendPacket = new DatagramPacket(sendData, sendData.length, IPAddress, 9876); clientSocket.send(sendPacket); DatagramPacket receivePacket = new DatagramPacket(receiveData, receiveData.length); clientSocket.receive(receivePacket); String modifiedSentence = new String(receivePacket.getData()); System.out.println("FROM SERVER:" + modifiedSentence); clientSocket.close(); } Create datagram with data-to-send, length, IP addr, port Send datagram to server Read datagram from server

16-10 Example: Java server (UDP) import java.io.*; import java.net.*; class UDPServer { public static void main(String args[]) throws Exception { DatagramSocket serverSocket = new DatagramSocket(9876); byte[] receiveData = new byte[1024]; byte[] sendData = new byte[1024]; while(true) { DatagramPacket receivePacket = new DatagramPacket(receiveData, receiveData.length); serverSocket.receive(receivePacket); Create datagram socket at port 9876 Create space for received datagram Receive datagram

16-11 Example: Java server (UDP), cont String sentence = new String(receivePacket.getData()); InetAddress IPAddress = receivePacket.getAddress(); int port = receivePacket.getPort(); String capitalizedSentence = sentence.toUpperCase(); sendData = capitalizedSentence.getBytes(); DatagramPacket sendPacket = new DatagramPacket(sendData, sendData.length, IPAddress, port); serverSocket.send(sendPacket); } Get IP addr port #, of sender Write out datagram to socket End of while loop, loop back and wait for another datagram Create datagram to send to client

16-12 Chapter 3 outline □ 3.1 Transport-layer services □ 3.2 Multiplexing and demultiplexing □ 3.3 Connectionless transport: UDP □ 3.4 Principles of reliable data transfer □ 3.5 Connection-oriented transport: TCP ♦ segment structure ♦ reliable data transfer ♦ flow control ♦ connection management □ 3.6 Principles of congestion control □ 3.7 TCP congestion control

16-13 TCP: Overview RFCs: 793, 1122, 1323, 2018, 2581 □ Full duplex data: ♦ bi-directional data flow in same connection ♦ MSS: maximum segment size □ Connection-oriented: ♦ handshaking (exchange of control msgs) inits sender, receiver state before data exchange □ Flow controlled: ♦ sender will not overwhelm receiver □ Point-to-point: ♦ one sender, one receiver □ Reliable, in-order byte steam: ♦ no “message boundaries” □ Pipelined: ♦ TCP congestion and flow control set window size □ Send & receive buffers

16-14 TCP segment structure source port # dest port # 32 bits application data (variable length) sequence number acknowledgement number Receive window Urg data pnter checksu m F SR PAU head len not used Options (variable length) URG: urgent data (generally not used) ACK: ACK # valid PSH: push data now (generally not used) RST, SYN, FIN: connection estab (setup, teardown commands) # bytes rcvr willing to accept counting by bytes of data (not segments!) Internet checksum (as in UDP)

16-15 TCP seq. #’s and ACKs Seq. #’s: ♦ byte stream “number” of first byte in segment’s data ACKs: ♦ seq # of next byte expected from other side ♦ cumulative ACK Q: how receiver handles out-of-order segments ♦ A: TCP spec doesn’t say, - up to implementor Host A Host B Seq=42, ACK=79, data = ‘C’ Seq=79, ACK=43, data = ‘C’ Seq=43, ACK=80 User type s ‘C’ host ACKs receipt of echoed ‘C’ host ACKs receipt of ‘C’, echoes back ‘C’ tim e simple telnet scenario

16-16 TCP Round Trip Time and Timeout Q: how to set TCP timeout value? □ longer than RTT ♦ but RTT varies □ too short: premature timeout ♦ unnecessary retransmissions □ too long: slow reaction to segment loss Q: how to estimate RTT? □ SampleRTT : measured time from segment transmission until ACK receipt ♦ ignore retransmissions □ SampleRTT will vary, want estimated RTT “smoother” ♦ average several recent measurements, not just current SampleRTT

16-17 TCP Round Trip Time and Timeout EstimatedRTT = (1-  )*EstimatedRTT +  *SampleRTT □ Exponentially weighted moving average □ influence of past sample decreases exponentially fast □ typical value:  = 0.125

16-18 Example RTT estimation:

16-19 TCP Round Trip Time and Timeout Setting the timeout □ EstimtedRTT plus “safety margin” ♦ large variation in EstimatedRTT -> larger safety margin □ first estimate of how much SampleRTT deviates from EstimatedRTT: TimeoutInterval = EstimatedRTT + 4*DevRTT DevRTT = (1-  )*DevRTT +  *|SampleRTT-EstimatedRTT| (typically,  = 0.25) Then set timeout interval:

16-20 Chapter 3 outline □ 3.1 Transport-layer services □ 3.2 Multiplexing and demultiplexing □ 3.3 Connectionless transport: UDP □ 3.4 Principles of reliable data transfer □ 3.5 Connection-oriented transport: TCP ♦ segment structure ♦ reliable data transfer ♦ flow control ♦ connection management □ 3.6 Principles of congestion control □ 3.7 TCP congestion control

16-21 TCP reliable data transfer □ TCP creates rdt service on top of IP’s unreliable service □ Pipelined segments □ Cumulative acks □ TCP uses single retransmission timer □ Retransmissions are triggered by: ♦ timeout events ♦ duplicate acks □ Initially consider simplified TCP sender: ♦ ignore duplicate acks ♦ ignore flow control, congestion control

16-22 TCP sender events: data rcvd from app: □ Create segment with seq # □ seq # is byte-stream number of first data byte in segment □ start timer if not already running (think of timer as for oldest unacked segment) □ expiration interval: TimeOutInterval timeout: □ retransmit segment that caused timeout □ restart timer Ack rcvd: □ If acknowledges previously unacked segments ♦ update what is known to be acked ♦ start timer if there are outstanding segments

16-23 TCP sender (simplified) NextSeqNum = InitialSeqNum SendBase = InitialSeqNum loop (forever) { switch(event) event: data received from application above create TCP segment with sequence number NextSeqNum if (timer currently not running) start timer pass segment to IP NextSeqNum = NextSeqNum + length(data) event: timer timeout retransmit not-yet-acknowledged segment with smallest sequence number start timer event: ACK received, with ACK field value of y if (y > SendBase) { SendBase = y if (there are currently not-yet-acknowledged segments) start timer } } /* end of loop forever */ Comment: SendBase-1: last cumulatively ack’ed byte Example: SendBase-1 = 71; y= 73, so the rcvr wants 73+ ; y > SendBase, so that new data is acked

16-24 TCP: retransmission scenarios Host A Seq=100, 20 bytes data ACK=100 tim e premature timeout Host B Seq=92, 8 bytes data ACK=120 Seq=92, 8 bytes data Seq=92 timeout ACK=120 Host A Seq=92, 8 bytes data ACK=100 los s timeout lost ACK scenario Host B X Seq=92, 8 bytes data ACK=100 tim e Seq=92 timeout SendBase = 100 SendBase = 120 SendBase = 120 Sendbas e = 100

16-25 TCP retransmission scenarios (more) Host A Seq=92, 8 bytes data ACK=100 los s timeout Cumulative ACK scenario Host B X Seq=100, 20 bytes data ACK=120 tim e SendBase = 120

16-26 TCP ACK generation [RFC 1122, RFC 2581] Event at Receiver Arrival of in-order segment with expected seq #. All data up to expected seq # already ACKed Arrival of in-order segment with expected seq #. One other segment has ACK pending Arrival of out-of-order segment higher-than-expect seq. #. Gap detected Arrival of segment that partially or completely fills gap TCP Receiver action Delayed ACK. Wait up to 500ms for next segment. If no next segment, send ACK Immediately send single cumulative ACK, ACKing both in-order segments Immediately send duplicate ACK, indicating seq. # of next expected byte Immediate send ACK, provided that segment startsat lower end of gap

16-27 Recap □ UDP socket programming ♦ DatagramSocket, DatagramPacket □ TCP ♦ Sequence numbers, ACKs ♦ RTT, DevRTT, timeout calculations ♦ Reliable data transfer algorithm

16-28 Next time □ TCP ♦ Fast retransmit ♦ Flow control ♦ Connection management ♦ Congestion control