Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Transport Layer Flow control Connection management TCP, UDP.

Similar presentations


Presentation on theme: "1 Transport Layer Flow control Connection management TCP, UDP."— Presentation transcript:

1 1 Transport Layer Flow control Connection management TCP, UDP

2 Copyright Jorg Liebeherr 98, Modified with permission, Abdelzaher 2 Announcements I hope you had a very happy Thanksgiving break! My sincere apologies for the Monday emergency cancellation!! SM5 is out. Due in one week.

3 Copyright Jorg Liebeherr 98, Modified with permission, Abdelzaher 3 Introduction Transport layer protocols are end-to-end protocols Transport layer is only implemented at the hosts

4 Copyright Jorg Liebeherr 98, Modified with permission, Abdelzaher 4 Functions of the Transport Layer Reliability Connection Establishment Connection Termination Flow control Congestion control

5 Copyright Jorg Liebeherr 98, Modified with permission, Abdelzaher 5 Reliability How to achieve it?

6 Copyright Jorg Liebeherr 98, Modified with permission, Abdelzaher 6 Reliability How to achieve it? Send data in chunks (called packets) Number the packets sequentially at the sender Make sure all numbers are received without gaps

7 Copyright Jorg Liebeherr 98, Modified with permission, Abdelzaher 7 Reliability How to achieve it? Send data in chunks (called packets) Number the packets sequentially at the sender Make sure all numbers are received without gaps Acknowledge each packet number If sender sees an ack gap  sender retransmits

8 Copyright Jorg Liebeherr 98, Modified with permission, Abdelzaher 8 Reliability How to achieve it? Send data in chunks (called packets) Number the packets sequentially at the sender Make sure all numbers are received without gaps Acknowledge each packet number If sender sees an ack gap  sender retransmits Optimization: Cumulative acks (ACK N: acknowledge that all packets up to but not including packet N have been received).

9 Copyright Jorg Liebeherr 98, Modified with permission, Abdelzaher 9 Reliability How to achieve it? Send data in chunks (called packets) Number the packets sequentially at the sender Make sure all numbers are received without gaps Acknowledge each packet number If sender sees an ack gap  sender retransmits Optimization: Cumulative acks (ACK N: acknowledge that all packets up to but not including packet N have been received). What about the number of the first packet?

10 Copyright Jorg Liebeherr 98, Modified with permission, Abdelzaher 10 Connection Establishment Connection establishment is asymmetric: one side puts itself in a LISTEN state (server) one side issues a request for connection (client)

11 Copyright Jorg Liebeherr 98, Modified with permission, Abdelzaher 11 Simple Solution (which has problems) CR (SeqNo = x) Connection Request, A wants to start with SeqNo = x ACK (SeqNo = y) Acknowledge request, B will wants to start with SeqNo = y DATA (SeqNo = x) Data transmission with SeqNo x Two Way Handshake

12 Copyright Jorg Liebeherr 98, Modified with permission, Abdelzaher 12 Problems with Two-Way Handshake B responds to CR(SeqNo = z), an old duplicate connection requests from A In the shown sce- nario, A believes that the ACK is for the connection request CR(SeqNo = y) Result: A starts to send data with Sequence x. B will throw the data away since it expects SeqNo = z

13 Copyright Jorg Liebeherr 98, Modified with permission, Abdelzaher 13 Three-Way Handshake Note: A and B acknowledge the sequence number from the other side This solution provides protection from old duplicate connection requests

14 Copyright Jorg Liebeherr 98, Modified with permission, Abdelzaher 14 Scenario 1 Host A rejects the invalid connection request in the REJ(ACK=y) packet Note: The connection request CR(SeqNo=x) is completed successfully Duplicate connection request (CR) appears

15 Copyright Jorg Liebeherr 98, Modified with permission, Abdelzaher 15 Scenario 2 Host A rejects the invalid ACK by sending REJ(ACK=y) Note: The connection request CR(SeqNo=x) is completed successfully A duplicate acknowledgement (ACK) appears

16 Copyright Jorg Liebeherr 98, Modified with permission, Abdelzaher 16 Connection Termination A connection release should involve both sides of the connection (otherwise data is lost) Here: B should wait after Disconnection Request (DR) is sent until all data has arrived

