URGENT Project

I have to submit my project for evaluation this week.

Project Statement : In an organization, a project manager assigns different modules of a project to members. The module codes need to be sent through a network channel that is susceptible to errors, by a team leader to integrate it. Team leader has sufficient space to store the modules but within limited time, he has to submit all modules in order to the project manager. Implement the concept so that the project manager gets all the modules correctly.

>>It is a project to implement Selective Repeat ARQ protocol in Computer Networks based on the Data Link Layer. I need to provide a user interface to show the easiest implementation of sending and recieving frames using this protocol in C++.
(1) How long (so far) have you had this assignment to do?

(2) Have you written any code yet, or written some type of design for your program?

(3) What type of program is it? GUI or terminal?

(4) Which OS is it to run on?
1. I had this assignment for a week but due to some preoccupation i am not able to do it.

2. I have the code for Go Back N ARQ which is similar to this algo but a few minor differences such as the size of sender and reciever window in this should be same and each frame has its own timer.

3. I need to run it on Windows and using C++ only.

Im pasting the code for Go Back N ARQ here, but theres a problem with this one too. :

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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
#include<iostream.h>
#include<conio.h>
#include<math.h>

class sender
{
public :
int size,sf,sn,t,a[500],w,ff;
sender(){}//default constructor
sender(int x,int aa)//parameterised constructor
{ 
           ff=aa;  //ff and aa = total no of frames 
size=pow(2,x)-1;//size of sliding window
sn=0;//next frame to sent
sf=0;//first outstanding frame
w=0;//count of frames 
t=5;//timer (decremented by 1 after a frame in sent)
for(int i=0;i<aa;i=i+size+1)//to assign sequence no to frames
{ 
for(int j=0;j<=size;j++)
{
if(i+j < aa)

a[i+j]=j;

}

}

} 

void reqstsend()//to send frames

{

if(w<ff)//check whether the no. of frame sent is less than total no of frames

{

if(t<=0 )//check for time out
{
cout<<endl<<"timer out"<<endl;

timeout();

}

else if((sn-sf)>=size || sf==sn+1 )

{

cout<<endl<<"window is full"<<endl;

t--;

}

else if(sn == size)//special case when sn==size sn should be =0

{

cout<<endl<<"frame F"<<sn<<" sent..."<<endl;

sn=0;

t--;

w++;

}

else//normal sending

{

cout<<endl<<"frame F"<<sn<<" sent..."<<endl;

sn++;

t--;

w++;

}

}

else

cout<<endl<<" ***all frames sent***"<<endl;

}


 

void arivack(int y)//recieving acknowledgement

{

sf=y;

t=5;

}

void timeout()

{

sn=sf;

t=5;

w=w-5;

}

void sdisplay()//displaying frames initially

{

cout<<endl<<"frames :- ";

for(int i=0;i<ff;i++)

cout<<" "<<a[i]<<" ";

cout<<endl<<endl<<"sn = "<<sn<<endl<<"sf = "<<sf<<endl;

}

};//class sender ends
 
class reciever

{

public :

int rn,b[500],c;

sender *s;

reciever(sender *y,int q)

{

rn=0;//next expected frame

c=0;//coounter

for(int i=0;i<q;i++)

b[i]=0;

s=y;

}

void arivnot(int x)

{

if(rn == x)//recieve in order

{

if(rn != s->size)//recieving frames

{

b[c]=rn;

c++;

rn++;

}

else//special case when rn =size, then rn should be =0

{

b[c]=rn;

c++;

rn=0;

}

}

}


 

void sendack(int z)

{

cout<<endl<<"acknowledgement A"<<z<<" sent"<<endl;

s->arivack(z);

}


 

void rdisplay()

{

cout<<endl<<"frames recieved :- ";

for(int i=0;i<c;i++)

cout<<" "<<b[i]<<" ";

cout<<endl<<"rn = "<<rn<<endl;

}

};//class reciever end


int main()

{

int m,x=3,h,y;

cout<<endl<<"enter the value of m  i.e  no of bits allowed for sequence no. :--> ";

cin>>m;

cout<<"size of sliding window ="<<pow(2,m)-1<<endl;

cout<<"enter the total no of frames you want to send "<<endl;

cin>> h;

sender pqr(m,h),*g=&pqr;

reciever rec(g,h),*r=&rec;

while(x != 0)

{
            
 int counter =0;

if(counter==0)

{
             cout<<endl<<"1 --> go to sender"<<endl

             <<"0 --> exit"<<endl

             <<"enter code :--> ";

cin>>x;
counter++;
}


else

{
             cout<<endl<<"1 --> go to sender"<<endl

             <<"2 --> go to reciever"<<endl

             <<"0 --> exit"<<endl

             <<"enter code :--> ";

cin>>x;

}

switch(x)

{

case 1 : while(y != 3)

             {

             pqr.sdisplay();

             cout<<endl<<"1 --> send frame"<<endl

                         <<"2 --> send frame (lost or incorrect)"<<endl

                         <<"3 --> go back"<<endl

                         <<" :--> ";

             cin>>y;

             switch(y)

             {

             case 1 : pqr.reqstsend();

                         if(pqr.sn == 0)

                         r->arivnot(pqr.size);

else

                         r->arivnot(pqr.sn-1);

                         break;

             case 2 : pqr.reqstsend();

                         break;

             case 3 : break;

             default : cout<<endl<<"!!! error in code !!!"<<endl;

                         break;

             }

             }

             y=0;

             break;

case 2 : while(y != 2)

             {

             r->rdisplay();

             cout<<endl<<"1 --> send acknowledgement"<<endl

                         <<"2 --> go back"<<endl

                         <<" :--> ";

             cin>>y;


 

             switch(y)

             {

             case 1 : r->sendack(rec.rn);

                         break;

             case 2 : break;

             default : cout<<endl<<"!!! error in code !!!"<<endl;

                         break;

             }

             };

             y=0;

             break;

case 0 : break;

default : cout<<endl<<"!!! error in code !!!"<<endl;

                break;


 

}


}

getch();

}
Last edited on
Topic archived. No new replies allowed.