Presentation is loading. Please wait.

Presentation is loading. Please wait.

TCP/IP Jennifer Rexford Advanced Computer Networks Tuesdays/Thursdays 1:30pm-2:50pm.

Similar presentations


Presentation on theme: "TCP/IP Jennifer Rexford Advanced Computer Networks Tuesdays/Thursdays 1:30pm-2:50pm."— Presentation transcript:

1 TCP/IP Jennifer Rexford Advanced Computer Networks http://www.cs.princeton.edu/courses/archive/fall08/cos561/ Tuesdays/Thursdays 1:30pm-2:50pm

2 Goals of Today’s Class Cerf/Kahn paper –Overview and discussion –Separation of IP from TCP Brief overview of IP header Transport protocols –Demultiplexing and error detection –Transmission Control Protocol TCP congestion control, if time allows

3 Vint Cerf and Bob Kahn “A Protocol for Packet Network Intercommunication” (IEEE Trans. on Communications, May 1974) Written when Vint Cerf was an assistant professor at Stanford, and Bob Kahn was working at ARPA.

4 Life in the Early 1970s Multiple unconnected networks –ARPAnet –Data-over-cable –Packet satellite (Aloha) –Packet radio ARPAnet satellite net

5 Differences Across Packet-Switched Networks Addressing Maximum packet size Timing for handling success/failure of delivery Handling of lost or corrupted data Routing, fault detection, status information, … ARPAnet satellite net

6 Where to Handle Heterogeneity? Application process? End host? Packet switches? Someplace else? Compatible process and host conventions –Obviate the need to support all combinations Retain the unique features of each network –Avoid changing the local network components Introduce the notion of a gateway

7 Gateways Between Different Kinds of Networks ARPAnet satellite net Gateway “Embed internetwork packets in local packet format or extract them” Route (at internetwork level) to next gateway gateway Internetwork layer Internetwork appears as a single, uniform entity Despite the heterogeneity of the local networks Network of networks

8 Internetwork Packet Format Internetwork header in standard format –Interpreted by the gateways and end hosts Source and destination addresses –Uniformly and uniquely identify every end point Ensure proper sequencing of the data –Include a sequence number and byte count Enable detection of corrupted text –Checksum for an end-to-end check on the text local header text checksum source address dest. address seq. # byte count flag field internetwork header

9 Process-Level Communication Enable pairs of processes to communicate –Full duplex –Unbounded but finite-length messages –E.g., keystrokes or a file Key ideas –Port numbers to (de)multiplex packets –Breaking messages into segments –Sequence numbers and reassembly –Retransmission and duplicate detection –Window-based flow control

10 Differences in Max Packet Size Select smallest packet size as the new max? Coordinate to determine max size on a path? Enable gateway to fragment a large packet? –Reassembly by the next gateway? The receiver? Design trade-offs –Coordination overhead for identifying the max –Overhead of sending many small packets –Overhead of buffering packets for reassembly

11 Discussion What did they get right? –Which ideas were key to the Internet’s success? –Which decisions still seem right today? What did they miss? –Which ideas had to be added later? –Which decisions seem wrong in hindsight? What would you do in a clean-slate design? –If your goal wasn’t to support communication between disparate packet-switched networks –Would you do anything differently?

12 Separating IP from TCP Original implementation –Only supported ordered reliable byte stream –Fine for file transfer and remote login Less appropriate for other applications –Interactive applications like voice –Let application decide whether/how to handle loss Reorganization of the original TCP –IP: addressing/forwarding of individual packets –TCP: services such as flow control & loss recovery Alternative transport protocols, e.g., UDP

13 IP Packets

14 IP Packet Structure (for IPv4 Packets) 4-bit Version 4-bit Header Length 8-bit Type of Service (TOS) 16-bit Total Length (Bytes) 16-bit Identification 3-bit Flags 13-bit Fragment Offset 8-bit Time to Live (TTL) 8-bit Protocol 16-bit Header Checksum 32-bit Source IP Address 32-bit Destination IP Address Options (if any) Payload

15 IP Header: Version, Length, ToS Version number (4 bits) –Indicates the version of the IP protocol –Necessary to know what other fields to expect –E.g. “4” (for IPv4), and sometimes “6” (for IPv6) Header length (4 bits) –Number of 32-bit words in the header –Typically “5” (for a 20-byte IPv4 header) –Can be more when “IP options” are used Type-of-Service (8 bits) –Allow differential treatment of packets –E.g., low delay versus high bandwidth

16 IP Header: Length, Fragments, TTL Total length (16 bits) –Number of bytes in the packet –Maximum size is 63,535 bytes (2 16 -1) –… though underlying link may impose harder limits Fragmentation information (32 bits) –Packet identifier, flags, and fragment offset –Supports dividing a large IP packet into fragments –… in case a link cannot handle a large IP packet Time-To-Live (8 bits) –Used to identify packets stuck in forwarding loops –… and eventually discard them from the network

