TCP/IP IP Ipv4 Packet Layout Ipv4 Packet Layout
Total Page:16
File Type:pdf, Size:1020Kb
IP • Internetworking protocol • Network layer TCP/IP • Common packet format for the Internet • Specifies what packets look like • Fragments long packets into shorter packets Emin Gun Sirer • Reassemblesfragments into original shape • Some parts are fundamental, and some are arbitrary • IPv4 is what most people use • IPv6 clears up some of the messy parts, but is not yet in wide use IPv4 packet layout IPv4 packet layout Version IHL TOS Total Length Version IHL TOS Total Length Identification Flags Fragment Offset Identification Flags Fragment Offset TTL Protocol Header Checksum TTL Protocol Header Checksum Source Address Source Address Destination Address Destination Address Options Options Data Data 1 IP Fragmentation IP Fragmentation Mechanics • Networks have different maximum packet sizes • IP divides a long datagram into N smaller • Big packets are sometimes desirable – less overhead datagrams • Huge packets are not desirable – reduced response time for others • Copies the header • Higher level protocols (e.g. TCP or UDP) could • Assigns a Fragment ID to each part figure out the max transfer unit and chop data into • Sets the More Fragments bit smaller packets • Receiving end puts the fragments together based • The endpoints do not necessarily know what the MTU is on the path on the new IP headers • The route can change underneath • Throws out fragments after a certain amount of • Consequently, IP transparently fragments and time if they have not be reassembled reassembles packets IP Options UDP • Source Routing: The source specifies the set of • Unreliable Datagram Protocol hosts that the packet should traverse • IP goes from host to host • Record Route: If this option appears in a packet, every router along a path attaches its own IP • We need a way to get datagrams from one address to the packet application to another • Timestamp: Every router along the route attaches • How do we identify applications on the a timestamp to the packet hosts ? • Security: Packets are marked with user info, and • Assign port numbers the security classification of the person on whose • E.g. port 13 belongs to the time service behalf they travel on the network • Most of these options pose security holes and are generally not implemented 2 UDP Packet Layout UDP Version IHL TOS Total Length • UDP is unreliable IP Identification Flags Fragment Offset • A UDP packet may get dropped at any time TTL Protocol Header Checksum • It may get duplicated Source Address • A series of UDP packets may get reordered Destination Address • Applications need to deal with reordering, UDP Source Port Destination Port duplicate suppression, reliable delivery Length Checksum • Some apps can ignore these effects and still function • Unreliable datagrams are the bare-bones network Data service • Good to build on, esp for multimedia applications • UDP adds Ports, Data Length and Data checksum TCP TCP/IP Packets • Transmission Control Protocol Version IHL TOS Total Length • Reliable, ordered communication IP Identification Flags Fragment Offset • Enough applications demand reliable ordered TTL Protocol Header Checksum delivery that they should not have to implement Source Address their own protocol Destination Address Source Port Destination Port • A standard, adaptive protocol that delivers good- Sequence Number enough performance and deals well with Acknowledgement Number congestion TCP Offset ACK|URG|SYN|FIN|RST Window • All web traffic travels over TCP/IP Checksum Urgent Pointer Options Padding Data 3 TCP Packets TCP Connections • Each packet carries a unique ID • TCP is connection oriented • The initial number is chosen randomly SYN • The ID is incremented by the data length • A connection is initiated with a three- • Each packet carries an acknowledgement SYN, ACK of SYN way handshake • Can acknowledge a set of packets by ack’ing the • Three-way handshake latest one received ensures against • Reliable transport is implemented using ACK of SYN duplicate SYN these identifiers packets • Takes 3 packets, 1.5 RTT Typical TCP Usage Reliable transport SYN • Three round-trips to set up a DATA, id=17 • TCP keeps a copy of all sent, SYN, ACK of SYN connection, send a data but unacknowledged packets packet, receive a response, DATA 23, ACK 17 • If acknowledgement does not ACK of SYN tear down connection arrive within a “send DATA • FINs work (mostly) like timeout” period, packet is SYNs to tear down DATA, id=18 resent connection DATA, ACK Send timeout • Send timeout adjusts to the • Need to wait after a FIN for round-trip delay FIN, ACK straggling packets FIN, ACK DATA, id=18 4 TCP timeouts TCP Windows • What is a good timeout period ? • Want to improve throughput without unnecessary transmissions NewAverageRTT = (1 - ?) OldAverageRTT + ? LatestRTT NewAverageDev = (1 - ?) OldAverageDev+ ? LatestDev where LatestRTT = ( ack_receive_time – send_time), LatestDev = |LatestRTT– AverageRTT|, ? = 1/8, typically. Timeout = AverageRTT + 4*AverageDev • Multiple outstanding packets can increase • Timeout is thus a function of RTT and deviation throughput TCP Windows TCP Congestion Control • Can have more than one • TCP Increases its window size as long as no DATA, id=17 packet in transit packets are dropped DATA, id=18 DATA, id=19 • Especially over fat pipes, e.g. • It halves the window size when a packet drop DATA, id=20 satellite connection occurs • A packet drop is evident from the acknowledgements • Need to keep track of all ACK 17 • Therefore, it will slowly build up to the max packets within the window bandwidth, and hover around the max ACK 18 • Need to adjust window size • It doesn’t achieve the max possible though ACK 19 • Instead, it shares the bandwidth well with other TCP connections ACK 20 • This linear-increase, exponential backoff in the face of congestion is termed TCP-friendliness 5 A D Bottleneck TCP Window Size B Link TCP Fairness • Linear increase • Want to • Exponential Max Bandwidth share the backoff bottleneck link fairly • Assuming no other losses in between two the network flows Bandwidth for Host A Bandwidth except those due to bandwidth Time Bandwidth for Host B TCP Slow Start TCP Slow Start • Linear increase takes a long time to build up a • Initial phase of window size that matches the link exponential bandwidth*delay Max Bandwidth increase • Most file transactions are not long enough • Consequently, TCP can spend a lot of time with • Assuming no small windows, never getting the chance to reach other losses in a sufficiently large window size the network • Fix: Allow TCP to build up to a large window size Bandwidth except those initially by doubling the window size until first due to loss bandwidth Time 6 TCP Summary • Reliable ordered message delivery • Connection oriented, 3-way handshake • Transmission window for better throughput • Timeouts based on link parameters • Congestion control • Linear increase, exponential backoff • Fast adaptation • Exponential increase in the initial phase 7.