Skip to content

Commit 66246e4

Browse files
committed
Separate class implementation for Go-Back-N Algorithm
1 parent fec9ddc commit 66246e4

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

Go-Back-N/GoBackN.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* The GoBackN class is defined, which includes the constructor to initialize the window size,
3+
* variables for tracking frames to send and frames expected, and functions for sender and receiver operations.
4+
**/
5+
6+
7+
8+
#include "GoBackN.h"
9+
#include <iostream>
10+
#include <cstdlib>
11+
#include <ctime>
12+
13+
14+
using namespace std;
15+
const int MAX_SEQUENCE_NUM = 7;
16+
17+
// Constructor for GoBackN class
18+
GoBackN::GoBackN(int window_size) {
19+
WINDOW_SIZE = window_size;
20+
frame_to_send = 0;
21+
next_frame_to_send = 0;
22+
frame_expected = 0;
23+
}
24+

Go-Back-N/GoBackN.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// This code defines a class 'GoBackN' that represents the Go-Back-N protocol.
2+
3+
4+
5+
#ifndef GOBACKN_H
6+
#define GOBACKN_H
7+
8+
9+
class GoBackN {
10+
private:
11+
int WINDOW_SIZE;
12+
int frame_to_send;
13+
int next_frame_to_send;
14+
int frame_expected;
15+
16+
public:
17+
GoBackN(int window_size);
18+
};
19+
20+
#endif

0 commit comments

Comments
 (0)