Lecture 16 cn_aizaz_final

Lecture 16 cn_aizaz_final - •Data Communication and...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: •Data Communication and Networks 1 PIPELINING Until now we have assumed that the transmission Until now we have assumed that the transmission time required for a frame to arrive at the receiver plus the transmission time for the acknowledgement to come back is negligible. Sometimes we have a long round­trip time and this Sometimes we have a long round­trip time and this assumption is clearly false. In these situations, the long round­trip time can have In these situations, the long round­trip time can have important implications for the efficiency of the bandwidth utilization. 2 EXAMPLE Consider a 50­kbps satellite channel with a 500­msec Consider a 50­kbps satellite channel with a 500­msec round­trip propagation delay. We use protocol 4 to send 1000­bit frames via the We use protocol 4 to send 1000­bit frames via the satellite. At t = 0 the sender starts sending the first frame. At t = 0 the sender starts sending the first frame. At t = 20 msec (1000/50k), the frame has been At t = 20 msec (1000/50k), the frame has been completely sent. Not until t = 270 msec has the frame fully arrived at Not until t = 270 msec has the frame fully arrived at the receiver, and not until t = 520 msec has the acknowledgement arrived back at the sender, under the best of circumstances (no waiting in the receiver and a short acknowledgement frame). 3 This means that the sender was blocked during 500/520 or 96 percent of the time. In other words, only 4 percent of the available In other words, only 4 percent of the available bandwidth was used Clearly, the combination of a long transit time, high Clearly, the combination of a long transit time, high bandwidth, and short frame length is disastrous in terms of efficiency. 4 The problem is the result of the rule requiring a sender to wait for an acknowledgement before sending another frame. The solution lies in allowing the sender to transmit up The solution lies in allowing the sender to transmit up to w frames before blocking, instead of just 1. With an appropriate choice of w the sender will be With an appropriate choice of w the sender will be able to continuously transmit frames for a time equal to the round­trip transit time without filling up the window. In the example above, w should be at least 26. In the example above, w should be at least 26. 5 The sender begins sending frame 0 as before. By the time it has finished sending 26 frames, at t = By the time it has finished sending 26 frames, at t = 520, the acknowledgement for frame 0 will have just arrived. Thereafter, acknowledgements arrive every 20 msec, Thereafter, acknowledgements arrive every 20 msec, so the sender always gets permission to continue just when it needs it. At all times, 25 or 26 unacknowledged frames are At all times, 25 or 26 unacknowledged frames are outstanding. Put in other terms, the sender's maximum window Put in other terms, the sender's maximum window size is 26. 6 The need for a large window on the sending side occurs whenever the product of bandwidth x round­ trip­delay is large. If the bandwidth is high, even for a moderate delay, If the bandwidth is high, even for a moderate delay, the sender will exhaust its window quickly unless it has a large window. If the delay is high (e.g., on a geostationary satellite If the delay is high (e.g., on a geostationary satellite channel), the sender will exhaust its window even for a moderate bandwidth. 7 The product of these two factors basically tells what the capacity of the pipe is, and the sender needs the ability to fill it without stopping in order to operate at peak efficiency. This technique is known as PIPELINING. This technique is known as PIPELINING. 8 If the channel capacity is b bits/sec, the frame size l bits, and the round­trip propagation time R sec, the time required to transmit a single frame is l/b sec. After the last bit of a data frame has been sent, there After the last bit of a data frame has been sent, there is a delay of R/2 before that bit arrives at the receiver and another delay of at least R/2 for the acknowledgement to come back, for a total delay of R. 9 In stop­and­wait, the line is busy for l/b and idle for R, and line utilization = l/(l+bR) i If l < bR, the efficiency will be less than 50 percent. Since there is always a nonzero delay for the Since there is always a nonzero delay for the acknowledgement to propagate back, so pipelining can be used to keep the line busy during this interval. But if the interval is small, the additional complexity is But if the interval is small, the additional complexity is not worth the trouble. 10 A Protocol Using Go Back N Based on sliding window Based on sliding window If no error, ACK as usual with next frame If no error, ACK as usual with next frame expected If error If error Discard that frame and all future frames until error frame received correctly Transmitter must go back and retransmit that frame and all subsequent frames 11 This strategy corresponds to a receive window of size 1. • The data link layer only accepts frames in order. • If the sender's window fills up before the timer runs out, the pipeline will begin to empty. Eventually, the sender will time out and retransmit all unacknowledged frames in order, starting with the damaged or lost one. • This approach can waste a lot of bandwidth if the error rate is high. • 12 The sender must buffer all the unacknowledged frames since it may have to retransmit all the them at a future time When an acknowledgement comes in for frame n, When an acknowledgement comes in for frame n, frames n ­ 1, n ­ 2, and so on are also automatically acknowledged. This property is especially important when some of This property is especially important when some of the previous acknowledgement­bearing frames were lost or garbled. 13 Whenever any acknowledgement comes in, the data link layer checks to see if any buffers can now be released. If buffers can be released, then this means that there If buffers can be released, then this means that there is some room available in the window. A previously blocked network layer can now be A previously blocked network layer can now be allowed to cause more network_layer_ready events. 14 For this protocol, we assume that there is always reverse traffic on which to piggyback acknowledgements. If there is no traffic, no acknowledgements can be If there is no traffic, no acknowledgements can be sent. 15 Since there are multiple outstanding frames, so multiple timers are required, one per outstanding frame. Each frame times out independently of all the other Each frame times out independently of all the other ones. 16 /* Protocol 5 (go back n) allows multiple outstanding frames. The sender may transmit up to MAX_SEQ frames without waiting for an ack. In addition, unlike in the previous protocols, the network layer is not assumed to have a new packet all the time. Instead, the network layer causes a network_layer_ready event when there is a packet to send. */ #define MAX_SEQ 7 /* should be 2ˆn − 1 */ typedef enum {frame_arrival, cksum_err, timeout, network_layer_ready} event_type; #include "protocol.h" 17 static boolean between(seq_nr a, seq_nr b, seq_nr c) { /* Return true if a <=b < c circularly; false otherwise. */ if (((a <= b) && (b < c)) || ((c < a) && (a <= b)) || ((b < c) && (c < a))) return(true); else return(false); } static void send_data(seq_nr frame_nr, seq_nr frame_expected, packet buffer[ ]) { /* Construct and send a data frame. */ frame s; /* scratch variable */ s.info = buffer[frame_nr]; /* insert packet into frame */ s.seq = frame_nr; /* insert sequence number into frame */ s.ack = (frame_expected + MAX_SEQ) % (MAX_SEQ + 1);/* piggyback ack */ to_physical_layer(&s); /* transmit the frame */ start_timer(frame_nr); /* start the timer running */ } 18 void protocol5(void) { seq_nr next_frame_to_send; /* MAX_SEQ > 1; used for outbound stream */ seq_nr ack_expected; /* oldest frame as yet unacknowledged */ seq_nr frame_expected; /* next frame expected on inbound stream */ frame r; /* scratch variable */ packet buffer[MAX_SEQ + 1]; /* buffers for the outbound stream */ seq_nr nbuffered; /* # output buffers currently in use */ seq_nr i; /* used to index into the buffer array */ event_type event; enable_network_layer(); /* allow network_layer_ready events */ ack_expected = 0; /* next ack expected inbound */ next_frame_to_send = 0; /* next frame going out */ frame_expected = 0; /* number of frame expected inbound */ nbuffered = 0; /* initially no packets are buffered */ 19 while (true) { wait_for_event(&event); /* four possibilities: see event_type above */ switch(event) { case network_layer_ready: /* the network layer has a packet to send */ /* Accept, save, and transmit a new frame. */ from_network_layer(&buffer[next_frame_to_send]); /* fetch new packet */ nbuffered = nbuffered + 1; /* expand the sender’s window */ send_data(next_frame_to_send, frame_expected, buffer);/* transmit the frame */ inc(next_frame_to_send); /* advance sender’s upper window edge */ break; 20 case frame_arrival: /* a data or control frame has arrived */ from_physical_layer(&r); /* get incoming frame from physical layer */ if (r.seq == frame_expected) { /* Frames are accepted only in order. */ to_network_layer(&r.info); /* pass packet to network layer */ inc(frame_expected); /* advance lower edge of receiver’s window */ } /* Ack n implies n − 1, n − 2, etc. Check for this. */ while (between(ack_expected, r.ack, next_frame_to_send)) { /* Handle piggybacked ack. */ nbuffered = nbuffered − 1; /* one frame fewer buffered */ stop_timer(ack_expected); /* frame arrived intact; stop timer */ inc(ack_expected); /* contract sender’s window */ } break; 21 case cksum_err: break; /* just ignore bad frames */ case timeout: /* trouble; retransmit all outstanding frames */ next_frame_to_send = ack_expected; /* start retransmitting here */ for (i = 1; i <= nbuffered; i++) { send_data(next_frame_to_send, frame_expected, buffer);/* resend frame */ inc(next_frame_to_send); /* prepare to send the next one */ } } if (nbuffered < MAX_SEQ) enable_network_layer(); else disable_network_layer(); } } Fig. A sliding window protocol using go back n. 22 ...
View Full Document

This note was uploaded on 12/18/2010 for the course ME 22 taught by Professor Rashid during the Spring '10 term at Superior University Lahore.

Ask a homework question - tutors are online