Transcript lecture12

EEC-484/584
Computer Networks
Lecture 12
Wenbing Zhao
[email protected]
(Part of the slides are based on Drs. Kurose &
Ross’s slides for their Computer Networking book)
2
Outline
• Reminder:
– Quiz#3 Wednesday
– Nov 10, 4pm: CSU IS&T data center tour
•
•
•
•
Introduction to transport layer
Multiplexing/demultiplexing
Reliable data transfer mechanisms
Sliding window protocols (part I)
Fall Semester 2008
EEC-484/584: Computer Networks
Wenbing Zhao
3
Transport Layer
Our goals:
• Understand
principles behind
transport layer
services:
– multiplexing/
demultiplexing
– reliable data
transfer
– flow control
– congestion control
Fall Semester 2008
• Learn about transport
layer protocols in the
Internet:
– UDP: connectionless
transport
– TCP: connectionoriented transport
– TCP congestion control
EEC-484/584: Computer Networks
Wenbing Zhao
4
Transport vs. Data Link Layer
• Similarities: deal with error control, sequencing,
flow control
• Difference: operating environments
Environment of the data link layer
Fall Semester 2008
Environment of the transport layer
EEC-484/584: Computer Networks
Wenbing Zhao
5
Transport vs. Network Layer
• Network layer: logical communication between
hosts
• Transport layer: logical communication
between processes
– Relies on, enhances, network layer services
Fall Semester 2008
EEC-484/584: Computer Networks
Wenbing Zhao
Internet Transport-Layer Protocols
• Reliable, in-order
delivery (TCP)
application
transport
network
data link
physical
– congestion control
– flow control
– connection setup
• Unreliable, unordered
delivery: UDP
– no-frills extension of “besteffort” IP
• Services not available:
– delay guarantees
– bandwidth guarantees
Fall Semester 2008
EEC-484/584: Computer Networks
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
Wenbing Zhao
6
7
Multiplexing/Demultiplexing
Multiplexing at send host:
gathering data from multiple
sockets, enveloping data with
header (later used for
demultiplexing)
Demultiplexing at rcv host:
delivering received segments
to correct socket
= socket
application
transport
network
link
= process
P3
P1
P1
application
P2
transport
network
P4
application
transport
network
link
link
physical
host 1
Fall Semester 2008
physical
host 2
EEC-484/584: Computer Networks
physical
host 3
Wenbing Zhao
8
How Demultiplexing Works
• Host receives IP datagrams
– Each datagram has source
IP address, destination IP
address
– Each datagram carries 1
transport-layer segment
– Each segment has source,
destination port number
• Host uses IP addresses & port
numbers to direct segment to
appropriate socket
Fall Semester 2008
32 bits
source port #
dest port #
other header fields
application
data
(message)
TCP/UDP segment format
EEC-484/584: Computer Networks
Wenbing Zhao
9
Reliable Data Transfer
characteristics of unreliable channel will determine
complexity of reliable data transfer protocol (rdt)
Fall Semester 2008
EEC-484/584: Computer Networks
Wenbing Zhao
10
Reliable Data Transfer
•
•
•
•
•
•
Why ack is needed
Why retransmission of data seg is needed
Why seq number on data seg is needed
Why seq number on ack is needed
When do we transmit an ack?
Do we retransmit ack?
Basic RDT mechanisms:
Acknowledgement, Retransmission,
Sequence numbers
Fall Semester 2008
EEC-484/584: Computer Networks
Wenbing Zhao
11
Sliding Window Protocols
• Full-duplex: Use same connection for data in both
directions (AB and BA)
• Interleave data and ack packets
– B piggybacks its ack for A’s packet onto B’s next packet
– Savings of header in separate ack packet
• If B sends data infrequently, use timeout to determine
when B should send ack in separate ack packet
• Each packet contains sequence number in ranges
0..2n-1 (for n-bit sequence numbers)
Fall Semester 2008
EEC-484/584: Computer Networks
Wenbing Zhao
12
Sending Window
• Start from empty and grow to a maximum size
• Within sending window, packets sent but not acked
– Sender must keep those packets for possible retransmission
– If max window size = w, need w buffers
1st outstanding Last packet
packet
sent
0
1
2
3
4
5
6
7
A new packet sent
(if send window allows)
0
1
2
3
4
5
6
When new packet arrives from
application layer, it is given
next highest sequence number,
and upper edge of window is
incremented
7
Sent window enlarges when more packet is sent
Fall Semester 2008
EEC-484/584: Computer Networks
Wenbing Zhao
13
Sending Window
0
0
1
2
3
ack
3
2
3
1
4
5
6
7
When ack arrives from
receiver, lower edge of
window is incremented
4
5
6
7
Sent window shrinks when the ack corresponding
to the 1st outstanding packet Is received
Fall Semester 2008
EEC-484/584: Computer Networks
Wenbing Zhao
14
Receiving Window
• List of consecutive sequence numbers of packets that
receiver is permitted to accept
• When packet with (seq num = lower edge of window) arrives
– Packet is passed to higher layer
– Ack is generated
– Window slid down by 1 (remains same size as was initially)
3
Fall Semester 2008
0
1
2
3
4
5
6
7
0
1
2
3
4
5
6
7
EEC-484/584: Computer Networks
Wenbing Zhao
15
Reliable Data Transfer:
Sliding Window Protocols
• A One-Bit Sliding Window Protocol
• A Protocol Using Go Back n
• A Protocol Using Selective Repeat
Fall Semester 2008
EEC-484/584: Computer Networks
Wenbing Zhao
16
One-Bit Sliding Window Protocol
A sliding window of size 1, with a 3-bit sequence number
Initially
Fall Semester 2008
After first
packet sent
After first
packet received
EEC-484/584: Computer Networks
After first
ack received
Wenbing Zhao
17
Sliding Window Protocols: Pipelining
• Problem of one-bit sliding window protocol:
– Sender blocks till receives acks
• Solution: pipelining
– Allow sender to send up to w packets before blocking
• With pipelining, if packet in middle is lost or
damaged, what to do with the packets following it ?
• Solution: two strategies
– Go Back n - all the packets following it are discarded
– Selective repeat – nack the lost/damaged packet and
retransmit that packet
Fall Semester 2008
EEC-484/584: Computer Networks
Wenbing Zhao
18
Pipelining and Error Recovery
Go back n: Effective receiver window size is 1
Packets discarded
Fall Semester 2008
EEC-484/584: Computer Networks
Wenbing Zhao
19
Pipelining and Error Recovery
Selective repeat
Packets buffered
Can you think of an alternative to go-back-n and selective-repeat?
Fall Semester 2008
EEC-484/584: Computer Networks
Wenbing Zhao
20
Go Back n
• Sender
– Stores all packets in output buffer
– Must get acks in order in which packets are sent
• Receiver
– Discards all packets following lost or damaged one
• Works well
– If transmission errors rare and few retransmissions
– If lot of traffic in both directions
Fall Semester 2008
EEC-484/584: Computer Networks
Wenbing Zhao
21
Selective Repeat
• Receiver accepts and buffers packets following
lost or damaged packets
• Both sender and receiver maintain windows
– Sender’s window starts at 0, grows to MAX SEQ
– Receiver’s window fixed at MAX SEQ
• Receiver has buffer reserved for each seq num
in its window
0
1
Fall Semester 2008
2
3
4
5
6
7
EEC-484/584: Computer Networks
Wenbing Zhao
22
Selective Repeat
• When packet arrives, receiver checks if seq num in
window
• If so and if not already received, this packet is accepted
and stored
• If all lower numbered packets delivered, this packet is
delivered as well
5
0
1
2
3
Fall Semester 2008
4
5
3
6
7
0
1
2
3
4
5
6
7
0
1
2
3
4
5
6
7
EEC-484/584: Computer Networks
Wenbing Zhao
23
Selective Repeat
• If no reverse traffic before timer goes off, separate ack is
sent
• When receiver suspects error, sends NAK back to sender
(request for retransmission)
• Two circumstances that trigger NAK
– Damaged packet arrives
– Packet other than expected one arrives, suspect expected one is
lost
• Receiver sends only one NAK for packet expected
Fall Semester 2008
EEC-484/584: Computer Networks
Wenbing Zhao
24
Non-Sequential Receive Problem
• New range of valid sequence numbers for
receiver can overlap old range
• Overlap can contain duplicates
• Example: n = 3-bit seq num (8 possible numbers,
0 through 7, back to 0)
0
1
Fall Semester 2008
2
3
4
5
6
7
0
1
2
EEC-484/584: Computer Networks
3
4
5
6
7
Wenbing Zhao
25
Non-Sequential Receive Problem
• Sender sends 0,1,2,3,4,5,6
• Receiver
– Receives 0,1,2,3,4,5,6
– Sends ack but ack gets lost
– Expects to receive 7,0,1,2,3,4,5
0
1
2
3
4
5
6
0
1
2
3
4
5
6
7
0
1
2
3
4
5
6
7
0
1
2
3
4
5
6
7
0
1
2
3
4
5
6
7
Fall Semester 2008
EEC-484/584: Computer Networks
Wenbing Zhao
26
Non-Sequential Receive Problem
• Sender times out, retransmits 0,1,2,3,4,5,6
• Receiver checks 0 is in new window, thinks new 0
because has sent ack for old 6, waits for 7
0
1
Fall Semester 2008
2
3
4
5
6
7
0
1
2
3
4
5
6
0
1
2
3
4
5
6
EEC-484/584: Computer Networks
7
Wenbing Zhao
27
Non-Sequential Receive Problem
• Sender receives ack for 0-6, sends 7
• Receiver receives 7, delivers 7 and
old 0 (as new 0 !)
7
0
1
2
3
4
5
6
7
0
1
2
3
4
5
6
7
0
1
2
3
4
5
6
7
0
1
2
3
4
5
6
7
Fall Semester 2008
EEC-484/584: Computer Networks
Wenbing Zhao
28
Non-Sequential Receive Problem
• The problem is caused by the overlap of
sequence number between the new receiving
window and the old receiving window
0
1
2
3
4
5
6
0
1
2
3
4
5
6
7
0
1
2
3
4
5
6
7
0
1
2
3
4
5
6
7
0
1
2
3
4
5
6
7
Overlap
Fall Semester 2008
Overlap
EEC-484/584: Computer Networks
Wenbing Zhao
29
Non-Sequential Receive Problem
• Solution:
– make sure no overlap when receiver advances its
window
– Make window size w =1/2 range of seq numbers
0
1
2
3
0
1
2
3
4
5
6
7
0
1
2
3
4
5
6
7
0
1
2
3
4
5
6
7
0
1
2
3
4
5
6
7
No Overlap
Fall Semester 2008
EEC-484/584: Computer Networks
Wenbing Zhao