Presentation is loading. Please wait.

Presentation is loading. Please wait.

TELE202 Lecture 14 TCP/UDP (2) 1 Lecturer Dr Z. Huang Overview ¥Last Lecture »TCP/UDP (1) »Source: chapter 17 ¥This Lecture »TCP/UDP (2) »Source: chapter.

Similar presentations

Presentation on theme: "TELE202 Lecture 14 TCP/UDP (2) 1 Lecturer Dr Z. Huang Overview ¥Last Lecture »TCP/UDP (1) »Source: chapter 17 ¥This Lecture »TCP/UDP (2) »Source: chapter."— Presentation transcript:

1 TELE202 Lecture 14 TCP/UDP (2) 1 Lecturer Dr Z. Huang Overview ¥Last Lecture »TCP/UDP (1) »Source: chapter 17 ¥This Lecture »TCP/UDP (2) »Source: chapter 17 ¥Next Lecture »Socket programming »Source: chapter 17

2 TELE202 Lecture 14 TCP/UDP (2) 2 Lecturer Dr Z. Huang Flow Control ¥Transport protocols resemble the data link protocols »Flow control, error control, sequencing »A sliding window is used for flow control ¥Differences »A router usually has only a few links to others, while a transport entity may have numerous connections »This difference makes it impractical to implement data link buffering strategy in the transport layer »The receiver may not dedicate specific buffers to specific connections ¥Dynamic buffer management: credit mechanism »Initially, the sender requests a certain number of buffers (credit), based on its perceived needs »The receiver then grants as many of these as it can afford »Every time the sender transmits a TPDU, it must decrease its allocation (credit), stopping altogether when the allocation (credit) reaches zero »The receiver then separately piggybacks both acknowledgments and buffer allocations (credit) onto reverse traffic

3 TELE202 Lecture 14 TCP/UDP (2) 3 Lecturer Dr Z. Huang Flow Control ¥Example: credit mechanism »We assume that when connection is established, entities A and B have initial sequence numbers 100 and 700 respectively, and each entity agree to buffer up to 200 bytes »Entities send 100 bytes in each TPDU »Entity A starts by sending two TPDUs and then wait for more credit because it has used up its credit »At time t2, B removes the first received TPDU from the buffer and also find 100 more bytes of buffer space; so B now has 200 bytes space available and tell A in the credit field of a TPDU »After A receives the 200 bytes credit, it can send two TPDUs again

4 TELE202 Lecture 14 TCP/UDP (2) 4 Lecturer Dr Z. Huang Error detection ¥Why is there error detection in the transport layer? »Reliable transmission along each link is still no guarantee of error-free transmission between the source and the destination ¥Example »Consider the router in the following figure »Suppose the router receives the IP packet intact, but an error that affects the packet’s contents occurs during reformatting of the frame containing the packet. »Since the checksum is calculated after the new frame is created it includes the erroneous data »It is not a transmission error. Instead, it is an error in the processing of packets »A transport-layer error detection mechanism would detect this error

5 TELE202 Lecture 14 TCP/UDP (2) 5 Lecturer Dr Z. Huang Transmission Control Protocol ¥TCP is a transport layer protocol »Provide a reliable end-to-end byte stream over an unreliable internetwork such as IP »Provide connection oriented user-to-user service: connection management ¥TCP connection »TCP connections are full duplex and point-to- point »A TCP connection is a byte stream, not a message stream »TCP does not support multicasting or broadcasting

6 TELE202 Lecture 14 TCP/UDP (2) 6 Lecturer Dr Z. Huang TCP ¥TCP operation »Each machine supporting TCP has a TCP entity, either a user process or part of the OS kernel that manages TCP streams and interfaces to the IP layer »A TCP entity accepts user data streams from local processes, breaks them up into pieces not exceeding 64K bytes, puts each of them into a TCP segment which is put into the payload of an IP packet, which is then transmitted by IP network protocol »When IP packets containing TCP segment arrive at a machine, they are given to the TCP entity, which reconstructs the original byte stream

7 TELE202 Lecture 14 TCP/UDP (2) 7 Lecturer Dr Z. Huang TCP ¥TCP/UDP service is obtained by having both the sender and receiver create end points, called sockets ¥Each socket is associated with »the IP address of the host »16-bit number local to the host, called port ¥Port number allocation »0 - not used »1-255, reserved ports for well known services »256-1023, other reserved ports »1024-65535, user-defined server ports »Check generally used ports in /etc/services in UNIX environment ¥Well-known ports »FTP - 21, Telnet - 23, SMTP (email) - 25, HTTP - 80, POP - 110, DNS - 53, BOOTP - 67

8 TELE202 Lecture 14 TCP/UDP (2) 8 Lecturer Dr Z. Huang TCP ¥Flow and error control »The basic protocol used by TCP entities is the sliding window protocol, which deals with the following issues »Error and flow control: timeout, retransmission, and acknowledgment »Byte stream order preservation »Congestion control: dynamic adjustment of window size according to delay of acknowledgment ¥TCP packets are called segments »A segment consists of a fixed 20-byte header (plus an optional part) followed by zero or more data bytes »Size of the segment is restricted by –65,536 (64K) bytes of the IP payload –MTU of the network