17 IP Header Fields: Transport Protocol Protocol (8 bits) –Identifies the higher-level protocol E.g., “6” for Transmission Control Protocol E.g., “17” for the User Datagram Protocol –Needed for demultiplexing at receiving host Indicates what kind of header to expect next IP header TCP headerUDP header protocol=6 protocol=17

18 IP Header: Checksum on the Header Checksum (16 bits) –Sum of all 16-bit words in the IP packet header –If any bits of the header are corrupted in transit –… the checksum won’t match at receiving host –Receiving host discards corrupted packets Sending host will retransmit the packet, if needed 134 + 212 = 346 134 + 216 = 350 Mismatch!

19 IP Header: To and From Addresses Two IP addresses –Source IP address (32 bits) –Destination IP address (32 bits) Destination address –Unique identifier for the receiving host –Each node can make forwarding decisions Source address –Unique identifier for the sending host –Recipient decides whether to accept packet –Enables recipient to reply back to source

20 Transport Protocols

21 Role of Transport Layer Application layer –Between applications (e.g., browsers and servers) –E.g., HyperText Transfer Protocol, File Transfer Protocol, Network News Transfer Protocol, … Transport layer –Between processes (e.g., sockets) –Relies on network layer, & serves application layer –E.g., TCP and UDP Network layer –Between nodes (e.g., routers and hosts) –Hides details of the link technology –E.g., IP

22 Two Basic Transport Features Demultiplexing: port numbers Error detection: checksums Web server (port 80) Client host Server host 128.2.194.242 Echo server (port 7) Service request for 128.2.194.242:80 (i.e., the Web server) OS Client IPpayload detect corruption

23 User Datagram Protocol (UDP) Datagram messaging service –Demultiplexing of messages: port numbers –Detecting corrupted messages: checksum Lightweight communication between processes –Send messages to and receive them from a socket –Avoid overhead and delays of ordered, reliable delivery SRC port DST port checksumlength DATA

24 Why Would Anyone Use UDP? Fine control over whether and when data are sent –As soon as an application process writes into the socket –… UDP will package the data and send the packet No delay for connection establishment –UDP just blasts away without any formal preliminaries –… which avoids introducing any unnecessary delays No connection state –No allocation of buffers, parameters, sequence #s, etc. –… making it easier to handle many active clients at once Small packet header overhead –UDP header is only eight-bytes long

25 Transmission Control Protocol (TCP) Stream-of-bytes service –Sends and receives a stream of bytes, not messages Reliable, in-order delivery –Checksums to detect corrupted data –Sequence numbers to detect losses and reorder data –Acknowledgments & retransmissions for reliable delivery Connection oriented –Explicit set-up and tear-down of TCP session Flow control – Prevent overflow of the receiver’s buffer space Congestion control (came in late 1980s) –Adapt to network congestion for the greater good

26 Transmission Control Protocol (TCP)

27 TCP Segment IP packet –No bigger than Maximum Transmission Unit (MTU) –E.g., up to 1500 bytes on an Ethernet TCP packet –IP packet with a TCP header and data inside –TCP header is typically 20 bytes long TCP segment –No more than Maximum Segment Size (MSS) bytes –E.g., up to 1460 consecutive bytes from the stream IP Hdr IP Data TCP HdrTCP Data (segment)

28 TCP Header Source portDestination port Sequence number Acknowledgment Advertised window HdrLen Flags 0 ChecksumUrgent pointer Options (variable) Data Flags: SYN FIN RST PSH URG ACK

29 TCP Header: Ports and Seq/Ack Numbers Identifying the process end-point –Source port –Destination port Delivering ordered reliable byte stream –Sequence number: # of first byte in the segment –Acknowledgment: # of next expected byte TCP Data Sequence number = 1 st byte Byte 81 Acknowledgment number = next byte

