Fall 2012: FCM 708 Bridge Foundation I Prof. Shamik Sengupta Instructor s Website: http://jjcweb.jjay.cuny.edu/ssengupta/ Blackboard Website: https://bbhosted.cuny.edu/
Intro to Computer Networking
Transport Layer
Transport services and protocols provide logical communication between app processes running on different hosts transport protocols run in end systems transport vs network layer services: network layer: data transfer between end systems transport layer: data transfer between processes application transport network data link physical network data link physical network data link physical network data link physical network data link physical network data link physical application transport network data link physical relies on network layer services
Transport-layer protocols Internet transport services: reliable, in-order unicast delivery (TCP) congestion flow control connection setup application transport network data link physical network data link physical network data link physical network data link physical network data link physical network data link physical unreliable ( best-effort ), unordered unicast or multicast delivery (UDP) application transport network data link physical
Principles of Reliable data transfer Sender needs to know whether receiver has received the packets Simplest implementation: stop and wait Sender sends one packet, then waits for receiver response
Stop & Wait protocol
World is not ideal Practical scenario: underlying channel can lose packets (data or ACKs) because of many reasons What if data packet gets lost? What if Ack packet gets lost?
World is not ideal Practical scenario: underlying channel can lose packets (data or ACKs) because of many reasons What if data packet gets lost? What if Ack packet gets lost? Approach: sender waits reasonable amount of time for ACK retransmits if no ACK received in this time
Stop & wait protocol with loss
New constraint: Stop & wait protocol with delay Practical scenario: What if Ack packet lost or just delayed (not lost) Approach: sender waits reasonable amount of time for ACK retransmits if no ACK received in this time if pkt (or ACK) just delayed (not lost): retransmission will be duplicate Sender, receiver need to specify seq # of pkt being handled
Stop & wait protocol with delay
Performance of stop-and-wait first packet bit transmitted, t = 0 last packet bit transmitted, t = L / R sender receiver Packet size = 8 Kb Transmission rate = 1 Mbps RTT = 30 sec. first packet bit arrives last packet bit arrives, send ACK ACK arrives, send next packet, t = RTT + L / R U sender = L / R RTT + L / R =.008 30+.008 = 0.00027
Pipelined protocols Pipelining: sender allows multiple, in-flight, yet-to-beacknowledged pkts range of sequence numbers must be increased buffering at sender and/or receiver
Pipelining: increased utilization first packet bit transmitted, t = 0 last bit transmitted, t = L / R sender receiver RTT ACK arrives, send next packet, t = RTT + L / R first packet bit arrives last packet bit arrives, send ACK last bit of 2 nd packet arrives, send ACK last bit of 3 rd packet arrives, send ACK U sender = 3 * L / R RTT + L / R =.024 30.008 Increase utilization by a factor of 3! = 0.0008 Two generic forms of pipelined protocols: go-back-n, selective repeat
Go-Back-N Sender: k-bit seq # in pkt header window of up to N, consecutive unack ed pkts allowed ACK(n): ACKs all pkts up to, including seq # n - cumulative ACK timer for each in-flight pkt timeout(n): retransmit pkt n and all higher seq # pkts in window
GBN in action
Selective Repeat receiver individually acknowledges all correctly received pkts buffers pkts, as needed, for eventual in-order delivery to upper layer sender only resends pkts for which ACK not received sender timer for each unacked pkt sender window N consecutive seq # s again limits seq #s of sent, unacked pkts
Selective repeat in action
TCP: Overview RFCs: 793, 1122, 1323, 2018, 2581 point-to-point: one sender, one receiver reliable, in-order byte steam: no message boundaries pipelined full duplex data: bi-directional data flow in same connection MSS: maximum segment size connection-oriented: handshaking (exchange of control msgs) init s sender, receiver state before data exchange flow controlled: sender will not overwhelm receiver 20
TCP seq. # s and ACKs Seq. # s: byte stream number of first byte in segment s data ACKs: seq # of next byte expected from other side User types C Host A Host B host ACKs receipt of C, echoes back C host ACKs receipt of echoed C time 21
TCP: retransmission scenarios Host A Host B Host A Host B timeout X loss Seq=100 timeout Seq=92 timeout time lost ACK scenario time premature timeout, cumulative ACKs 22
Example RTT estimation: RTT: gaia.cs.umass.edu to fantasia.eurecom.fr 350 300 RTT (milliseconds) 250 200 150 100 1 8 15 22 29 36 43 50 57 64 71 78 85 92 99 106 time (seconnds) SampleRTT Estimated RTT 23
TCP Round Trip Time and Timeout EstimatedRTT = (1- α)*estimatedrtt + α*samplertt Exponential weighted moving average influence of past sample decreases exponentially fast typical value: α = 0.125 24
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: DevRTT = (1-β)*DevRTT + β* SampleRTT-EstimatedRTT (typically, β = 0.25) Then set timeout interval: TimeoutInterval = EstimatedRTT + 4*DevRTT 25
Fast Retransmit time-out period often relatively long: long delay before resending lost packet detect lost segments via duplicate ACKs. sender often sends many segments back-to-back if segment is lost, there will likely be many duplicate ACKs for that segment If sender receives 3 ACKs for same data, it assumes that segment after ACKed data was lost: fast retransmit: resend segment before timer expires 26
Host A Host B triple duplicate ACKs seq # x1 seq # x2 seq # x3 seq # x4 seq # x5 X ACK x1 ACK x1 ACK x1 ACK x1 timeout time 27
TCP segment structure 32 bits source port # dest port # head len sequence number acknowledgement number not used checksum U A P R S F Receive window Urg data pointer Min 20bytes Options (variable length) application data (variable length)
TCP Connection Management Three way handshake: Recall: TCP sender, receiver establish connection before exchanging data segments initialize TCP variables: seq. #s buffers, flow control info (e.g. RcvWindow) Step 1: client host sends TCP SYN segment to server specifies initial seq # no data Step 2: server host receives SYN, replies with SYNACK segment server allocates buffers specifies server initial seq. # Step 3: client receives SYNACK, replies with ACK segment, which may contain data
TCP Connection Establishment aida.poly.edu mng.poly.edu SYN (SeqNo = x) SYN (SeqNo = y, AckNo = x + 1 ) (SeqNo = x+1, AckNo = y + 1 )
TCP Connection Management (cont.) Closing a connection: client server Step 1: client end system sends TCP FIN control segment to server Step 2: server receives FIN, replies with ACK. Closes connection, sends FIN. close timed wait closed close
TCP Connection Management (cont.) Step 3: client receives FIN, replies with ACK. closing client server Step 4: server, receives ACK. Connection closed. Note: with small modification, can handle simultaneous FINs. closing timed wait closed closed
Principles of Congestion Control Congestion: informally: too many sources sending too much data too fast for network to handle results: lost packets (buffer overflow at routers) long delays (queuing in router buffers)
Approaches towards congestion control two broad approaches towards congestion control: end-end congestion control: no explicit feedback from network congestion inferred from endsystem observed loss, delay approach taken by TCP network-assisted congestion control: routers provide feedback to end systems explicit rate sender should send at Network-layer mechanism for congestion control Traffic shaping / traffic policing
TCP congestion control: goal: TCP sender should transmit as fast as possible, but without congesting network Q: how to find rate just below congestion level decentralized: each TCP sender sets its own rate, based on implicit feedback: ACK: segment received (a good thing!), network not congested, so increase sending rate lost segment: assume loss due to congested network, so decrease sending rate
TCP congestion control: bandwidth probing probing for bandwidth : increase transmission rate on receipt of ACK, until eventually loss occurs, then decrease transmission rate continue to increase on ACK, decrease on loss (since available bandwidth is changing, depending on other connections in network) ACKs being received, so increase rate X loss, so decrease rate sending rate X X X X TCP s sawtooth behavior time Q: how fast to increase/decrease? details to follow
TCP congestion control: two phases slow start congestion avoidance important variables: Congestion window (cwnd) threshold: defines threshold between two slow start phase, congestion control phase
TCP Slow Start Host A Host B RTT time
TCP: congestion avoidance Increasing sending rate: How far would the doubling of cwnd go? What if a loss happens? Decrease sending rate Set the threshold value to half of current cwnd Till, it reaches a threshold After that it increases linearly loss: decrease cwnd to 1 and start the slow-start again
TCP Congestion Control: more details segment loss event: reducing cwnd timeout: no response from receiver cut cwnd to 1 TCP Tahoe principle 3 duplicate ACKs: at least some segments getting through (recall fast retransmit) cut cwnd in half, less aggressively than on timeout TCP Reno greedy heuristic
Popular flavors of TCP cwnd window size (in segments) ssthresh TCP Tahoe TCP Reno ssthresh Transmission round
Summary: TCP Congestion Control when cwnd < ssthresh, sender in slow-start phase, window grows exponentially. when cwnd >= ssthresh, sender is in congestionavoidance phase, window grows linearly. when triple duplicate ACK occurs, ssthresh set to cwnd/2, cwnd set to ~ ssthresh when timeout occurs, ssthresh set to cwnd/2, cwnd set to 1 MSS.
TCP Congestion Control Numerical example: Assume TCP Tahoe Initial ssthreshold = 14 First loss occurrence after 9 transmissions. What would be the current congestion window and ssthreshold?