Network Transport Layer: Transport Reliability: Sliding Windows; Connection Management; TCP Y. Richard Yang 3/9/2016.

Slides:



Advertisements
Similar presentations
Introduction 1 Lecture 13 Transport Layer (Transmission Control Protocol) slides are modified from J. Kurose & K. Ross University of Nevada – Reno Computer.
Advertisements

1 End to End Protocols. 2 End to End Protocols r Last week: m basic protocols m Stop & wait (Correct but low performance) r Today: m Window based protocol.
Transport Layer3-1 TCP. Transport Layer3-2 TCP: Overview RFCs: 793, 1122, 1323, 2018, 2581 r full duplex data: m bi-directional data flow in same connection.
Data Communications and Computer Networks Chapter 3 CS 3830 Lecture 16 Omar Meqdadi Department of Computer Science and Software Engineering University.
1 Chapter 3 Transport Layer. 2 Chapter 3 outline 3.1 Transport-layer services 3.2 Multiplexing and demultiplexing 3.3 Connectionless transport: UDP 3.4.
1 Transport Layer Lecture 9 Imran Ahmed University of Management & Technology.
Transport Layer3-1 Summary of Reliable Data Transfer Checksums help us detect errors ACKs and NAKs help us deal with errors If ACK/NAK has errors sender.
Week 9 TCP9-1 Week 9 TCP 3 outline r 3.5 Connection-oriented transport: TCP m segment structure m reliable data transfer m flow control m connection management.
Transport Layer3-1 Homework r Chapter 2#10,13-18 r Due Wed September 17.
Transport Layer3-1 Pipelined protocols Pipelining: sender allows multiple, “in-flight”, yet-to- be-acknowledged pkts m range of sequence numbers must be.
Introduction 1 Lecture 12 Transport Layer (Transmission Control Protocol) slides are modified from J. Kurose & K. Ross University of Nevada – Reno Computer.
Transport Layer 4 Slides from Kurose and Ross
Chapter 3 outline 3.1 transport-layer services
Transport Layer 3-1 Transport Layer r To learn about transport layer protocols in the Internet: m TCP: connection-oriented protocol m Reliability protocol.
1 Outline r Transport-layer services r Multiplexing and demultiplexing r Connectionless transport: UDP r Principles of reliable data transfer.
Transport Layer3-1 Data Communication and Networks Lecture 6 Reliable Data Transfer October 12, 2006.
Announcement Project 1 due last night, how is that ? Project 2 almost ready, out tomorrow, will post online –Much harder than project 1, start early!
Announcement Project 1 due last night, how is that ? Homework 1 grade, comments out –Will be discussed in the next lecture Homework 2 out Project 2 almost.
Transport Layer 3-1 Transport Layer r To learn about transport layer protocols in the Internet: m TCP: connection-oriented protocol m Reliability protocol.
1 Announcement r Project 2 out m Much harder than project 1, start early! r Homework 2 due next Tuesday.
Transport Layer3-1 Reliable Data Transfer. Transport Layer3-2 Principles of Reliable data transfer r important in app., transport, link layers r top-10.
1 Outline r Transport-layer services r Multiplexing and demultiplexing r Connectionless transport: UDP r Principles of reliable data transfer.
Announcement Project 2 out –Much harder than project 1, start early! Homework 2 due next Tu.
Chapter 3 Transport Layer
Announcement Homework 1 graded Homework 2 out –Due in a week, 1/30 Project 2 problems –Minet can only compile w/ old version of gcc (2.96). –Only tlab-login.
Transport Layer3-1 Chapter 3 Transport Layer Computer Networking: A Top Down Approach Featuring the Internet, 3 rd edition. Jim Kurose, Keith Ross Addison-Wesley,
Some slides are in courtesy of J. Kurose and K. Ross Review of Previous Lecture r Transport-layer services r Multiplexing and demultiplexing r Connectionless.
EEC-484/584 Computer Networks Lecture 7 Wenbing Zhao (Part of the slides are based on Drs. Kurose & Ross ’ s slides for their Computer.
Transport Layer3-1 TCP sender (simplified) NextSeqNum = InitialSeqNum SendBase = InitialSeqNum loop (forever) { switch(event) event: data received from.
Transport Layer1 Reliable Transfer Ram Dantu (compiled from various text books)
3: Transport Layer3b-1 TCP: Overview RFCs: 793, 1122, 1323, 2018, 2581 r full duplex data: m bi-directional data flow in same connection m MSS: maximum.
2: Transport Layer 21 Transport Layer 2. 2: Transport Layer 22 TCP: Overview RFCs: 793, 1122, 1323, 2018, 2581 r full duplex data: m bi-directional data.
15-1 Last time □ Reliable Data Transfer ♦ Provide rdt over unreliable network layer ♦ FSM model ♦ rdt 1.0: rdt over reliable channels ♦ rdt 2.0: rdt over.
rdt2.2: a NAK-free protocol
Part 3: Transport Layer: Reliable Data Transfer CSE 3461/5461 Reading: Section 3.4, Kurose and Ross 1.
Transport Layer3-1 rdt2.1: sender, handles garbled ACK/NAKs Wait for call 0 from above sndpkt = make_pkt(0, data, checksum) udt_send(sndpkt) rdt_send(data)
Transport Layer 3-1 Chapter 3 outline 3.4 Principles of reliable data transfer.
1 End-to-End Protocols (UDP, TCP, Connection Management)
September 26 th, 2013 CS1652 The slides are adapted from the publisher’s material All material copyright J.F Kurose and K.W. Ross, All Rights.
Transport Layer3-1 Chapter 3 Transport Layer Computer Networking: A Top Down Approach 5 th edition. Jim Kurose, Keith Ross Addison-Wesley, April 2009.
Transport Layer3-1 Chapter 3 outline r 3.1 Transport-layer services r 3.2 Multiplexing and demultiplexing r 3.3 Connectionless transport: UDP r 3.4 Principles.
Transport Layer Our goals:
9: Pipelined Protocols and RTT Transport Layer 3-1 Slides adapted from: J.F Kurose and K.W. Ross,
Important r Midterm will be on m FRIDAY, Feb. 12th 1.
Transport Layer3-1 Transport Layer If you are going through Hell Keep going.
Introduction 1 Lecture 11 Transport Layer (Reliable Data Transfer) slides are modified from J. Kurose & K. Ross University of Nevada – Reno Computer Science.
Application Layer 2-1 Chapter 3 Transport Layer Computer Networking: A Top Down Approach 6 th edition Jim Kurose, Keith Ross Addison-Wesley March 2012.
CSEN 404 Transport Layer II Amr El Mougy Lamia AlBadrawy.
DMET 602: Networks and Media Lab Amr El Mougy Yasmeen EssamAlaa Tarek.
09-Transport Layer: TCP Transport Layer.
Chapter 3 Transport Layer
DMET 602: Networks and Media Lab
CS 1652 Jack Lange University of Pittsburgh
TCP: Overview RFCs: 793, 1122, 1323, 2018, 2581 full duplex data:
Introduction to Networks
Chapter 3 outline 3.1 transport-layer services
Last time Reliable Data Transfer
CS1652 TCP Jack Lange University of Pittsburgh
Review: UDP demultiplexing TCP demultiplexing Multiplexing?
rdt2.2: a NAK-free protocol
rdt2.2: a NAK-free protocol
rdt2.2: a NAK-free protocol
rdt2.2: a NAK-free protocol
rdt2.2: a NAK-free protocol
9: Pipelined Protocols and RTT
Network Transport Layer: Transport Reliability: Sliding Windows; Connection Management Y. Richard Yang 11/6/2018.
Chapter 3 Transport Layer
rdt2.0: FSM specification
Lecture 5 – Chapter 3 CIS 5617, Spring2019 Anduo Wang
rdt2.2: a NAK-free protocol
Presentation transcript:

Network Transport Layer: Transport Reliability: Sliding Windows; Connection Management; TCP Y. Richard Yang 3/9/2016

Admin.: PS4 proj-sol: FishThread.java Node.java PingRequest.java SimpleTCPSockSpace.java TCPManager.java TCPSock.java TCPSockID.java TransferClient.java TransferServer.java total 2 proj: FishThread.java Node.java PingRequest.java TCPManager.java TCPSock.java TransferClient.java TransferServer.java total

3 Recap: Reliable Data Transfer send side receive side rdt_send(): called from above, (e.g., by app.) udt_send(): called by rdt, to transfer packet over unreliable channel to receiver rdt_rcv(): called from below; when packet arrives on rcv-side of channel deliver_data(): called by rdt to deliver data to upper

4 Recap: Potential Channel Errors r bit errors r loss (drop) of packets r reordering or duplication Characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt).

5 Recap: rdt3.0 Sender (Bit Error/Loss) sndpkt = make_pkt(0, data, checksum) udt_send(sndpkt) start_timer rdt_send(data) Wait for ACK0 rdt_rcv(rcvpkt) && ( corrupt(rcvpkt) || isACK(rcvpkt,1) ) Wait for call 1 from above sndpkt = make_pkt(1, data, checksum) udt_send(sndpkt) start_timer rdt_send(data) rdt_rcv(rcvpkt) && notcorrupt(rcvpkt) && isACK(rcvpkt,0) rdt_rcv(rcvpkt) && ( corrupt(rcvpkt) || isACK(rcvpkt,0) ) rdt_rcv(rcvpkt) && notcorrupt(rcvpkt) && isACK(rcvpkt,1) stop_timer udt_send(sndpkt) start_timer timeout udt_send(sndpkt) start_timer timeout rdt_rcv(rcvpkt) Wait for call 0 from above Wait for ACK1  rdt_rcv(rcvpkt)   

6 rdt3.0 in Action Question to think about: What is a good timeout value?

7 rdt3.0 in Action

rdt3.0 sender data 0 (n-1) receiver data 0 (n-1) ACK for 0 (n-1) data 1 (n) waiting for 0 (n-1) sending 0 (n-1) waiting for 1 (n) sending 1 (n) waiting for 0 (n+1) ACK for 0 (n-1) State consistency: When receiver’s state is waiting n, the state of the sender is either sending for n-1 or sending for n When sender’s state is sending for n, receiver’s state is waiting for n or n + 1

rdt3.0: Stop-and-Wait Performance first packet bit transmitted, t = 0 senderreceiver 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 What is U sender : utilization – fraction of time sender busy sending? Assume: 1 Gbps link, 15 ms e-e prop. delay, 1KB packet

10 Performance of rdt3.0 r rdt3.0 works, but performance stinks r Example: 1 Gbps link, 15 ms e-e prop. delay, 1KB packet: T transmit = 8kb/pkt 10**9 b/sec = 8 microsec m 1KB pkt every 30 msec -> 33kB/sec thruput over 1 Gbps link m network protocol limits use of physical resources ! L (packet length in bits) R (transmission rate, bps) =

A Summary of Questions  How to improve the performance of rdt3.0? r What if there are reordering and duplication? r How to determine the “right” timeout value?

Sliding Window Protocols: Pipelining Pipelining: sender allows multiple, “in-flight”, yet-to-be- acknowledged pkts m range of sequence numbers must be increased m buffering at sender and/or receiver r Two generic forms of pipelined protocols: go-Back-N, selective repeat

13 Pipelining: Increased Utilization first packet bit transmitted, t = 0 senderreceiver RTT last bit transmitted, t = L / R first packet bit arrives last packet bit arrives, send ACK ACK arrives, send next packet, t = RTT + L / R last bit of 2 nd packet arrives, send ACK last bit of 3 rd packet arrives, send ACK increase utilization by a factor of 3! Question: a rule-of-thumb window size?

14 Go-Back-n Sender: r k-bit seq # in pkt header r “window” of up to W, consecutive unack’ed pkts allowed r ACK(n): ACKs all pkts up to, including seq # n - “cumulative ACK” m note: ACK(n) could mean two things: I have received upto and include n, or I am waiting for n r timer for the packet at base r timeout(n): retransmit pkt n and all higher seq # pkts in window W

15 GBN: Sender FSM Wait start_timer udt_send(sndpkt[base]) udt_send(sndpkt[base+1]) … udt_send(sndpkt[nextseqnum-1]) timeout rdt_send(data) if (nextseqnum < base+W) { sndpkt[nextseqnum] = make_pkt(nextseqnum,data,chksum) udt_send(sndpkt[nextseqnum]) if (base == nextseqnum) start_timer nextseqnum++ } else block sender if (new packets ACKed) { advance base; if (more packets waiting) send more packets } if (base == nextseqnum) stop_timer else start_timer for the packet at new base rdt_rcv(rcvpkt) && notcorrupt(rcvpkt) base=1 nextseqnum=1 rdt_rcv(rcvpkt) && corrupt(rcvpkt) 

16 GBN: Receiver FSM Only state: expectedseqnum r out-of-order pkt: m discard (don’t buffer) -> no receiver buffering! m re-ACK pkt with highest in-order seq # m may generate duplicate ACKs Wait udt_send(sndpkt) default rdt_rcv(rcvpkt) && notcurrupt(rcvpkt) && hasseqnum(rcvpkt,expectedseqnum) extract(rcvpkt,data) deliver_data(data) sndpkt = make_pkt(expectedseqnum,ACK,chksum) udt_send(sndpkt) expectedseqnum++ expectedseqnum=1 sndpkt = make_pkt(expectedseqnum,ACK,chksum) 

17 GBN in Action window size = 4

18 Analysis: Efficiency of Go-Back-n r Assume window size W r Assume each packet is lost with probability p r On average, how many packets do we send for each data packet received?

19 Selective Repeat r Sender window m Window size W: W consecutive unACKed seq #’s r Receiver individually acknowledges correctly received pkts m buffers out-of-order pkts, for eventual in-order delivery to upper layer m ACK(n) means received packet with seq# n only m buffer size at receiver: window size r Sender only resends pkts for which ACK not received o sender timer for each unACKed pkt

20 Selective Repeat: Sender, Receiver Windows W W

21 Selective Repeat data from above : r unACKed packets is less than window size W, send; otherwise block app. timeout(n): r resend pkt n, restart timer ACK(n) in [sendbase,sendbase+W-1]: r mark pkt n as received r update sendbase to the first packet unACKed sender pkt n in [rcvbase, rcvbase+W-1] r send ACK(n) r if (out-of-order) mark and buffer pkt n else /*in-order*/ deliver any in-order packets otherwise: r ignore receiver

22 Selective Repeat in Action

23 Discussion: Efficiency of Selective Repeat r Assume window size W r Assume each packet is lost with probability p r On average, how many packets do we send for each data packet received?

24 State Invariant: Window Location m Go-back-n (GBN) m Selective repeat (SR) sender window receiver window sender window receiver window

25 Window Location m Go-back-n (GBN) m Selective repeat (SR) sender window receiver window sender window receiver window Q: what relationship between seq # size and window size?

26 Selective Repeat: Seq# Ambiguity Example: r seq #’s: 0, 1, 2, 3 r window size=3 r incorrectly passes duplicate data as new in (a)

27 Sliding Window Protocols: Go-back-n and Selective Repeat Go-back-nSelective Repeat data bandwidth: sender to receiver (avg. number of times a pkt is transmitted) ACK bandwidth (receiver to sender) Relationship between M (the number of seq#) and W (window size) Buffer size at receiver Complexity p: the loss rate of a packet; M: number of seq# (e.g., 3 bit M = 8); W: window size More efficient Less efficient M > W M ≥ 2W 1 W Simpler More complex Less efficientMore efficient

28 Question: What is Initial Seq#? sender receiver ACK for 0 accept data 0

29 Question: What is Initial Seq#? sender receiver ACK for 0 (n) accept data 0 (transfer $1000 to B) accept?

30 Outline r Review  Reliable data transfer o perfect channel o channel with bit errors o channel with bit errors and losses o sliding window: reliability with throughput  connection management

31 Three Way Handshake (TWH) [Tomlinson 1975] Host A SYN(seq=x) Host B ACK(seq=x), SYN(seq=y) ACK(seq=y) DATA(seq=x+1) SYN: indicates connection setup accept data only after verified y is bounced back x is the init. seq notify initial seq#. Accept? think of y as a challenge

32 Scenarios with Duplicate Request/SYN Attack Host A Host B ACK(seq=x), SYN(seq=y) REJECT(seq=y) SYN(seq=x) accept? no such request reject

33 Scenarios with Duplicate Request/SYN Attack Host A Host B ACK(seq=x), SYN(seq=y) REJECT(seq=y) SYN(seq=x) accept? no such request reject ACK(seq=z)

34 Make “Challenge y” Robust r To avoid that “SYNC ACK y” comes from reordering and duplication m for each connection (sender-receiver pair), ensuring that two identically numbered packets are never outstanding at the same time network bounds the life time of each packet a sender will not reuse a seq# before it is sure that all packets with the seq# are purged from the network seq. number space should be large enough to not limit transmission rate

35 Connection Close r Why connection close? m so that each side can release resource and remove state about the connection (do not want dangling socket) client server I am done. Are you done too? I am done too. Goodbye! init. close close release resource? release resource? release resource?

36 General Case: The Two-Army Problem The gray (blue) armies need to agree on whether or not they will attack the white army. They achieve agreement by sending messengers to the other side. If they both agree, attack; otherwise, no. Note that a messenger can be captured!

37 Four Way Teardown Host A FIN Host B ACK FIN close closed all states removed timed wait - can retransmit the ACKif its ACK is lost closed A->B closed all states removed propose close A->B propose close B->A

38 A Summary of Questions  How to improve the performance of rdt3.0? ü sliding window protocols r What if there are duplication and reordering? ü network guarantee: max packet life time ü transport guarantee: not reuse a seq# before life time ü seq# management and connection management r How to determine the “right” parameters?

39 Outline r Recap r Reliable data transfer  TCP reliability

40 TCP: Overview RFCs: 793, 1122, 1323, 2018, 2581 r Point-to-point reliability: one sender, one receiver r Flow controlled and congestion controlled

41 Evolution of TCP Source:

42 Evolution of TCP Source: multiple versions

43 TCP Reliable Data Transfer r Connection-oriented: m connection management setup (exchange of control msgs) init’s sender, receiver state before data exchange close r Full duplex data: m bi-directional data flow in same connection r A sliding window protocol m a combination of go-back-n and selective repeat: send & receive buffers cumulative acks TCP uses a single retransmission timer do not retransmit all packets upon timeout

44 TCP Segment Structure source port # dest port # 32 bits application data (variable length) sequence number acknowledgement number rcvr window size ptr urgent data checksum F SR PAU head len not used Options (variable length) RST, SYN, FIN: connection management (reset, setup teardown commands) flow control ACK: ACK # valid counting by bytes of data (not segments!) Also in UDP URG: urgent data (generally not used) PSH: push data now (generally not used)

45 Flow Control r receive side of a connection has a receive buffer: r speed-matching service: matching the send rate to the receiving app’s drain rate r app process may be slow at reading from buffer sender won’t overflow receiver’s buffer by transmitting too much, too fast flow control

46 TCP Flow Control: How it Works  spare room in buffer = RcvWindow source port # dest port # application data (variable length) sequence number acknowledgement number rcvr window size ptr urgent data checksum F SR PAU head len not used Options (variable length)

47 TCP Seq. #’s and ACKs Seq. #’s: m byte stream “number” of first byte in segment’s data ACKs: m seq # of next byte expected from other side m cumulative ACK Host A Host B Seq=42, ACK=79, data = ‘C’ Seq=79, ACK=43, data = ‘C’ Seq=42, ACK=80 User types ‘C’ host ACKs receipt of echoed ‘C’ host ACKs receipt of ‘C’, echoes back ‘C’ time simple telnet scenario

48 Fast Retransmit r Problem: Timeout period often relatively long: m long delay before resending lost packet r If sender receives 3 ACKs for the same data, it supposes that segment after ACKed data was lost: m resend segment before timer expires r Detect lost segments via duplicate ACKs m sender often sends many segments back-to-back m if segment is lost, there will likely be many duplicate ACKs

49 Triple Duplicate Ack Packets Acknowledgements (waiting seq#)

50 event: ACK received, with ACK field value of y if (y > SendBase) { … SendBase = y if (there are currently not-yet-acknowledged segments) start timer … } else { increment count of dup ACKs received for y if (count of dup ACKs received for y = 3) { resend segment with sequence number y … Fast Retransmit: a duplicate ACK for already ACKed segment fast retransmit

51 TCP: reliable data transfer 00 sendbase = initial_sequence number agreed by TWH 01 nextseqnum = initial_sequence number by TWH 02 loop (forever) { 03 switch(event) 04 event: data received from application above 05 if (window allows send) 06 create TCP segment with sequence number nextseqnum 06 if (no timer) start timer 07 pass segment to IP 08 nextseqnum = nextseqnum + length(data) else put packet in buffer 09 event: timer timeout for sendbase 10 retransmit segment 11 compute new timeout interval 12 restart timer 13 event: ACK received, with ACK field value of y 14 if (y > sendbase) { /* cumulative ACK of all data up to y */ 15 cancel the timer for sendbase 16 sendbase = y 17 if (no timer and packet pending) start timer for new sendbase 17 while (there are segments and window allow) 18 sent a segment; 18 } 19 else { /* y==sendbase, duplicate ACK for already ACKed segment */ 20 increment number of duplicate ACKs received for y 21 if (number of duplicate ACKS received for y == 3) { 22 /* TCP fast retransmit */ 23 resend segment with sequence number y 24 restart timer for segment y 25 } 26 } /* end of loop forever */ Simplified TCP sender

52 TCP Receiver ACK Generation [RFC 1122, RFC 2581] Event at Receiver Arrival of in-order segment with expected seq #. All data up to expected seq # already ACKed Arrival of in-order segment with expected seq #. One other segment has ACK pending Arrival of out-of-order segment higher-than-expect seq. #. Gap detected Arrival of segment that partially or completely fills gap TCP Receiver Action Delayed ACK. Wait up to 500ms for next segment. If no next segment, send ACK Immediately send single cumulative ACK, ACKing both in-order segments Immediately send duplicate ACK, indicating seq. # of next expected byte Immediate send ACK, provided that segment starts at lower end of gap

53 %netstat -t -a CLOSED LISTEN SYN RCVD SYN SYN/ACK ACK CLOSED SYN SENT ESTABLSIHED FIN ACK FIN WAIT 1 ESTABLSIHED CLOSE WAIT FIN LAST ACK FIN WAIT 2 TIME WAIT

54 TCP Connection Management TCP lifecycle: init SYN/FIN CLOSED SYN RCVD SYN SYN/ACK ACK CLOSED SYN SENT ESTABLSIHED FIN ACK FIN WAIT 1 ESTABLSIHED CLOSE WAIT FIN LAST ACK FIN WAIT 2 TIME WAIT

55 TCP Connection Management TCP lifecycle: wait for SYN/FIN CLOSED SYN RCVD SYN SYN/ACK ACK CLOSED SYN SENT ESTABLSIHED FIN ACK FIN WAIT 1 ESTABLSIHED CLOSE WAIT FIN LAST ACK FIN WAIT 2 TIME WAIT

56 A Summary of Questions  How to improve the performance of rdt3.0? ü sliding window protocols r What if there are duplication and reordering? ü network guarantee: max packet life time ü transport guarantee: not reuse a seq# before life time ü seq# management and connection management r How to determine the “right” parameters?

57