Transcript Global Information Systems and Software Technology (GISST)
University of British Columbia
CICS 515 (Part 1) Computer Networks
Lectures 3 – Transport Layer (TCP/UDP) Principle of Reliable Data Transfer
Instructor: Dr. Son T. Vuong Email: [email protected]
May 17 , 2012
The World Connected
Jump to first page
Lecture 3: Transport Layer
(Kurose Ch. 3)
Our goals:
understand principles behind transport layer services: multiplexing/demultiplexing reliable data transfer flow control congestion control learn about transport layer protocols in the Internet: UDP: connectionless transport TCP: connection oriented transport TCP congestion control
CICS 515 – Summer 2012 © Dr. Son Vuong
2
Outline (Ch. 3)
3.1 Transport-layer services 3.2 Multiplexing and demultiplexing 3.3 Connectionless transport:
UDP
3.5 Connection-oriented transport:
TCP
segment structure reliable data transfer flow control connection management 3.4 Principles of reliable data transfer ( Sliding Window Protocol ) 3.6 Principles of congestion control 3.7 TCP congestion control
CICS 515 – Summer 2012 © Dr. Son Vuong
3
Internet Architecture
Defined by Internet Engineering Task Force (IETF) Hourglass Design Application vs Application Protocol (FTP, HTTP)
FTP HTTP TCP NV TFTP UDP IP
NET 1 NET 2 …
CICS 515 – Summer 2012 © Dr. Son Vuong
NET n Application TCP UDP IP Network 4
Example TCP/IP internet
H7 Network 1 (Ethernet) R3
H8 H1
H2 H3 Network 2 (Ethernet) R1 Network 4 (point-to-point) R2 H4 Network 3 (FDDI) H1 TCP IP IP R1 H5 IP R2 ETH ETH FDDI
CICS 515 – Summer 2012 © Dr. Son Vuong
FDDI PPP H6 PPP IP R3 ETH IP H8 TCP ETH 5
Transport services and protocols
provide
logical communication
between app processes running on different hosts transport protocols run in end systems send side: breaks app messages into segments , passes to network layer rcv side: reassembles segments into messages, passes to app layer more than one transport protocol available to apps Internet: TCP and UDP
CICS 515 – Summer 2012 © Dr. Son Vuong
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 6
Transport services and TCP Segments
TCP sends data in
Segments
(same concept as Packets, just a different name).
Data is written by the application program into the TCP buffers, and at some later time each Segment will be transmitted.
Application process Write bytes TCP Send buffer Application process Read bytes TCP Receive buffer Segment Segment … Segment
CICS 515 – Summer 2012 © Dr. Son Vuong
Transmit segments 7
Transport vs. network layer
network layer:
logical communication between hosts
transport layer:
logical communication between processes relies on, enhances, network layer services Household analogy:
12 kids sending letters to 12 kids
processes = kids app messages = letters in envelopes hosts = houses transport protocol entities = Ann and Bill network-layer service = postal service
CICS 515 – Summer 2012 © Dr. Son Vuong
8
Internet transport-layer protocols
reliable, in-order delivery ( TCP ) congestion control flow control connection setup unreliable, unordered delivery: UDP no frills extension of “best effort” IP services not available: application transport network data link physical delay guarantees bandwidth guarantees 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
CICS 515 – Summer 2012 © Dr. Son Vuong
9
Transport services and protocols
provide
logical communication
between app processes running on different hosts transport protocols run in end systems send side: breaks app messages into segments , passes to network layer rcv side: reassembles segments into messages, passes to app layer more than one transport protocol available to apps Internet: TCP and UDP
CICS 515 – Summer 2012 © Dr. Son Vuong
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 10
Multiplexing and demultiplexing
Ch. 3
3.1 Transport-layer services 3.2 Multiplexing and demultiplexing 3.3 Connectionless transport:
UDP
3.5 Connection-oriented transport:
TCP
segment structure reliable data transfer flow control connection management 3.4 Principles of reliable data transfer 3.6 Principles of congestion control 3.7 TCP congestion control
CICS 515 – Summer 2012 © Dr. Son Vuong
11
Multiplexing/demultiplexing
Demultiplexing at rcv host: delivering received segments to correct socket = socket = process Multiplexing at send host: gathering data from multiple sockets, enveloping data with header (later used for demultiplexing) application P3 transport network link physical host 1
CICS 515 – Summer 2012 © Dr. Son Vuong
application transport network link physical host 2 P2 P4 application transport network link physical host 3 12
Multiplexing/demultiplexing
Recall:
segment
- unit of data exchanged between transport layer entities aka TPDU: transport protocol data unit P1 segment header segment application-layer data Hn Ht M segment P3 M application transport network Demultiplexing: delivering received segments to correct app layer processes Receiver P2 M M application transport network M P4 application transport network
CICS 515 – Summer 2012 © Dr. Son Vuong
13
Multiplexing/demultiplexing: examples
host A source port: x dest. port:
23
server B source port:
23
dest. port: x port use: simple
telnet
app Web client host C Source IP: C Dest IP: B source port: y dest. port: 80 Source IP: C Dest IP: B source port: x dest. port: 80 Web client host A
CICS 515 – Summer 2012 © Dr. Son Vuong
Source IP: A Dest IP: B source port: x dest. port: 80 Web server B port use: Web server 14
3.1
. Transport Mux Peer Instruction Question 3.1
Through a specific
port
(e.g. port 80), an application process (e.g. Web server) can communicate with multiple (the following number of) remote (e.g. client) processes:
Answer: (A)
Exactly 1
(B)
2
(C) (E)
None of the above 3
(D)
An arbitrary number
CICS 515 – Summer 2012 © Dr. Son Vuong
15
3.1b
. Transport Mux Peer Instruction Question 3.1b
Through a specific
socket
, an application process (e.g. Web server process or client process) can communicate with multiple (the following number of) remote (e.g. client or server) processes:
Answer: (A)
Exactly 1
(B)
2
(C) (E)
None of the above 3
(D)
An arbitrary number
CICS 515 – Summer 2012 © Dr. Son Vuong
16
Outline (Ch. 3)
3.1 Transport-layer services 3.2 Multiplexing and demultiplexing 3.3 Connectionless transport:
UDP
3.5 Connection-oriented transport:
TCP
segment structure reliable data transfer flow control connection management 3.4 Principles of reliable data transfer 3.6 Principles of congestion control 3.7 TCP congestion control
CICS 515 – Summer 2012 © Dr. Son Vuong
17
UDP: User Datagram Protocol [RFC 768]
“no frills,” “bare bones” Internet transport protocol “best effort” service, UDP segments may be: lost Why is there a UDP?
no connection establishment (which can add delay) delivered out of order to app
connectionless:
simple: no connection state at sender, receiver no handshaking between UDP sender, receiver each UDP segment handled independently of others small segment header no congestion control: UDP can blast away as fast as desired
CICS 515 – Summer 2012 © Dr. Son Vuong
18
UDP: more
often used for streaming multimedia apps loss tolerant rate sensitive other UDP uses DNS SNMP reliable transfer over UDP: add reliability at application layer application-specific error recovery!
CICS 515 – Summer 2012 © Dr. Son Vuong
19
UDP Header Format
0 16 SrcPort DstPort Checksum Length Data 31
Checksum
computed over: Pseudoheader + UDP header + Data Pseudoheader = src, dest IP addresses + Protocol no. (17) + UDP length
CICS 515 – Summer 2012 © Dr. Son Vuong
20
UDP Message Queue
Application process Application process Application process Ports Queues Packets demultiplexed UDP
CICS 515 – Summer 2012 © Dr. Son Vuong
Packets arrive 21
UDP checksum
Goal: detect “errors” (e.g., flipped bits) in transmitted segment Sender: treat segment contents as sequence of 16-bit integers checksum: addition (1’s complement sum) of segment contents sender puts checksum value into UDP checksum field
CICS 515 – Summer 2012 © Dr. Son Vuong
Receiver: compute checksum of received segment check if computed checksum equals checksum field value: NO - error detected YES - no error detected.
But maybe errors nonetheless?
….
More later 22
Internet Checksum Example
Note When adding numbers, a carryout from the most significant bit needs to be added to the result Example: add two 16-bit integers
1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
wraparound
1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1
sum checksum
1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1 Checksum at Rec 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 CICS 515 – Summer 2012 © Dr. Son Vuong
23
Outline (Ch. 3)
3.1 Transport-layer services 3.2 Multiplexing and demultiplexing 3.3 Connectionless transport:
UDP
3.5 Connection-oriented transport:
TCP
segment structure reliable data transfer flow control connection management 3.4 Principles of reliable data transfer 3.6 Principles of congestion control 3.7 TCP congestion control
CICS 515 – Summer 2012 © Dr. Son Vuong
24
Principles of Reliable data transfer
important in app., transport, link layers top-10 list of important networking topics!
characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt)
CICS 515 – Summer 2012 © Dr. Son Vuong
25
Reliable data transfer: getting started
rdt_send():
called from above, (e.g., by app.). Passed data to deliver to receiver upper layer
deliver_data(): rdt
called by to deliver data to upper send side receive side
udt_send():
called by rdt, to transfer packet over unreliable channel to receiver
CICS 515 – Summer 2012 © Dr. Son Vuong rdt_rcv():
called when packet arrives on rcv-side of channel 26
Reliable Data Link Protocols
Functions of data link protocols:
Flow control Error control Sequencing
Stop-and-wait (alternating-bit) protocol Sliding window protocol CICS 515 – Summer 2012 © Dr. Son Vuong
27
Protocols
Used for communications between entities in a distributed system Must speak the same language Key Elements: data part (syntax): data format control part (semantics): procedures Formal Description Techniques (FDTs) e.g. CFSM, Estelle, SDL, LOTOS
CICS 515 – Summer 2012 © Dr. Son Vuong
28
rdt1.0
: reliable transfer over a reliable channel
underlying channel perfectly reliable no bit errors, no loss of packets no flow control separate FSMs for sender, receiver: sender sends data into underlying channel receiver read data from underlying channel
Wait for call from above rdt_send(data) packet = make_pkt(data) udt_send(packet)
sender
Wait for call from below rdt_rcv(packet) extract (packet,data) deliver_data(data)
receiver
CICS 515 – Summer 2012 © Dr. Son Vuong
29
rdt2.0
: Protocol for unreliable channel
sender Stop-And-Wait Protocol
Error control Flow control
receiver rdt_send(data) sn d pkt = make_pkt(data, checksum) udt_send(sndpkt) rdt_rcv(rcvpkt) && isNAK(rcvpkt) Wait for call from above Wait for ACK or NAK udt_send(sndpkt) rdt_rcv(rcvpkt) && corrupt(rcvpkt) udt_send(NAK) Wait for call from below rdt_rcv(rcvpkt) && isACK(rcvpkt)
L
rdt_rcv(rcvpkt) && notcorrupt(rcvpkt) extract(rcvpkt,data) deliver_data(data) udt_send(ACK) CICS 515 – Summer 2012 © Dr. Son Vuong
30
rdt2.0: operation with no errors
rdt_send(data) sn
d
pkt = make_pkt(data, checksum) udt_send(sndpkt) rdt_rcv(rcvpkt) && isNAK(rcvpkt) Wait for call from above Wait for ACK or NAK udt_send(sndpkt) rdt_rcv(rcvpkt) && corrupt(rcvpkt) udt_send(NAK) rdt_rcv(rcvpkt) && isACK(rcvpkt) L Wait for call from below rdt_rcv(rcvpkt) && notcorrupt(rcvpkt) extract(rcvpkt,data) deliver_data(data) udt_send(ACK)
CICS 515 – Summer 2012 © Dr. Son Vuong
31
rdt2.0: error scenario
rdt_send(data) snkpkt = make_pkt(data, checksum) udt_send(sndpkt) rdt_rcv(rcvpkt) && isNAK(rcvpkt) Wait for call from above Wait for ACK or NAK udt_send(sndpkt) rdt_rcv(rcvpkt) && isACK(rcvpkt) L
CICS 515 – Summer 2012 © Dr. Son Vuong
rdt_rcv(rcvpkt) && corrupt(rcvpkt) udt_send(NAK) Wait for call from below rdt_rcv(rcvpkt) && notcorrupt(rcvpkt) extract(rcvpkt,data) deliver_data(data) udt_send(ACK) 32
Peer Instruction 3.2
Question
Is NAK necessary ( T or F ) and sufficient ( T or F ) ?
Answer:
(A): (B): (C): F, F F, T T, F (D): T, T (E): B, C and D CICS 515 – Summer 2012 © Dr. Son Vuong
33
Formal Specification of Protocols
Communicating Finite State Machines (CFSM)
- DATA SENDER 0 RECEIVER + DATA 0 (a) Eutopia +Error / -NAK 0 - DATA [TimeOut] / - DATA 1 + ACK +NAK / - DATA + DATA 0 1 - ACK (b) Stop-And-Wait Protocol CICS 515 – Summer 2012 © Dr. Son Vuong
34
Alternating Bit Protocol
SENDER RECEIVER
+ ACK 1
+
ACK 0 + DATA 1 + Error - ACK 1
0 3 0 3
- DATA 0
[TimeOut]
+ DATA 0 - DATA 1 + DATA 1
1 2 1 2 +
ACK 1 + DATA 0 + Error + ACK 0
(a) ABP with 4 states
- ACK 0 Init I=0
- S0 [T] S1 +
+ [I==J] Init J=1 + Error
S0 + [I!=J] J=J+1 t1
+
(b) ABP with 2 states CICS 515 – Summer 2012 © Dr. Son Vuong S1 -
Provided
I!= J
{
J=J+1
}
35
Alternating Bit Protocol (Correct Version?)
SENDER +
ACK 1 - DATA 0
+
ACK 1
RECEIVER
+ ACK 1
+
ACK 0 + Error - ACK 1
0 3 1 [TimeOut]
+ ACK 0 + DATA 0 - DATA 1
2 +
ACK 0 + DATA 0 + Error
(a) ABP with 4 states 0 1
+ DATA 1 - ACK 0
3
+ DATA 0
2
+ DATA 1 + Error + DATA 1 + Error Init J=0 Init I=0 +
S0 - + [T] +
+ Error * +
(b) ABP with 2 states CICS 515 – Summer 2012 © Dr. Son Vuong
t1
S0 * S1
+ Error
-
+ [I!=J] 36
Alternating Bit Protocol (Correct Version)
SENDER +
ACK 1 - DATA 0
+
ACK 1
RECEIVER
+ ACK 1
+
ACK 0 + Error - ACK 1
0 3 1 [T] + ACK 1 + ACK 0
+ ACK 0 + DATA 0 - DATA 1
2 +
ACK 0 + DATA 0 + Error
(a) ABP with 4 states 0 1
+ DATA 1 - ACK 0
3
+ DATA 0
2
+ DATA 1 + Error + DATA 1 + Error Init J=0 Init I=0 +
S0 - + [T] +
+ Error * +
(b) ABP with 2 states CICS 515 – Summer 2012 © Dr. Son Vuong
t1
S0 * S1
+ Error
-
+ [I!=J] 37
How to Recover from Errors?
If a bad frame is detected, what do we do?
Forward Error Correction (FEC) - Using parity bits as a guide to fixing single bit errors.
Respond to the sender by transmitting a message: NAK = Negative Acknowledgement ACK = Positive Acknowledgement (if no error) Let the sender
timeout
and retransmit. Also called Automatic Repeat reQuest (ARQ)
CICS 515 – Summer 2012 © Dr. Son Vuong
38
Sender Receiv er Sender Receiv er Frame ACK Frame ACK Frame ACK Sender (a) (c )
Timeout for frame loss recovery
Receiv er Sender Receiv er Frame Frame ACK Frame Frame ACK ACK (b)
CICS 515 – Summer 2012 © Dr. Son Vuong
(d) 39
Questions:
What should we set the sender’s timeout value to be?
What is Piggybacking ? How does it save us from sending ACKs?
CICS 515 – Summer 2012 © Dr. Son Vuong
40
Efficiency: Stop-and-wait protocol
sender first packet bit transmitted, t = 0 last packet bit transmitted, t = L / R receiver RTT 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 e-e prop. delay, 1KB packet: U sender = L / R RTT + L / R .
008 = 30.008
CICS 515 – Summer 2012 © Dr. Son Vuong
= 0.00027 microsec onds 41
Stop-and-Wait Protocol Efficiency
α = CICS 515 – Summer 2012 © Dr. Son Vuong
42
Efficiency of Stop and Wait Protocol
U = D/(D+H+A+2CI) =~ 1/(1 + 2*Tp/Td) U = 1/(1+2 ) U = channel utilization (efficiency) D = # bits in frame body H = # bits in frame header A = # bits in ACK C = channel capacity (bits/sec) I = Propagation Delay = Distance/Speed (300, 200, 230 m/ s for vacuum, fiber, copper)
CICS 515 – Summer 2012 © Dr. Son Vuong
43
Link Utilization (Efficiency) Example
CICS 515 – Summer 2012 © Dr. Son Vuong
44
Maximizing Link Efficiency
Example: 1.5Mbps link x 45ms RTT = 67.5Kbits (8KBytes) for the Delay x Bandwidth product.
Assuming frame size of 1KB, stop-and-wait uses about one-eighth of the link's capacity. Solution: Want the sender to be able to transmit up to 8+1 = 9 frames before having to wait for an ACK.
CICS 515 – Summer 2012 © Dr. Son Vuong
45
Sliding Windows Flow Control
Allow multiple frames to be in transit Receiver has buffer W long Transmitter can send up to W frames without ACK Each frame is numbered ACK includes number of next frame expected Sequence number bounded by size of field (k) Frames are numbered modulo 2 k
CICS 515 – Summer 2012 © Dr. Son Vuong
46
Pipelined (sliding window) protocols
Pipelining: sender allows multiple, “in-flight”, yet-to-be acknowledged pkts range of sequence numbers must be increased buffering at sender and/or receiver Two generic forms of pipelined protocols:
go-Back-N, selective repeat
CICS 515 – Summer 2012 © Dr. Son Vuong
47
Efficiency: Stop-and-wait protocol
sender first packet bit transmitted, t = 0 last packet bit transmitted, t = L / R receiver RTT 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 e-e prop. delay, 1KB packet: U sender = L / R RTT + L / R .
008 = 30.008
CICS 515 – Summer 2012 © Dr. Son Vuong
= 0.00027 microsec onds 48
Pipelining: increased utilization
receiver first packet bit transmitted, t = 0 last bit transmitted, t = L / R sender RTT first packet bit arrives last packet bit arrives, send ACK last bit of 2 nd last bit of 3 rd packet arrives, send ACK packet arrives, send ACK ACK arrives, send next packet, t = RTT + L / R Increase utilization by a factor of 3!
U sender = 3 * L / R RTT + L / R .
024 = 30.008
CICS 515 – Summer 2012 © Dr. Son Vuong
= 0.0008 microsecon ds 49
Sliding Window Protocol Efficiency
CICS 515 – Summer 2012 © Dr. Son Vuong
50
Efficiency: Stop-and-wait protocol
sender first packet bit transmitted, t = 0 last packet bit transmitted, t = L / R receiver RTT 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 e-e prop. delay, 1KB packet: U sender = L / R RTT + L / R .
008 = 30.008
CICS 515 – Summer 2012 © Dr. Son Vuong
= 0.00027 microsec onds 51
Peer Instruction 3.2: Questions
Consider the previous example: 1 Gbps link, 15 ms e-e propagation delay, e.g. RTT = 30 ms 1KB packet (1) What would be the window size to achieve 100% efficiency?
(A) 15 (B) 30 (C) 300 (D) 3751 (E) 4000 (F) None
(2) How many bits at minimum are needed for the sequence number ?
(A) 4 (B) 6 (C) 12 CICS 515 – Summer 2012 © Dr. Son Vuong (D) 13 (E) 15 (F) None
52
Sliding Window Diagram
CICS 515 – Summer 2012 © Dr. Son Vuong
53
Sliding Window Protocol Example
CICS 515 – Summer 2012 © Dr. Son Vuong
54
Dealing with Errors
What happens if a frame is lost, or is corrupted?
Solution 1:
Go back N
Receiver discards all subsequent frames Sender must retransmit all frames, starting at the lost/corrupted frame.
This implies that RWS = 1 No buffering is needed at the receiver Ordering of frames is guaranteed A lot of bandwidth is wasted if error rate is high.
CICS 515 – Summer 2012 © Dr. Son Vuong
55
Dealing with Errors cont.
Solution 2:
Selective Repeat
Receiver sends a NAK, with a list of frames that are missing/corrupted.
Receiver stores subsequent frames.
Sender retransmits the bad frame(s) only.
Need to buffer up to RWS frames at the receiver and order them correctly before sending to a higher protocol layer.
CICS 515 – Summer 2012 © Dr. Son Vuong
56
Sender
LAR LFS SWS 0 1 2 3 4 5 6 7 8 Sender side: SWS: send window size LAR: last ACK received LFS: last frame sent Sender: if more data to send (LFS-LAR < SWS) then send data, LFS++ if recv’ed ACK for LAR+1 then LAR++ if timer expires then send LAR+1 CICS 515 – Summer 2012 © Dr. Son Vuong
57
Receiver
Receiver side: RWS: receive window size LFR: last frame received LAF: largest acceptable frame LFR RWS LAF 0 1 2 3 4 5 6 7 8 Receiver: if recv’ed K <= LFR, K > LAF then discard else store if K == LFR+1 then LFR++, LAF++ (slide window) ACK, largest in-order received frame CICS 515 – Summer 2012 © Dr. Son Vuong
58
Selective Repeat Example - Animated
SWS 0 1 2 3 4 5 6 7 8 4 RWS ACK5 0 1 2 3 5 CICS 515 – Summer 2012 © Dr. Son Vuong
59
Selective Repeat Example
SWS 0 1 2 3 4 5 6 7 8 2 Choice to keep 3 or discard CICS 515 – Summer 2012 © Dr. Son Vuong 3 X loss 0 1 RWS
60
Selective Repeat Example
SWS 0 1 2 3 4 5 6 7 8 2 4 0 1 RWS 3 5 CICS 515 – Summer 2012 © Dr. Son Vuong
61
Selective Repeat Example - Animated
SWS 0 1 2 3 4 5 6 7 8 4 RWS ACK5 0 1 2 3 5 CICS 515 – Summer 2012 © Dr. Son Vuong
62
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” may receive duplicate ACKs (see receiver) timer for each in-flight pkt
timeout(n):
retransmit pkt n and all higher seq # pkts in window
CICS 515 – Summer 2012 © Dr. Son Vuong
63
GBN in action
M >= W + 1 or W =< M-1 CICS 515 – Summer 2012 © Dr. Son Vuong
64
GBN - Scenario 1 of Confusion When W =< M-1 is violated
Window W = Modulus M = 8
What’s wrong ?
I, 0 I, 1 lost I, 2 I, 3 I, 4 I, 5 I, 6 I, 7 ACK, 0 ACK, 0 I, 0 CICS 515 – Summer 2012 © Dr. Son Vuong
65
GBN - Scenario 1 of Confusion When W =< M-1 is violated
Confusion when Window W = Modulus M = 8
ACK,0 can mean Ack to request for retransmission of I,0; ACK, 0 can also mean Ack for receipt of all I frames 0 to 7, and to request for new packet 0.
Thus, upon receiving ACK, 0 Sender is confused whether Receiver has received all I packets 0 to 7, or none at all.
CICS 515 – Summer 2012 © Dr. Son Vuong I, 0 I, 1 lost I, 2 I, 3 I, 4 I, 5 I, 6 I, 7 ACK, 0 ACK, 0 I, 0
66
GBN - Scenario 2 of Confusion When W =< M-1 is violated
I, 0 I, 1 I, 2 lost I, 3 I, 4 ACK, 1 ACK, 2 ACK, 3 ACK, 4 I, 5 ACK, 5 I, 6 I, 7 ACK, 6 ACK, 7 I, 0 lost ACK, 0
Window W = Modulus M = 8
What’s wrong ?
CICS 515 – Summer 2012 © Dr. Son Vuong
67
GBN - Scenario 2 of Confusion When W =< M-1 is violated
I, 0 I, 1 I, 2 lost I, 3 I, 4 ACK, 1 ACK, 2 ACK, 3 ACK, 4 I, 5 ACK, 5 I, 6 I, 7 ACK, 6 ACK, 7 I, 0 lost ACK, 0 CICS 515 – Summer 2012 © Dr. Son Vuong If all ACKs got lost, Sender will timeout and retransmit duplicate I frame 0 I, 0 which will unfortunately be treated wrongly by the Receiver as the new fresh I Frame 0.
68
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
CICS 515 – Summer 2012 © Dr. Son Vuong
69
Selective repeat: sender, receiver windows
CICS 515 – Summer 2012 © Dr. Son Vuong
70
Selective repeat in action
CICS 515 – Summer 2012 © Dr. Son Vuong
71
Example: Go-back-N RWS = 1
SWS = 3 0 1 2 0 1 2 0 1 2 3 sequence numbers SWS = 3 RWS = 1 Case 1: All 3 packets get lost Case 2: All 3 packets received OK Ack 2, Expecting “0” 2 RWS = 1 Sender cannot tell which case (from ACK 2) !
Sequence space must be at least SWS+1 i.e. SWS < Modulus CICS 515 – Summer 2012 © Dr. Son Vuong
72
Selective repeat: dilemma
Example:
seq #’s: 0, 1, 2, 3 window size=3 receiver sees no difference in two scenarios!
incorrectly passes duplicate data as new in (a) Q: what relationship between seq # size and window size?
CICS 515 – Summer 2012 © Dr. Son Vuong
73
Example: Selective Repeat RWS = SWS
Modulus = 4 SWS = 3 0 1 2 3 0 1 2 3 0 Receiver:
or delayed and I received a
new 0
Did 3 just get lost or did all my ACKs get lost and this is the
old 0
?
RWS = 3 0 1 2 3 0 1 2 Sequence space = Modulus >= SWS + RWS = 2SWS i.e. SWS =< Modulus/2 CICS 515 – Summer 2012 © Dr. Son Vuong
74
Example
SWS = 2 0 1 2 3 0 1 2 3 0 Receiver: No ambiguity!
If both of my ACKs got lost duplicate 0 would be received. Otherwise,
a new 2 or 3
would be received.
RWS = 2 0 1 2 3 0 1 2 Modulus = 4 and SWS = 2 => SWS =< Modulus/2 is satisfied CICS 515 – Summer 2012 © Dr. Son Vuong
75
TCP vs GobackN vs Selective Repeat
GobackN
RWS =1,
W =< M-1
Discard out-of-sequence segments Cumulative Ack e.g. ACK n Retransmit All outstanding segments e.g. segments n, n+1, …, N
Selective Repeat
• • RWS = SWS >1,
W =< M/2
Store out-of-sequence segments received • Individual Ack ( Selective Ack is an option) e.g. ACK n •Retransmit only 1 (oldest un-acked) segment, e.g. segment n only
TCP
is a hybrid compbined GobackN and Selective Repeat ( as shown in red )
CICS 515 – Summer 2012 © Dr. Son Vuong
76
Sliding Window Protocol
Summary
Used in dala link layer (node-to-node) Provide reliable transfer, flow/error control, and sequencing Efficiency depends on =Tp/Td and window size
CICS 515 – Summer 2012 © Dr. Son Vuong
77