600 likes | 713 Views
History and Internals of TCP/IP. Andrew Tucker February 15, 2000. What We’ll Cover . Big picture of network protocols Where TCP/IP lives in the network layer model Protocols that utilize TCP/IP Under the hood of IP Addressing and Routing Under the hood of TCP (and UDP)
E N D
History and Internals of TCP/IP Andrew Tucker February 15, 2000
What We’ll Cover • Big picture of network protocols • Where TCP/IP lives in the network layer model • Protocols that utilize TCP/IP • Under the hood of IP • Addressing and Routing • Under the hood of TCP (and UDP) • Ensuring reliable delivery • Weaknesses of TCP/IP • Resources for more info
What We’ll Cover • All topics should be considered overviews • References for more depth on each subject will be given at the end • Programming with sockets will be covered in next session • Feel free to interrupt with questions at any time
What is TCP/IP? • Set of protocols that are used for communication across a network • TCP/IP = Transmission Control Protocol / Internet Protocol • UDP = User Datagram Protocol • Standard method for transferring data and information on the Internet
What is a protocol? • Definition: A set of rules that regulate the way data is transmitted between computers. • An infinite amount of ways to realize this abstract notion - so why did the Internet standardize on TCP/IP?
Why TCP/IP? • ‘cuz Uncle Sam said so! • Originally a set of conventions developed by the DOD and DARPA in 1969, formalized into TCP/IP in 1980s • Original ideas attributed to Vinton Cerf and Robert Kahn • Gained popularity in the user community because of inclusion in v4.2 of BSD UNIX
Why TCP/IP? • DARPA network was the early precursor of the Internet • If you wanted to talk on the DARPANET you needed to speak TCP/IP • TCP/IP was designed well enough to scale to the Internet* * - until recently...
Why TCP/IP? • Three Main Goals: • Interoperability - communicate between heterogeneous hardware and OS • Robustness - reliability and performance • Ease of Reconfiguration - add and remove computers without disruption
ISO OSI 7-layer model • ISO developed the 7-layer Open Systems Interconnect (OSI) model independent of TCP/IP in the 1970s • Allows each layer of a protocol to be changed without affecting layers above or below
Layer 7: interfaces with end user Layer 6: data format conversion Layer 5: establishes node connection Layer 4: ensures delivery and correctness Layer 3: routing and addressing Layer 2: interface for physical line (NIC) Layer 1: actual transmission line or “bit pipe” ISO OSI 7-layer model
Modified Conceptual 5 Layer Model • Top three layers ISO OSI model don’t relate well to Internet protocols using TCP/IP • Conceptually it helps to think about a 5 layer model for the Internet and TCP/IP
TCP/IP In the 5 Layer Model • TCP handles the transport layer and guarantees data delivery and correctness • UDP is a TCP replacement that doesn’t guarantee delivery • IP lives in the network layer and handles routing and addressing
TCP/IP In the 5 Layer Model Stream Connection ConnectionlessDatagram Sockets API
Protocols Built on TCP/IP FTP HTTP NNTP TFTP DNS Telnet SMTP TCP UDP IP
IP Internals • Current version in widespread use is IPv4 • Each node in an internet has a 32-bit IP address such as 10.0.3.172 IP knows nothing of text names like www.bsquare.com - they are translated to the numeric form by DNS
IP Internals • IP addresses are split into two parts: • network - same for all hosts on the same network • host - identifies a specific host within a network • The number of bits that represent the network and host vary by the address “class”
IP Internals 7 24 Class A 0 Network Host 14 16 Class B 1 0 Network Host 21 8 Class C 1 1 0 Network Host
IP Internals • Original idea was to have a small number of WANs (class A), modest number of campus size networks (class B) and a large number of LANs (class C) • Explosion of the Internet has changed this - many clever interpretations of IP addresses have been invented to stretch the limit
IP Internals • IP routes information across a network via “packet switching” (as opposed to circuit switching) • Each packet is transmitted as a separate entity • Different packets can take different routes and can arrive in different order than they were sent
IP Internals • Packets are sent as datagrams, so delivery isn’t guaranteed • Each packet has an IP header that contains source and destination address, data and header length, etc • Packets are routed based on the network specified in the destination address
IP Internals • If the source and destination address are on the same network life is simple (e.g. Ethernet uses ARP to get the MAC address) • If the source and destination address are on different networks it is more complicated...
IP Internals • Special nodes called “gateways” connect networks • Gateways have tables that map network numbers to gateway addresses • Datagrams are forwarded to the gateway corresponding to their destination network number • What if there is no gateway available?
IP Internals • Default gateways are used if no mapping is present • Once a mapping is found the sender is notified of the correct gateway mapping (via ICMP) • Over time, routers build up a mapping table based on ICMP notifications
IP Internals • A simple routing example via TraceRoute: 1 www.worldaccessnet.com (206.190.139.3) 2 worldaccessnet-2t1-ltipdxbackbone.ltinet.net (206.190.136.117) 3 pdx2lc.worldaccessnet.com (206.190.136.6) 4 seattle-portland-ds3.sea.above.net (209.133.31.50) 5 POS1-0-0.GW2.SEA4.ALTER.NET (157.130.177.121) 6 112.ATM3-0.XR2.SEA4.ALTER.NET (146.188.200.174) 7 292.ATM3-0.XR2.SEA1.ALTER.NET (146.188.200.157) 8 194.ATM9-0-0.GW1.SEA1.ALTER.NET (146.188.200.45) 9 63.76.82.94 (63.76.82.94) 10 www.bsquare.com (63.76.82.70)
IP Internals • TTL (Time To Live) field in IP header eliminates endless routing loops by limiting hop count • 127.0.0.1 is a special loopback address
UDP Internals • Ensures data correctness, but not reliable delivery • Adds a “port” number to IP • Think of a port as channels for a single machine - more on this in the discussion of sockets
UDP Internals • Sends entire chuck of data in one packet • Sends datagrams in one direction
TCP Internals • Lots of versions floating around: • Tahoe - released with BSD NR 1.0 • Reno - released with BSD NR 2.0 • New TCP Reno • TCP Vegas • Versions are guaranteed to interoperate but not with optimal performance
TCP Internals • Guarantees data correctness and delivery • Uses ports identical to UDP • Breaks data into individual packets • Full duplex two-way stream • Complete implementation is complicated with lots of intricate details - we’ll touch on interesting highlights
TCP Internals • Operates on two basic principles: flow control and congestion control • Flow control involves preventing senders from overrunning the capacity of receivers • Congestion control involves preventing too much data from being injected into the network, causing links and switches to become overloaded
TCP Internals • Follows a basic protocol design rule called “smart sender, dumb receiver” • Flow control done via “sliding window” • For window size n, only n bytes can be sent without receiving an acknowledgement • When data is acknowledged, the window slides forward
TCP Internals • TCP packet header advertises a window size indicating the number of bytes the receiver is willing to get • Initial window size established in TCP connection setup
TCP Internals • Packet header includes the last byte acknowledged and the packet sequence number • Sequence numbers are used to reassemble packets in the order they were sent
TCP Internals offered window (advertised by receiver) usable window 1 2 3 4 5 6 7 8 9 10 11 12 sent and acknowledged can send ASAP can’t send until window moves sent, not ACKed Left side of window advances when data is acknowledged Right side controlled by size of window advertisement
TCP periodically sends a 1-byte “probe” packet which fails but has a new advertised window size EffectiveWindow = AdvertisedWindow - (LastByteSent - LastByteAcked) TCP Internals • What if receiver’s buffer fills up and results in an advertised window size of 0?
TCP Internals • Acks indicate last consecutive packet received • Packets are retransmitted if an ACK is not received after a certain time period • Timeout value varies depending on previous packets average round trip time (RTT)
TCP Internals • Congestion control is built on top of sliding window flow control • Consists of three intertwined mechanisms: • Additive Increase / Multiplicative Decrease • Slow Start • Fast Retransmit
TCP Internals • An additional window size is maintained in each packet header called the congestion window • Similar to advertised window, but not directly controlled by sender or receiver
TCP Internals • Effective window size calculation changes: MaxWindow = MIN(CongestionWindow,AdvertisedWindow) EffectiveWindow = MaxWindow - (LastByteSent - LastByteAcked) • How is congestion window size calculated?
TCP Internals • Initially it is set to the Maximum Segment Size (MSS) • Whenever a congestion window size is successfully transmitted, the size is incremented by MSS - hence the term “additive increase”
TCP Internals • If a packet is dropped (e.g an ACK times out), it is assumed to be due to network congestion • When a packet is dropped, the congestion window size is cut in half - hence the term “multiplicative decrease”
TCP Internals • Result is that the window size is eased up until a packet is dropped and then it is throttled back • Works OK during the middle of a connection, but takes too long to ramp up when starting from scratch...
TCP Internals • Slow Start addresses initial connection issue and temporarily discards additive increase • Congestion window size starts at 1 packet and is doubled every time a full window is successfully transmitted • Eventually a packet is dropped and additive increase is resumed
TCP Internals • Why is it called Slow Start if it changes from linear to exponential growth of congestion window size? • Refers to difference when compared to original TCP strategy of always starting with full advertised window size
TCP Internals • Fast retransmit was not part of original TCP spec • Added by TCP Reno circa 1990 to deal with performance problems
TCP Internals • Fast Retransmit means that if the sender sees a number of duplicate ACKs it retransmits first packet after ACK • Assumes that a number of duplicate ACKs imply a dropped packet
TCP Internals Fast Retransmit in action! Packet 1 Packet 2 Packet 3 ACK 1 Packet 4 ACK 1 Packet 5 ACK 1 Packet 2 ACK 5