-
Notifications
You must be signed in to change notification settings - Fork 0
/
gbn.cpp
48 lines (42 loc) · 1.02 KB
/
gbn.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <iostream>
#include <cmath>
using namespace std;
int t(int N, int TotalFrames)
{
int i =1;
int TotalTransactions=0;
while(i <= TotalFrames)
{
for(int k=i; k < i + N && k <= TotalFrames ; k++)
{
cout << "Sending Frame " << k << " ..." << endl;
TotalTransactions++;
}
int x=0;
cout << "If acknowledge is not received select 0 else select 1 : ";
cin >> x;
if(x == 1)
{
i = i + N;
}
else
{
int z=0;
cout << "Enter Frame Number for which acknowledgment is not received : ";
cin >> z;
i = z;
}
}
return TotalTransactions;
}
int main()
{
int TotalFrames=0, x=0;
cout << "enter total frames : ";
cin >> TotalFrames;
cout << "sequence bit size : ";
cin >> x;
int N = pow(2, x);
int TotalTransactions = t(N, TotalFrames);
cout << "total no. of frames sent and resent are : " << TotalTransactions << endl;
}