17 Copyright Jorg Liebeherr 98, Modified with permission, Abdelzaher 17 Connection Termination in 4 steps An elegant way to terminate connections is to have each end shut down independently (“half- close”) If one end wants to shut down, it sends a DR message Four steps involved: (1) A sends a DR to B (active close) (2) B ACKs the DR, (at this time: B can still send data to A) (3) and B sends a DR to A (passive close) (4) A ACKs the DR

18 Copyright Jorg Liebeherr 98, Modified with permission, Abdelzaher 18 Connection Termination in 4 steps To account for packet losses, a timer is needed to limit the waiting time of a side

19 Copyright Jorg Liebeherr 98, Modified with permission, Abdelzaher 19 TCP Segment Format TCP segments have a 20 byte header with >= 0 bytes of data.

20 Copyright Jorg Liebeherr 98, Modified with permission, Abdelzaher 20 Flow Control Notion of window-based flow control: Have a window of packets ready for transmission Can send only those packets that are in the window up to the end of the window Every time an acknowledgement is received, window slides (and its size may be increased).

21 Copyright Jorg Liebeherr 98, Modified with permission, Abdelzaher 21 Flow Control Flow Control is a technique for speed-matching of transmitter and receiver. Flow control ensures that a transmitting station does not overflow a receiving station with data We will discuss two protocols for flow control: Stop-and-Wait On-Off Sliding Window For the time being, we assume that we have a perfect channel (no errors)

22 Copyright Jorg Liebeherr 98, Modified with permission, Abdelzaher 22 Stop-and-Wait Flow Control Simplest form of flow control In Stop-and-Wait flow control, the receiver indicates its readiness to receive data for each frame Operations: 1. Sender: Transmit a single frame 2. Receiver: Transmit acknowledgment (ACK) 3. Goto 1.

23 Copyright Jorg Liebeherr 98, Modified with permission, Abdelzaher 23 Analysis of Stop-and-Wait Efficiency = ?

24 Copyright Jorg Liebeherr 98, Modified with permission, Abdelzaher 24 Sliding Window Flow Control Allows transmission of multiple frames Assigns each frame a k-bit sequence number Range of sequence number is [0..2 k -1], i.e., frames are counted modulo 2 k

25 Copyright Jorg Liebeherr 98, Modified with permission, Abdelzaher 25 Operation of Sliding Window Sending Window: At any instant, the sender is permitted to send frames with sequence numbers in a certain range (the sending window)

26 Copyright Jorg Liebeherr 98, Modified with permission, Abdelzaher 26 Operation of Sliding Window Receiving Window: The receiver maintains a receiving window corresponding to the sequence numbers of frames that are accepted

27 Copyright Jorg Liebeherr 98, Modified with permission, Abdelzaher 27 Operation of Sliding Window How is “flow control” achieved? Receiver can control the size of the sending window By limiting the size of the sending window data flow from sender to receiver can be limited Interpretation of ACK N message: Receiver acknowledges all packets until (but not including) sequence number N

28 Copyright Jorg Liebeherr 98, Modified with permission, Abdelzaher 28 Example 3

29 Copyright Jorg Liebeherr 98, Modified with permission, Abdelzaher 29 Example Continued 4 4

30 Copyright Jorg Liebeherr 98, Modified with permission, Abdelzaher 30 Slow Start Whenever starting traffic on a new connection, or whenever increasing traffic after congestion was experienced: Set cwnd = MSS bytes (=1 segment) Each time an ACK is received, slide the congestion window and increase size by 1 segment (= MSS bytes). Does Slow Start increment slowly? Not really. In fact, the increase of cwnd can be exponential

31 Copyright Jorg Liebeherr 98, Modified with permission, Abdelzaher 31 Slow Start Example The congestion window size grows very rapidly For every ACK, we increase cwnd by 1 irrespective of the number of segments ACK’ed TCP slows down the increase of cwnd when cwnd > ssthresh

32 Copyright Jorg Liebeherr 98, Modified with permission, Abdelzaher 32 Slow Start “Slow Start” slows down if the congestion window is larger than a threshold value If cwnd > ssthresh then each time an ACK is received, increment cwnd as follows: cwnd = cwnd + MSS * MSS / cwnd So cwnd is increased by one only if all segments have been acknowledged. ssthresh is modified if there is congestion in the network

