




Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
This file contains solution to problems related Data Communication Systems. Mr. Prajin Ahuja assigned task at Birla Institute of Technology and Science. Its main points are: Data, Questions, Solutions, Media, Access, Byte-oriented, Protocol, Error, Selective-Repeat, Piggybacking
Typology: Exercises
1 / 8
This page cannot be seen from the preview
Don't miss anything!





Review Questions
Exercises
b. Algorithm 11.2 can be used at the receiver site.
Figure 11.1 Solution to Exercise 13
Algorithm 11.1 Sender’s site solution to Exercise 15 InsertFrame (one-byte flag); // Insert beginning flag while (more characters in data buffer) { ExtractBuffer (character); if (character is flag or ESC) InsertFrame (ESC); // Byte stuff InsertFrame (character); } InsertFrame (one-byte flag); // Insert ending flag
Algorithm 11.2 Receiver’s site solution to Exercise 15 ExtractFrame (character); // Extract beginning flag Discard (character); // Discard beginning flag while ( more characters in the frame) { ExtractFrame (character); if (character = = flag) exit(); // Ending flag is extracted
if (character = = ESC) { Discard (character); // Un-stuff ExtractFrame (character); // Extract flag or ESC as data } InsertBuffer (character); } Discard (character); // Discard ending flag
ESC ESC ESC Flag ESC ESC ESC ESC ESC ESC ESC Flag
StopTimer (); PurgeFrame (S (^) n−1 , R (^) n−1); //Copy is not needed canSend = true; } }
if (Event(TimeOut)) // The timer expired { StartTimer (); ResendFrame (S (^) n -1 , R (^) n-1); // Resend a copy } } // End Repeat forever
Algorithm 11.5 A bidirectional algorithm for Selective-Repeat ARQ
S (^) w = 2 m−^1 ; S (^) f = 0; S (^) n = 0; R (^) n = 0; NakSent = false; AckNeeded = false; Repeat (for all slots); Marked (slot) = false; while (true) // Repeat forever { WaitForEvent (); if (Event (RequestToSend)) // There is a packet to send { if (S (^) n−S (^) f >= S (^) w) Sleep (); // If window is full GetData (); MakeFrame (S (^) n , R (^) n); StoreFrame (S (^) n , R (^) n); SendFrame (S (^) n , R (^) n); S (^) n = S (^) n + 1; StartTimer (S (^) n); }
if (Event (ArrivalNotification)) { Receive (frame); // Receive Data or NAK if (FrameType is NAK) { if (corrupted (frame)) Sleep(); if (nakNo between S (^) f and S (^) n) { resend (nakNo); StartTimer (nakNo); } }
Algorithm 11.4 A bidirectional algorithm for Stop-And-Wait ARQ
if (FrameType is Data) { if (corrupted (Frame)) AND (NOT NakSent) { SendNAK (R (^) n ); NakSent = true; Sleep(); }
if (ackNo between S (^) f and S (^) n ) { while (S (^) f < ackNo) { Purge (S (^) f ); StopTimer (S (^) f); S (^) f = S (^) f + 1; } }
if ((seqNo <> R (^) n ) AND (NOT NakSent)) { SendNAK (R (^) n ); NakSent = true; }
if ((seqNo in window) AND (NOT Marked (seqNo)) { StoreFrame (seqNo); Marked (seqNo) = true; while (Marked (R (^) n)) { DeliverData (R (^) n); Purge (R (^) n); R (^) n = R (^) n + 1; AckNeeded = true; } } } // End if (FrameType is Data) } // End if (arrival event)
if (Event (TimeOut (t))) // The timer expires { StartTimer (t); SendFrame (t); } } // End Repeat forever
Event A : Receiver Site: Frame 0 received. Event B : Receiver Site: Frame 1 received.
Algorithm 11.5 A bidirectional algorithm for Selective-Repeat ARQ
Delay for 1 window = 7 + 25 + 25 = 57 ms.
Total delay = 143 × 57 ms = 8.151 s