CSE 124 Networked Services Fall 2009 B. S. Manoj, Ph.D 10/20/20091CSE 124 Networked Services Fall 2009 Some of these slides are adapted from various sources/individuals including but not limited to the slides from the text books by Kurose and Ross, Peterson and Davie, digital libraries such as IEEE/ACM digital libraries and slides from Prof. Vahdat. Use of these slides other than for pedagogical purpose for CSE 124, may require explicit permissions from the respective sources.
Announcements Programming Assignment 1 – Submission window th October Week-3 Homework – Due on 26 th October First Paper Discussion – Discussion on 29 th October – Write-up due on: 28 th October Midterm: November 5 10/20/20092CSE 124 Networked Services Fall 2009
End-to-end Transport Layer Protocols End-to-end issues are important – Link-level (hop-level) benefit may not translate to end-to-end benefit Main objectives of end-to-end transport protocols – Quality of Service Reliability In order delivery Flow control – Fairness Flow fairness Network congestion – Handle the end-to-end network dynamics Round-trip-time Bandwidth We focus on Transmission Control Protocol (TCP) 10/20/2009CSE 124 Networked Services Fall 20093
TCP Main features of TCP – Connection oriented Connection setup, data transfer, and connection tear-down – Reliability – In-order delivery – Byte-stream oriented – Flow control Prevents senders from flooding the receiver Transmit at a rate acceptable to the receiver – Error control Retransmission – Congestion control Prevents senders from creating congestion in the network Manage transmission at a rate acceptable to the network 10/20/2009CSE 124 Networked Services Fall 20094
Multiplexing/Addressing Higher layer (Application/session layer services/applications) Transport layer (Port Number) Network layer (IP address) S1S1 S2S2 SnSn … C1C1 C2C2 CnCn … Network Connection: 10/20/20095CSE 124 Networked Services Fall 2009
How do we optimize the transmission rate Transmission rate optimization to achieve network capacity Bandwidth delay product is the suitable metric for flow capacity 10/20/2009CSE 124 Networked Services Fall Delay Bandwidth
Stop-and-wait operation first packet bit transmitted, t = 0 senderreceive r RTT last packet bit transmitted, t = L / R first packet bit arrives last packet bit arrives, send ACK ACK arrives, send next packet, t = RTT + L / R Example: 1 Gbps link, 15 ms prop. delay, 8000 bit packet 10/20/20097CSE 124 Networked Services Fall 2009
Filling the pipe operation first packet bit transmitted, t = 0 senderreceive r RTT last packet bit transmitted, t = L / R first packet bit arrives last packet bit arrives, send ACK ACK arrives, send next packet, t = RTT + L / R Example: 1 Gbps link, 15 ms prop. delay, 8000 bit packet, BDP=1Gbpsx30ms=30Mbits 10/20/20098CSE 124 Networked Services Fall 2009
Connection Establishment Process Three way handshake SYN, SYN+ACK, and ACK 10/20/2009CSE 124 Networked Services Fall 20099
3-10 TCP segment structure source port # dest port # 32 bits application data (variable length) sequence number acknowledgement number Receive window Urg data pointer checksum F SR PAU head len not used Options (variable length) URG: urgent data (generally not used) ACK: ACK # valid PSH: push data now (generally not used) RST, SYN, FIN: connection estab (setup, teardown commands) # bytes rcvr willing to accept counting by bytes of data (not segments!) Internet checksum (as in UDP) 10/20/2009
State transition diagram of TCP 10/20/2009CSE 124 Networked Services Fall Transition Event/Action
TCP Connection Management (cont.) Closing a connection: client closes socket: close(); Step 1: client end system sends TCP FIN control segment to server Step 2: server receives FIN, replies with ACK. Closes connection, sends FIN. client FIN server ACK FIN close closed timed wait 10/20/200912CSE 124 Networked Services Fall 2009
TCP Connection Management (cont.) Step 3: client receives FIN, replies with ACK. – Enters “timed wait” - will respond with ACK to received FINs Step 4: server, receives ACK. Connection closed. client FIN server ACK FIN closing closed timed wait closed 10/20/200913CSE 124 Networked Services Fall 2009
TCP Connection Management (cont) TCP client lifecycle TCP server lifecycle 10/20/200914CSE 124 Networked Services Fall 2009
Connection Established State Data transfer – Sender transmits data in sequence – Receiver acknowledges the received data packets – Sequence number helps in detecting loss and in-order delivery Sliding window management – Helps in in order delivery, reliable delivery, and flow control – Receiver window Round trip time estimation – Adaptive approach Congestion control – Many variants 10/20/2009CSE 124 Networked Services Fall
Sliding Window Management LastByteAcked ≤ LastByteSent LastByteSent ≤ LastByteWritten LastByteRead < NextByteExpected NextByteExpected ≤ LastByteRcvd+1 (if received in order, else, the beginning of the gap) LastByteRcvd –LastByteRead ≤ MaxRcvWindow AdvertizedWindow = MaxRcvBuffer – ((NextByteExpected -1) – LastByteRead) LastByteSent – LastByteAcked ≤ AdvertisedWindow EffectiveWindow = AdvertizedWindow – (LastByteSent – LastByteAcked) – EffectiveWindow >0 for transmitter to transmit (LastByteWritten – LastByteAcked)+y > MaxSendBuffer – Else the sender application is prevented from sending more 10/20/2009CSE 124 Networked Services Fall
10/20/2009CSE 124 Networked Services Fall SenderReceiver
Linux TCP: Packet ReceptionLinux TCP: Packet Transmission 10/20/2009CSE 124 Networked Services Fall /proc/sys/net/ipv4/tcp rmem/proc/sys/net/ipv4/tcp wmem
TCP Round Trip Time and Timeout EstimatedRTT = (1- )*EstimatedRTT + *SampleRTT r Exponential weighted moving average r influence of past sample decreases exponentially fast r typical value: = /20/200919CSE 124 Networked Services Fall 2009
TCP Round Trip Time and Timeout Setting the timeout EstimtedRTT plus “safety margin” – large variation in EstimatedRTT -> larger safety margin first estimate of how much SampleRTT deviates from EstimatedRTT: TimeoutInterval = EstimatedRTT + 4*DevRTT TimeoutInterval is expoentially increased with every retransmission DevRTT = (1- )*DevRTT + *|SampleRTT-EstimatedRTT| (typically, = 0.25) Then set timeout interval: 10/20/200920CSE 124 Networked Services Fall 2009
Summary Reading assignment TCP from Chapter 3 in Kurose and Ross TCP from Chapter 5 in Peterson and Davie 10/20/200921CSE 124 Networked Services Fall 2009