33 Copyright Jorg Liebeherr 98, Modified with permission, Abdelzaher 33 Slow Start Example Assume that ssthresh = 8 Roundtrip times Cwnd (in segments) ssthresh

34 Copyright Jorg Liebeherr 98, Modified with permission, Abdelzaher 34 Slow Start / Congestion Avoidance Here we give a more accurate version than in our earlier discussion of Slow Start: If cwnd <= ssthresh then Each time an Ack is received: cwnd = cwnd + MSS else /* cwnd > ssthresh */ Each time an Ack is received : cwnd = cwnd + MSS * MSS / cwnd endif

35 Copyright Jorg Liebeherr 98, Modified with permission, Abdelzaher 35 Slow Start / Congestion Avoidance Each time when congestion occurs (timeout or receipt of duplicate ACK), cwnd is reset to one: cwnd = 1 ssthresh is set to half the current size of the congestion window: ssthressh = cwnd / 2

36 Copyright Jorg Liebeherr 98, Modified with permission, Abdelzaher 36 Slow Start / Congestion Avoidance A typical plot of cwnd for a TCP connection (MSS = 1500 bytes) :

37 Copyright Jorg Liebeherr 98, Modified with permission, Abdelzaher 37 Round-Trip Time Measurements The retransmission mechanism of TCP is adaptive The retransmission timers are set based on round- trip time (RTT) measurements that TCP performs The RTT is based on time difference between segment transmission and receipt of ACK But: TCP does not ACK each segment Each connection has only one timer

38 Copyright Jorg Liebeherr 98, Modified with permission, Abdelzaher 38 Round-Trip Time Measurements Retransmission timer is set to a Retransmission Timeout (RTO) value RTO is calculated based on the RTT measurements The RTT measurements are smoothed by the following estimators srtt and rttvar: srtt n+1 =  RTT + (1-  ) srtt n rttvar n+1 =  ( | RTT - srtt n+1 | ) + (1-  ) rttvar n RTO n+1 = srtt n rttvar n+1 The gains are set to  =1/4 and  =1/8 srtt 0 = 0 sec, rttvar 0 = 3 sec, Also: RTO 0 = srtt rttvar 0

39 Copyright Jorg Liebeherr 98, Modified with permission, Abdelzaher 39 TCP header fields Port Number: A port number identifies the endpoint of a connection. A pair identifies one endpoint of a connection. Two pairs and identify a TCP connection.

40 Copyright Jorg Liebeherr 98, Modified with permission, Abdelzaher 40 TCP header fields Sequence Number (SeqNo): Sequence number is 32 bits long. So the range of SeqNo is 0 <= SeqNo <=  4.3 Gbyte Each sequence number identifies a byte in the byte stream Initial Sequence Number (ISN) of a connection is set during connection establishment

41 Copyright Jorg Liebeherr 98, Modified with permission, Abdelzaher 41 TCP header fields Acknowledgement Number (AckNo): Acknowledgements are piggybacked A hosts uses the AckNo field to send acknowledgements. (If a host sends an AckNo in a segment it sets the “ACK flag”) The AckNo contains the next SeqNo that a hosts wants to receive Example: The acknowledgement for a segment with sequence numbers is AckNo=1501

42 Copyright Jorg Liebeherr 98, Modified with permission, Abdelzaher 42 TCP header fields Flag bits: URG: Urgent pointer is valid If the bit is set, the following bytes contain an urgent message in the sequence number range “SeqNo <= urgent message <= SeqNo+urgent pointer” ACK: Segment carries a valid acknowledgement PSH: PUSH Flag Notification from sender to the receiver that the receiver should pass all data that it has to the application. Normally set by sender when the sender’s buffer is empty

43 Copyright Jorg Liebeherr 98, Modified with permission, Abdelzaher 43 TCP header fields Flag bits: RST: Reset the connection The flag causes the receiver to reset the connection Receiver of a RST terminates the connection and indicates higher layer application about the reset SYN: Synchronize sequence numbers Sent in the first packet when initiating a connection FIN: Sender is finished with sending Used for closing a connection Both sides of a connection must send a FIN

44 Copyright Jorg Liebeherr 98, Modified with permission, Abdelzaher 44 TCP States in Connection Lifetime


Download ppt "1 Transport Layer Flow control Connection management TCP, UDP."

Similar presentations


Ads by Google