9 TELE202 Lecture 14 TCP/UDP (2) 9 Lecturer Dr Z. Huang TCP Segment ¥Destination port (16 bits) »Identifies the application to which the segment is sent. ¥Source port (16 bits) »Specifies the application sending the segment. ¥Sequence number (32 bits) »Contains the sequence number of the first byte of data. TCP numbers bytes not frames. ¥Acknowledgment number (32 bits) »Contains the byte sequence number the receiving TCP entity expects to receive next. ¥Header length (4 bits) »Specifies the size of the TCP header ¥Flags (6 bits): determine the purpose and content of the segment »Each bit from left to right represents the following meaning if it is set to 1 –URG: Urgent pointer field is valid –ACK: Ack field is valid –PSH: segment requests a push (segment should be sent to user immediately) –RST: Reset the connection –SYN: synchronise to set up a connection –FIN: indicate the last segment

10 TELE202 Lecture 14 TCP/UDP (2) 10 Lecturer Dr Z. Huang TCP Segment ¥Window (16 bits) »Tells the receiving TCP entity how many data bytes the sending TCP entity can accept in return ¥Checksum (16 bits) »used for transport layer error detection ¥Urgent pointer (16 bits) »Signal the receiver to deliver the data to the higher layer as quickly as possible ¥Options/padding: maximum segment size ¥Sliding window buffer »When ack sequence number and window size are received from the receiver, the sender has to adjust its window start pointer and window size.

11 TELE202 Lecture 14 TCP/UDP (2) 11 Lecturer Dr Z. Huang TCP in action ¥Before data is transferred, a connection must be opened »A server does passive open (listen) »A client does active open (connect) ¥TCP has three phases »Connection setup »Data transmission »Connection close ¥Connection establishment »Uses three-way handshake protocol »Ensures both ends are ready and starting sequence numbers are exchanged

12 TELE202 Lecture 14 TCP/UDP (2) 12 Lecturer Dr Z. Huang TCP in action ¥Data transmission »Use a simple example of Telnet, in which host B echoes back each received character ¥Connection close »Uses three-way handshake protocol

13 TELE202 Lecture 14 TCP/UDP (2) 13 Lecturer Dr Z. Huang TCP timers ¥Retransmission timer »Used to retransmit data if no ack is received within a period ¥Persist timer »Keeps window size info flowing »A window size info may get lost »A timer is set (500ms) at one end to ask for a new window update from the other end ¥Keep alive timer »Detect idle connection due to crash or reboot »Periodically send TCP segment to confirm the connection »If no ack after a number of retries, the connection is reset. ¥2MSL:2 Maximum Segment Lifetime »Maximum Segment Lifetime is the maximum time an old segment can remain alive in an Internet »This timer is used to keep a connection alive for a period to avoid problems incurred with unreliable delivery ¥Delayed ack timer »Ack is not sent immediately after receiving data »Most implementations use a 200ms delay

14 TELE202 Lecture 14 TCP/UDP (2) 14 Lecturer Dr Z. Huang Congestion control ¥Congestion due to »Faster LAN to slower WAN »Multiple input to a router with limited capacity ¥Dropping packets may cause worse situation ¥Congestion can be indicated by the number of lost packets »Lost packets may be caused by damage or congestion »However, the percentage of lost packets caused by damage is very small (<1%) ¥Solution: Jacobson’s algorithm »Slow start –Set the initial window size as one segment –Double the window size each time an ack is received within a time period until it reaches the window size limit –If an ack is delayed, perform congestion avoidance algorithm »Congestion avoidance –Each time an ack is delayed or data get lost, the window size is reduced to half

15 TELE202 Lecture 14 TCP/UDP (2) 15 Lecturer Dr Z. Huang UDP ¥User Datagram Protocol »Connectionless transport service »Much less complex, but unreliable »Simple interface between IP and higher layer protocols »Allows applications to send encapsulated datagrams without having to establish a connection »Useful in many client/server applications that have one request and one response ¥UDP header »source port: 16 bits »destination port: 16 bits »UDP length: 16 bits »UDP checksum: 16 bits

16 TELE202 Lecture 14 TCP/UDP (2) 16 Lecturer Dr Z. Huang Summary ¥Flow control in transport layer ¥Error control in transport layer ¥Transmission Control Protocol(TCP) »TCP connection »TCP operation »Socket »Port number »Flow&error control »Congestion control »Format of TCP segments »TCP timers ¥User Datagram Protocol »Format of UDP datagram »Connectionless service »Error detection

Download ppt "TELE202 Lecture 14 TCP/UDP (2) 1 Lecturer Dr Z. Huang Overview ¥Last Lecture »TCP/UDP (1) »Source: chapter 17 ¥This Lecture »TCP/UDP (2) »Source: chapter."

Similar presentations

Ads by Google