2 Learning outcome Application layer Transport layer Internet layer TCP/IPLearning outcomeApplication layerHTTP, FTP, TELNET, POP3, SMTP, IMAP, DNS protocolsTransport layerTCP and UDPTCP and UDP segmentOpening and closing connectionsFlow controlReliable data transmissionInternet layerIP , ICMP, ARP and RARPIP datagramRouting
3 Learning outcome cont’d TCP/IPLearning outcome cont’dBefore we have explained howEach layer adds header information to the block of data passed to it from the previous layerAnd these headers are interpreted and removed by corresponding layer at the receiving endIn this ChapterWe will look in details at the header information constructed at the transport and internet layersWe will also show how this information is used
4 Reading List for this chapter TCP/IPReading List for this chapterJoe Casad, Teach Teach Yourself TCP/IP, chs. 4-6orWilliam Buchanan, Mastering the Internet, Ch. 4orJulian Moss, “understanding TCP/IP” (parts 2-4, October 1997-March 1998)andLiam Proven, “understanding TCP/IP” [details of IP addressing]( January 2001)
5 Network-specific protocols (e.g. Ethernet, Token-ring, FDDI, ATM) TCP/IPTCP/IP Protocol Suite is a four-layered protocol suite. The location of the important protocols within the TCP/IP layers is showed belowOSI layersTCPUDPIP Internet layer ICMPNetwork interfaceNetwork-specific protocols (e.g. Ethernet, Token-ring, FDDI, ATM)Transport layerSMTPHTTPTELNETFTPSNMPDNSRTPApplication layerIMAPPOP5
7 TCP/IP suiteThe application layerHandles high-level protocols, issues of representation, encoding, and dialog control. The TCP/IP combines all application-related issues into one layer, and assures this data is properly packaged for the next layer.FTP, HTTP, SMNP, DNS ...Format of data, data structure, encode …Dialog control, session management …
8 Application Protocols TCP/IP suiteApplication ProtocolsProtocolsRolePortsHTTPHyper Text Transfer Protocolbrowser and web server communicationclient browser connects to HTTP serverclient browser send a request to the HTTP serverHTTP server reacts by sending a responseHTTP server disconnects80FTPFile transfer protocolallow people anywhere on the Internet to log in and download whatever files they have placed on the FTP server, or upload other files.Port 20 for data channel and 21 for control channel20,21
9 Application Protocols TCP/IP suiteApplication ProtocolsProtocolsRolePortsDNSDomain Name Systemprovides translation between host name and IP addressDNS messages are carried using UDP on port 5353TELNETRemote login23
10 Application Protocols (cont’d) TCP/IP suiteApplication Protocols (cont’d)ProtocolsRolePortsPOP3Post Office Protocol 3The point of POP3 is to fetch from the remote mailbox and store it on the user’s local machine to read later.Downloaded s are then deleted from the server.110IMAPInternet Message Access ControlRetrieve sretaining on the server and for organizing it in folders on the serve143SMTPSendingSending sEstablish TCP connection to port 25 of the destination machine / serverStart sending message25
11 The transport layer Transport layer Transport protocols TCP/IP suiteThe transport layerTransport layerTransport protocolsUDPTCPTCP AND UDP segments
12 Transport Protocols in the Internet TCP/IP suiteTransport Protocols in the InternetThe Internet supports 2 transport protocolsUDP - User Datagram Protocoldatagram orientedunreliable, connectionlessNo acknowledgmentsimpleunicast and multicastuseful only for few applications, e.g., multimedia applicationsused a lot for servicesnetwork management (SNMP), routing (RIP), naming (DNS), etc.TCP - Transmission Control Protocolstream orientedreliable, connection-orientedcomplexonly unicastused for most Internet applications:web (HTTP), (SMTP), file transfer (FTP), terminal (TELNET), etc.
13 User Datagram Protocol TCP/IPUser Datagram ProtocolUDPHeaderUDP DataDatagramHeaderDatagram Data AreaUDPHeaderUDP DataFrameHeaderFrame Data AreaDatagramHeaderDatagram Data AreaUDPHeaderUDP Data
14 User Datagram Protocol TCP/IPUser Datagram ProtocolSource port (optional - zero if not used)Length - Count of octets including header and data (minimum is 8)Checksum (optional - zero if not used)UDP Source PortUDP Destination PortUDP Message LengthUDP ChecksumData . . .
15 User Datagram Protocol TCP/IPUser Datagram ProtocolIP checksum does not include dataUDP checksum is only way to guarantee that data is correctUDP checksum includes pseudo-headerPseudoHeaderUDPHeaderUDP Data
16 UDP Pseudo-Header Source IP Address Destination Address Zero Protocol TCP/IPUDP Pseudo-HeaderSource IP AddressDestination AddressZeroProtocolUDP LengthUDP Source PortUDP Destination PortUDP Message LengthUDP ChecksumData . . .
17 Transport Control Protocol TCP/IPTransport Control Protocol
18 TCP/IPTCP LingoWhen a client requests a connection, it sends a “SYN” segment (a special TCP segment) to the server port.SYN stands for synchronize. The SYN message includes the client’s ISN.ISN is Initial Sequence Number.
19 More...TCP/IPEvery TCP segment includes a Sequence Number that refers to the first byte of data included in the segment.Every TCP segment includes a Request Number (Acknowledgement Number) that indicates the byte number of the next data that is expected to be received.All bytes up through this number have already been received.
20 And more... There are a bunch of control flags: TCP/IPAnd more...There are a bunch of control flags:URG: urgent data included.ACK: this segment is (among other things) an acknowledgement.RST: error - abort the session.SYN: synchronize Sequence Numbers (setup)FIN: polite connection termination.
21 And more... MSS: Maximum segment size (A TCP option) TCP/IPAnd more...MSS: Maximum segment size (A TCP option)Window: Every ACK includes a Window field that tells the sender how many bytes it can send before the receiver will have to throw it away (due to fixed buffer size).
22 Client Server SYN 1 ISN=X time SYN 2 ISN=Y ACK=X+1 3 ACK=Y+1 TCP Connection creationClientServerSYNISN=X1SYNISN=Y ACK=X+12timeACK=Y+13TCP 3-way handshake
23 TCP 3-way handshake1Client: “I want to talk, and I’m starting with byte number X+1”.Server: “OK, I’m here and I’ll talk. My first byte will be called number Y+1, and I know your first byte will be number X+1”.Client: “Got it - you start at byte number Y+1”.23
24 TCP Data and ACK Once the connection is established, data can be sent. Each data segment includes a sequence number identifying the first byte in the segment.Each segment (data or empty) includes a request number indicating what data has been received.
25 TCP Fast Retransmit Another enhancement to TCP congestion control Idea: When sender sees 3 duplicate ACKs, it assumes something went wrongThe packet is immediately retransmitted instead of waiting for it to timeout
26 Figure 6.12 Fast Retransmit TCP Fast RetransmitFast RetransmitBased on threeduplicate ACKsFigure 6.12 Fast Retransmit
27 TCP Fast Retransmit Example SenderReceiverMSS = 1KACK of new dataACK = 2048 WIN = 31K1KSEQ=20481KSEQ=3072Duplicate ACK #1ACK = 2048 WIN = 30K1KSEQ=4096Duplicate ACK #21KSEQ=5120ACK = 2048 WIN = 29KFast Retransmitoccurs (2nd packet is nowretransmitted w/o waitingfor it to timeout)Duplicate ACK #3ACK = 2048 WIN = 28K1KSEQ=61441KSEQ=2048ACK = 2048 WIN = 27KACK = 7168 WIN = 26K
28 BufferingKeep in mind that TCP is (usually) part of the Operating System. It takes care of all these details asynchronously.The TCP layer doesn’t know when the application will ask for any received data.TCP buffers incoming data so it’s ready when we ask for it.
29 TCP BuffersBoth the client and server allocate buffers to hold incoming and outgoing dataThe TCP layer takes care of this.Both the client and server announce with every ACK how much buffer space remains (the Window field in a TCP segment).
30 Send Buffers The application gives the TCP layer some data to send. The data is put in a send buffer, where it stays until the data is ACK’d.it has to stay, as it might need to be sent again!The TCP layer won’t accept data from the application unless (or until) there is buffer space.
31 ACKsA receiver doesn’t have to ACK every segment (it can ACK many segments with a single ACK segment).Each ACK can also contain outgoing data (piggybacking).If a sender doesn’t get an ACK after some time limit it resends the data.
32 TCP Segment OrderMost TCP implementations will accept out-of-order segments (if there is room in the buffer).Once the missing segments arrive, a single ACK can be sent for the whole thing.Remember: IP delivers TCP segments, and IP is not reliable - IP datagrams can be lost or arrive out of order.
33 TerminationThe TCP layer can send a RST segment that terminates a connection if something is wrong.Usually the application tells TCP to terminate the connection politely with a FIN segment.
34 FIN Either end of the connection can initiate termination. A FIN is sent, which means the application is done sending data.The FIN is ACK’d.The other end must now send a FIN.That FIN must be ACK’d.
36 TCP Termination 1 App1: “I have no more data for you”. App2: “OK, I understand you are done sending.”dramatic pause…App2: “OK - Now I’m also done sending data”.App1: “Goodbye, It’s been real pleasure talking to you ”234
37 TCP TIME_WAITOnce a TCP connection has been terminated (the last ACK sent) there is some unfinished business:What if the ACK is lost? The last FIN will be resent and it must be ACK’d.What if there are lost or duplicated segments that finally reach the destination after a long delay?TCP hangs out for a while to handle these situations.
38 Test Questions Why is a 3-way handshake necessary? Who sends the first FIN - the server or the client?Once the connection is established, what is the difference between the operation of the server’s TCP layer and the client’s TCP layer?
39 TCP Features Connection-oriented Byte-stream app writes bytes TCP sends segmentsapp reads bytesReliable data transferFlow control: keep sender from overrunning receiverCongestion control: keep sender from overrunning networkApplication processWritebytesTCPSend bufferSegmentTransmit segmentsReadReceive buffer…
41 TCP Segment Fields Source & Destination Ports Sequence number 16 bit port identifiers for each packet (65536 ports)Sequence numberThe packet’s unique sequence IDInitial number selected at connection timeAcknowledgement numberThe sequence number of the next packet expected by the receiver
42 TCP Segment Fields (cont’d) Window size (flow control)Specifies how many bytes may be sent after the first acknowledged byteChecksumChecksums the TCP header and IP address fieldsUrgent PointerPoints to urgent data in the TCP data fieldSenderData(SequenceNum)Acknowledgment +AdvertisedWindowReceiver
43 TCP Segment Fields (cont’d) Header bitsURG = Urgent pointer field in useACK = Indicates whether frame contains acknowledgementPSH = Data has been “pushed”. It should be delivered to higher layers right away.RST = Indicates that the connection should be resetSYN = Used to establish connectionsFIN = Used to release a connection
44 TCP Congestion WindowTCP introduces a second window, called the “congestion window”To determine how many bytes it may send, the sender takes the minimum of the receiver window and the congestion windowExample:If the receiver window says the sender can transmit 8K, but the congestion window is only 4K, then the sender may only transmit 4KIf the congestion window is 8K but the receiver window says the sender can transmit 4K, then the sender may only transmit 4K
46 Internet LayerBest path determination and packet switching3/28/2017
47 Internet Layer TCP UDP IP 802.3 Process Process Application Layer Transport LayerICMP, ARP&RARPIPInternet Layer802.3Data-Link Layer
48 IP Datagram The Internet layer defines A packet format Addressing schemeAnd IP (Internet protocol)Ensures that any computer on the Internet has a unique IPThe Internet layer adds an IP Header to a packet.A packet with an IP header is called:IP datagramHeaderSource IP addressDestination IP addressPayload size (actual data sent without header)And some other stuff…
49 Forwarding a DatagramBecause datagrams are a connectionless communication, they are forwarded from node to node.At each step, the router (node) inspects the destination address of the datagram and forwards it to the appropriate interface.
52 Network AddressFrom our subnetting discussion, we’ve already seen how the network address can be determined from the IP address and the netmask.& ==With the network address, the router can determine the correct next hop.
53 Best-Effort DeliveryAlthough IP makes the best-effort of datagram delivery, it does not guarantee proper handling of:Datagram duplicationDelayed or out-of-order deliveryCorruption of dataDatagram lossOther protocol layers are responsible for error handling.
55 IP Datagram Header (cont.) Vers:version of IP (4 bits)Only 2 permitted0100 for IPv4 and0110 for IPv6H. LEN:Header Length (4 bits)length of the header in 32 bit words.Service Type:Information about how data transmission is prioritised
56 IP Datagram Header(cont.) Total Length (16 bits):Total length of the datagram, measured in octets, including header and data.Identification (16 bits):A value assigned to aid in assembly of fragments.Identification, Flags and fragment offset:These values allow datagrams to be fragmented and reassembled ant the destination.Time to Live (8 bits):Maximum time the datagram is allowed to exist in the system. Each router that handles the datagram decrements the TTL by 1.If the value is reaches 0 the datagram is discarded and an ICMP message is sent to the source host.
57 IP Datagram Header (cont.) Type:Protocol (8 bits): Indicates which Transport Layer protocol the datagram is passed to.UDP or TCPHeader Checksum (16 bits):Checksum is used to verifyIt is recomputed at each router hop.Source address (32 bits)Destination address (32 bits)
58 More about IP RoutingRouting - the process of choosing a path over which to send packetsRouter - a computer that performs routingRouting is one of the Internet Protocol’s primary functions
59 IP Routing (cont’d)Criteria that could (ideally) be used to make routing decisions:Network characteristicsNetwork topologyNetwork loadDatagram lengthType of service requested in the datagram’s headerIP routing software:Normally does not consider most of these factorsMakes decisions based on fixed assumptions about shortest paths
60 Hosts vs. Routers Hosts make routing decisions Hosts don’t typically transfer packets from one network to anotherRouters make routing decisionsRouters typically transfer packets from one network to another
61 Direct vs. Indirect Delivery Direct delivery - transmit datagram across a single physical network to the destinationIndirect delivery - transmit datagram across multiple physical networks (with the aid of routers) to the destinationHow does a machine know which method of delivery to use?
62 Direct Delivery Map the destination IP address to a physical address Encapsulate the datagram in a physical frameSend the frame over the physical network to the destination
63 Indirect Delivery Encapsulate the datagram in a frame Choose a router on the physical networkSend the frame to that routerRouter forwards the datagram on towards its final destinationHow does the host choose a router?How does the router forward the datagram?
64 The IP Routing TableRouting table - each machine stores information about destination networks and how to reach themUsing only netid portion of the IP address keeps routing tables:SmallRelatively stable
66 Next-Hop Routing (cont) Routing table at machine M contains pairs (N,R)N is the IP address of a destination networkR is the IP address of the “next” router (R and M must share a physical network)Routing table size:Depends on the number of networks in the internetOnly grows when new networks are added
67 Properties of Next-Hop Routes All traffic destined for a given network takes the same pathOnly the final router can determine whether a host exists or is operationalRoutes are not necessarily symmetric
68 The Internet Control Message Protocol Abnormal normal communication among routers and hosts is sometimes necessary to:Report errorsHandle abnormal conditionsUpdate routing informationICMP
69 ICMP is for Error Reporting Errors are reported to a datagram’s original senderIt is the sender’s responsibility to take appropriate action
70 ICMP Message FormatAll ICMP messages begin with the same three fields:TYPE (1 octet) - identifies the messageCODE (1 octet) - information about the subtypeCHECKSUM (2 octets) - covers the ICMP messageICMP error messages always include the header and first 64 data bits of the datagram causing the problem
71 Mapping IP Addresses to Hardware Addresses (MAC) IP Addresses are not recognized by hardware.If we know the IP address of a host, how do we find out the hardware address ?The process of finding the hardware address of a host given the IP address is calledAddress Resolution
72 ARPThe Address Resolution Protocol is used by a sending host when it knows the IP address of the destination but needs the Ethernet (or whatever) address.ARP is a broadcast protocol - every host on the network receives the request.Each host checks the request against it’s IP address - the right one responds.
73 ARP (cont.)ARP does not need to be done every time an IP datagram is sent - hosts remember the hardware addresses of each other.Part of the ARP protocol specifies that the receiving host should also remember the IP and hardware addresses of the sending host.
74 ARP conversation not me HEY - Everyone please listen! Will please send me his/her Ethernet address?not meHi Red! I’m , and my Ethernet address is 87:A2:15:35:02:C3
75 Address Resolution Protocol (ARP) Each device on a network maintains its own ARP table.A device that requires an IP and MAC address pair broadcasts an ARP request.If one of the local devices matches the IP address of the request, it sends back an ARP reply that contains its IP-MAC pair.If the request is for a different IP network, a router performs a proxy ARP.The router sends an ARP response with the MAC address of the interface on which the request was received, to the requesting host.
76 Reverse Address Resolution Protocol RARP The process of finding out the IP address of a host given a hardware address is calledReverse Address ResolutionReverse address resolution is needed by diskless workstations when booting (which used to be quite common).
77 RARP conversation not me HEY - Everyone please listen! My Ethernet address is 22:BC:66:17:01:75.Does anyone know my IP address ?not meHi Red! Your IP address is
78 SUMMARY Transport layer Internet layer UDP TCP IP ConnectionlessUnreliable transmissionLess overheatTCPCONNECTION ORIENTEDReliable TransmissionMore overheat to deal with ack’sInternet layerIPConnectonlessIP routing (next-hop using routing table)UnreliableICMP (information control message protocol)ARP (IP to MAC)RARP (MAC TO IP)