30 TCP Header: Length and Flags Header length –Size of the TCP header –Usually 20 bytes, but higher if options are used Flags to piggyback information –SYN: open connection –FIN: close connection –RST: abort connection –ACK: acknowledgment (in acknowledgement #) –PSH: not important –URG: not important (relates to Urgent pointer)

31 TCP Header: Checksum and Window Checksum –Detect corruption of the TCP header and segment Advertised window –Additional data the receiver can receive Window Size Outstanding Un-ack’d data Data OK to send Data not OK to send yet Data ACK’d

32 TCP Support for Reliable Delivery Detect missing data: sequence number – Used to detect a gap in the stream of bytes –... and for putting the data back in order Detect bit errors: checksum – Used to detect corrupted data at the receiver – …leading the receiver to drop the packet Recover from lost data: retransmission – Sender retransmits lost or corrupted data – Two main ways to detect lost packets Retransmission timeout and fast retransmission

33 Automatic Repeat reQuest (ARQ) Time Packet ACK Timeout Automatic Repeat reQuest –Receiver sends acknowledgment (ACK) when it receives packet –Sender waits for ACK and timeouts if it does not arrive within some time period Simplest ARQ protocol –Stop and wait –Send a packet, stop and wait until ACK arrives SenderReceiver

34 Reasons for Retransmission Packet ACK Timeout Packet ACK Timeout Packet Timeout Packet ACK Timeout Packet ACK Timeout Packet ACK Timeout ACK lost DUPLICATE PACKET Packet lost Early timeout DUPLICATE PACKETS

35 Fast Retransmission Better solution possible under sliding window –Although packet n might have been lost –… packets n+1, n+2, and so on might get through Idea: have the receiver send ACK packets –ACK says that receiver is still awaiting n th packet And repeated ACKs suggest later packets have arrived –Sender can view the “duplicate ACKs” as an early hint … that the n th packet must have been lost … and perform the retransmission early Fast retransmission –Sender retransmits data after the “triple duplicate ACK”

36 TCP Congestion Control

37 Congestion is Unavoidable in IP Best-effort delivery –Let everybody send –Try to deliver what you can –… and just drop the rest If many packets arrive in short period of time –The node cannot keep up with the arriving traffic –… and the buffer may eventually overflow

38 The Problem of Congestion What is congestion? –Load is higher than capacity What do IP routers do? –Drop the excess packets Why is this bad? –Wasted bandwidth for retransmissions Load Goodput “congestion collapse” Increase in load that results in a decrease in useful work done.

39 Many Important Questions How does the sender know there is congestion? –Explicit feedback from the network? –Inference based on network performance? How should the sender adapt? –Explicit sending rate computed by the network? –End host coordinates with other hosts? –End host thinks globally but acts locally? What is the performance objective? –Maximizing goodput, even if some users suffer more? –Fairness? (Whatever the heck that means!) How fast should new TCP senders send?

40 Inferring From Implicit Feedback ? What does the end host see? –Round-trip loss –Round-trip delay

41 Host Adapts Sending Rate Over Time Congestion window –Maximum number of bytes to have in transit –I.e., # of bytes still awaiting acknowledgments Upon detecting congestion –Decrease the window size (e.g., divide in half) –End host does its part to alleviate the congestion Upon not detecting congestion –Increase the window size, a little at a time –And see if the packets are successfully delivered –End host learns whether conditions have changed

42 Leads to the TCP “Sawtooth” Window size halved Loss Time

43 Receiver Window vs. Congestion Window Flow control –Keep a fast sender from overwhelming a slow receiver Congestion control –Keep a set of senders from overloading the network Different concepts, but similar mechanisms –TCP flow control: receiver window –TCP congestion control: congestion window –TCP window: min{congestion window, receiver window}

44 How Should a New Flow Start t Window But, could take a long time to get started! Need to start with a small CWND to avoid overloading the network.

45 “Slow Start” Phase Start with a small congestion window –Initially, CWND is 1 Max Segment Size (MSS) –So, initial sending rate is MSS/RTT That could be pretty wasteful –Might be much less than the actual bandwidth –Linear increase takes a long time to accelerate Slow-start phase –Sender starts at a slow rate (hence the name) –… but increases the rate exponentially –… until the first loss event

46 Slow Start and the TCP Sawtooth Loss Exponential “slow start” t Window Why is it called slow-start? Because TCP originally had no congestion control mechanism. The source would just start by sending a whole receiver window’s worth of data.

47 Two Kinds of Loss in TCP Timeout –Packet n is lost and detected via a timeout E.g., because all packets in flight were lost –After timeout, blasting away for the entire CWND would trigger a very large burst in traffic –So, better to start over with a low CWND Triple duplicate ACK –Packet n is lost, but packets n+1, n+2, etc. arrive Receiver sends duplicate acknowledgments –And the sender retransmits packet n quickly –Do a multiplicative decrease and keep going

48 Repeating Slow Start After Timeout t Window Slow-start restart: Go back to CWND of 1, but take advantage of knowing the previous value of CWND. Slow start in operation until it reaches half of previous cwnd. timeout

49 What About Inefficiency? TCP congestion control is not very efficient –The sawtooth behavior is wasteful –Short flows never ramp up to max rate –Poor performance on high-bandwidth paths –Poor performance on long-RTT paths Ongoing work on improvements to TCP –Better information about network conditions Measurement of available bandwidth on a path Explicit feedback from the routers –Better performance under high bandwidth-delay product (e.g., bulk data transfer between labs)

50 What About Cheating? Some folks are more fair than others –Running multiple TCP connections in parallel –Modifying the TCP implementation in the OS –Use the User Datagram Protocol (UDP) What is the impact –Good guys slow down to make room for you –You get an unfair share of the bandwidth Possible solutions? –Routers detect cheating and drop excess packets? –Peer pressure? –Move congestion control to the network?


Download ppt "TCP/IP Jennifer Rexford Advanced Computer Networks Tuesdays/Thursdays 1:30pm-2:50pm."

Similar presentations


Ads by Google