Title: Protocol 3
1Protocol 3
- Sender3
-
- frame_number 0
- while(true)
- get buffer from network layer
- construct frame with frame_number
- send to physical layer
- start a timer
- while( ack not received)
- wait for event
- (timer or ack or bad ack)
- if event is not ack
- resend frame
- increment frame number mod 2
- Receiver3
-
- frame_number 0
- while(true)
- wait for event (good frame arrival or
corrupt frame arrival) - if (event is frame arrival)
- read from physical layer
- if sequence number frame_number
- send data to network layer
- frame_number inc(frame_number)
-
- send ack (1 - frame_number)
- send data to physical layer
-
-
2Problems with Protocol 3
- We are spending too much time waiting and not
enough time sending data - The protocol can fail under some conditions
- How do we know how long to make the timeout?
- Data frames are transmitted in only one direction
3How can we achieve duplex communication?
- We could duplicate the system to handle traffic
in the opposite direction, but the acks make
inefficient use of the available bandwidth - Better, send data and acks on the same channel
- Even better, combine data and acks using a
technique called piggybacking.
4Piggybacking
- Typically an ack only requires a few bits of
information - if it is sent as an independent frame it requires
quite a bit of overhead - Frame delimiters and CRC
- Separate event must be processed when ack
arrives - Piggybacking combines acks with data frames that
are carrying data to the same host that is
expecting the ack.
5How long should we wait for data on which to
piggyback an ack?
- Cant wait longer than senders timeout,
otherwise frames will be resent - Cant know if a data buffer will arrive from
network layer - Generally waits a fixed number of milliseconds
6Sliding Window Protocols
- Each outbound frame contains a sequence number (0
to some max (usually 2n-1)) - Sender maintains a set of sequence numbers for
frames it is permitted to send (the sending
window) - Receiver maintains a set of sequence numbers for
frames it is permitted to accept (the receiving
window) - Network layer must still receive data in the
correct order
7Sliding window of size 1 with 3-bit sequence
number
Sender must have buffer space to hold all
unacknowledged frames Receiver discards frames
not within its window without comment
8Under-utilized bandwidth
- 50Kbps satellite channel
- 500 msec round trip propagation delay
- 1000-bit frames
- Frame requires 1/50th of a second (20 msecs) to
transmit data (put data in pipe) - Frame requires 250 msec to arrive
- Ack requires 250 msec to arrive
- We are only transmitting data at 20/500 or 4 of
the available bandwidth
9With Sliding Window Protocols we can pipeline
frame transmissions
- Use a window size of 26
- after sending frame 26, 2620ms 520ms have
elapsed, and the ack for the first frame should
be arriving. - Typically 25 or 26 acks are outstanding (in the
pipe)
10How do we handle damaged frames in a sliding
window protocol?
- Two approaches
- Go back n
- Refuse to accept any frames other than the next
one expected. All pipelined frames will be
discarded. Equivalent to receiver window size of
1. - Selective Repeat
- Maintain buffers to save the subsequent correct
frames that are in the pipe in buffers. When the
damaged frame is retransmitted and received,
additional buffered frames may be available for
transmission to the network layer.
- Using more memory provides better channel
Utilization
11Effect of Receiver Window Size
12Protocol 4
- Sliding Window Protocol
- Bidirectional Protocol
- Sliding window is of size 1
- Piggybacked Acks
13Protocol 4 (Sliding Window)windowSize 1
next_frame_to_send 0 frame_expected 0 get
data from network layer send frame()
sframe.data data sframe.seq_number
next_frame_to_send sframe.ack
1-frame_expected send frame via physical
layer start_timer(sframe.seq) send_frame()
// one side only while(true)
wait_for_event(event)
if (event is correct frame arrival) get
rframe from physical layer if (rframe.seq
frame_expected) send frame to
network layer inc (frame_expected) if
(r.ack next_frame_to_send) get data from
network layer inc_next_frame_to_send // Now
we are either sending a new buffer // or
resending an old buffer send_frame()
14Starting Protocol 4