File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -44,4 +44,22 @@ void GoBackN::sender() {
4444
4545 cout << " *** Sender: All frames sent successfully ***\n " ;
4646}
47-
47+
48+ // Receiver function for Go-Back-N algorithm
49+ void GoBackN::receiver () {
50+ while (frame_expected < MAX_SEQUENCE_NUM) {
51+ cout << " Waiting for frame " << frame_expected << " ...\n " ;
52+
53+ bool frame_arrives = rand () % 2 ;
54+
55+ if (frame_arrives) {
56+ cout << " Frame " << frame_expected << " received\n " ;
57+ cout << " Sending acknowledgment: " << frame_expected << endl;
58+ frame_expected++;
59+ } else {
60+ cout << " *** Timeout occurred, requesting retransmission ***\n " ;
61+ }
62+ }
63+
64+ cout << " *** Receiver: All frames received successfully ***\n " ;
65+ }
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ class GoBackN {
1616public:
1717 GoBackN (int window_size);
1818 void sender ();
19+ void receiver ();
1920};
2021
2122#endif
You can’t perform that action at this time.
0 commit comments