Skip to content

Commit 2cc248d

Browse files
committed
Add Main Class: Example of how to use
1 parent 1092534 commit 2cc248d

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

Selective Repeat Protocol/Main.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/**
2+
* This code snippet in main.cpp essentially orchestrates the transmission and acknowledgment
3+
* of frames using the Selective Repeat protocol by interacting with the classes Frame and SelectiveRepeat.
4+
**/
5+
6+
7+
8+
#include <iostream>
9+
#include "Frame.h"
10+
#include "SelectiveRepeat.h"
11+
#include <vector>
12+
using namespace std;
13+
14+
15+
int main() {
16+
int n;
17+
cout << "**************************************************************";
18+
cout << "---> Enter the number of frames: ";
19+
cin >> n;
20+
vector<Frame> frames;
21+
for (int i = 0; i < n; i++) {
22+
int seqNum = i;
23+
string data;
24+
cout << "---> Enter data for frame " << seqNum << ": ";
25+
cin >> data;
26+
frames.emplace_back(Frame(seqNum, data));
27+
}
28+
int windowSize;
29+
cout << "---> Enter the window size: ";
30+
cin >> windowSize;
31+
SelectiveRepeat::execute(frames, windowSize);
32+
return 0;
33+
cout << "**************************************************************";s
34+
}

0 commit comments

Comments
 (0)