Lecture 4: Outline Literature: Lecture 4: Transport Layer Forouzan: ch 11-12 RFC? Transport layer introduction UDP TCP 2004 Image Coding Group, Linköpings Universitet 2 The Transport Layer Transport layer protocols The transport layer is responsible for end to end delivery of messages This is achieved through Service point addressing Segmentation and reassembly Connection control Flow control Error control There are two transport layer protocols in the TCP/IP stack: UDP- UserDatagramProtocol Connectionless unreliable service TCP - Transmission Control Protocol Connection- oriented reliable stream service TCP UDP IGMP ICMP IP ARP RARP 3 Underlying networks 4
Protocol Ports Port numbers are used as a process identifier They are needed since computers can run multiple programs at the same time IP addresses identify computers Port numbers identify processes An (IP address, port number) pair is called a socket Messages must define source and destination sockets Port Numbers The IANA has divided the port numbers into three ranges: Well known ports (0-1023) Assigned and controlled by IANA Registered ports (1024-49151) Ports in this range can be registered with IANA to prevent duplication Dynamic ports (49152-65535) The ephemeral ports can be used by any process 5 6 Some Well Known Ports Port number Application 20 FTP 23 Telnet 25 SNMP 80 HTTP User Datagram Protocol UDP is a connectionless, unreliable transport protocol UDP provides process to process communication limited error checking UDP does not provide acknowledgement for recieved packets segmentation and reassembly flow control 7 8
User Datagram Protocol Why use UDP? User Datagram Protocol UDP is suitable for processes that provide internal flow and error control mechanisms, eg TFTP multicasting and broadcasting management processes, eg SNMP somerouteupdatingprotocols,egrip processes that only send short messages 9 10 User Datagram UDP packets (datagrams): 8byteheader max 65507 bytes of data 16 bits 16 bits Source port address UDP total length Data Destination port address UDP Checksum UDP Checksum The UDP checksum includes pseudoheader UDP header data from the application layer pad byte (if needed) Source IP address Destination IP address All 0s Protocol (17) Header checksum Source port Destination port address address UDP total length Data UDP Checksum 11 12
UDP Operation Messages are encapsulated in UDP datagrams Usually each port is associated with one or two queues UDP handles multiplexing and demultiplexing of messages Transmission Control Protocol TCP is a connection- oriented transport protocol TCP provides full duplex connections reliable stream service flow control error control 13 14 Buffers Sending and receiving buffers are used for storage This makes it possible to handle differences in speed between the sending and receiving processes Buffers are also used in flow and error control mechanisms Reliable Service TCP provides reliable service by breaking application data into suitable sized blocks called segments using an acknowledgement mechanism retransmission when errors occur providing flow control checksum control of header and data 15 16
TCP Segment hlen 6bitsreserved Source port address TCP Checksum Sequence Number flags Options (if any) Acknowledgement Number Data (if any) Window Size Urgent Pointer Destination port address TCP Flags 6 flags can be used to determine the purpose of the segment (more than one can be set) URG - urgent pointer valid (set when sender wants the receiver to read a piece of data urgently and possibly out of order) ACK - acknowledgement number valid PSH - push data, receiver should immediately pass the data to the application (buffers should be emtied!) RST - reset the connection SYN - synchronize sequence numbers to initiate connection FIN - terminate the connection 17 18 TCP Handshake Connection Termination A three- way handshake is used to establish a connection 4 segments needed to close a connection Client Server Client Server Negotiation on initial sequence numbers FIN Initial segment number (ISN) chosen so that each active connection has its own ISN Normally initiation is made by the client SYN, seq=x ACK, seq=x+1, SYN, seq=y ACK of FIN FIN ACK, seq=y+1 ACK of FIN 19 20
Maximum Segment Size TCP Options MSS is the largest block of data TCP will send to the other side MSS can be announced in the options field during connection establishment Default MSS is 536 The larger the better (until fragmentation occurs) Up to 40 bytes of optional informationcan be included in the TCP header Used to convey additional information or to align other options Options Single- byte End of option No operation Maximum segment size Multiple- byte Window scale factor 21 Timestamp 22 Flow Control Congestion Control How much can a source send without receiving an ACK? The sliding window protocol is used in TCP Handles bottlenecks in the network Without congestion control the network will collaps! offered window usable window Silly window syndrome Solution: Congestion window (CWND) slow start Sender initiated silly window solved by Nagle's algorithm Receiver initiated silly window solved by delayed ACKs 23 Additive increase of CWND Multiplicative decrease of CWND Fast retransmit and Fast recovery 24
TCP Timers Summary Retransmission timer Transport layer basics how long should sender wait for an ACK? Persistence timer how long should sender wait if window size = 0? Keepalive timer UDP - a fairly simple connectionless protocol TCP - a very complex protocol Reliability Connection management Prevents connections to live forever Flow control Time- Waited timer Congestion avoidance Each connection held in limbo before actually closed Timers 25 26