0% found this document useful (0 votes)
71 views9 pages

Aim: Study of Sliding Window Protocol. Theory

The document discusses sliding window protocol. It states that the sender and receiver both maintain windows to indicate the set of frames that can be sent or received. The windows can be visualized as a circle divided into parts representing the maximum sequence number. The upper and lower edges of the windows indicate the set of packets allowed to be sent but not yet acknowledged by the receiver or that the receiver can accept. The program implements sliding window protocol by having the sender transmit packets within its window and retransmit any packets not acknowledged by the receiver's window.

Uploaded by

sangeetadinesh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
71 views9 pages

Aim: Study of Sliding Window Protocol. Theory

The document discusses sliding window protocol. It states that the sender and receiver both maintain windows to indicate the set of frames that can be sent or received. The windows can be visualized as a circle divided into parts representing the maximum sequence number. The upper and lower edges of the windows indicate the set of packets allowed to be sent but not yet acknowledged by the receiver or that the receiver can accept. The program implements sliding window protocol by having the sender transmit packets within its window and retransmit any packets not acknowledged by the receiver's window.

Uploaded by

sangeetadinesh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Exp.No.

Study of sliding window protocol.


Aim: Study of sliding window protocol.

Theory:
At any instant of time, the sender maintains a set of sequence numbers which
correspond to the frames it is permitted to send. Such frames are said to be a set of the
sending window. Similarly, the receiver also maintains a receiving window which indicates
the set of frames it is allowed to receive.
A window can be visualised as a circle divided into (2n) 1 parts where n is the number of
bits required to represent, in binary, the maximum sequence number in a given sequence of
packets.
The upper and lower edges of a sending window indicate the set of packets which are allowed
to be sent but have not been acknowledged. The upper and lower edges of a receiving
window indicate the set of packets it may accept.
Program:

#include<stdio.h>

#include<iostream.h>

#include<conio.h>

#include<dos.h>

void main()

int ti,ri,i,j,ack=0,pack=0;

int rx[11],tx[11];

clrscr();

for(i=0;i<4;i++)

printf("\n transmission packet:");

for(ti=ack;ti<11;ti++)

delay(ack*(5%2+25));

tx[ti]=ti;

printf("%d",ti);

pack=ack;

if(i==3)

ack=11;

else

if(i==2)
ack=6;

else

if(i==1)

ack=3;

printf("\n receiving packet:");

for(ti=pack;ti<ack;ti++)

delay(ack*(5%100+5));

rx[ti]=ti;

printf("%d",ti);

printf("\n got acknowledgement as error in receiving packet


no.%d\n",ack);

printf("\n retransmitting packet from packet no.%d\n",ack);

//else

printf("\n\n data successfully transmitted");

pack=pack;

getch();

}
output

transmission packet:012345678910

receiving packet:

got acknowledgement as error in receiving packet no.0

retransmitting packet from packet no.0

transmission packet:012345678910

receiving packet:012

got acknowledgement as error in receiving packet no.3

retransmitting packet from packet no.3

transmission packet:345678910

receiving packet:345

got acknowledgement as error in receiving packet no.6

retransmitting packet from packet no.6

transmission packet:678910

receiving packet:678910

got acknowledgement as error in receiving packet no.11

retransmitting packet from packet no.11

data successfully transmitted

Conclusion:--------------------------------------------------------------------------------------
Exp.No.-8

Cyclic Redundancy Check

Aim: Study of Cyclic Redundancy Check

Theory:

A CRC is an example of a block code, but it can operate on blocks of any size. Given
a message block of size k bits, it produces a compact digest of size r bits, where r is a
constant (typically between 8 and 32 bits in real implementations). Together, the k + r = n
bits constitute a code word. Every valid code word has a certain minimum Hamming distance
from every other valid code word to aid in error detection. A CRC is an example of a
polynomial code as well as an example of a cyclic code. The idea in a polynomial code is to
represent every code word w = wn1wn2wn2 ...w0 as a polynomial of degree n 1. That
is, we write

For example, the code word 11000101 may be represented as the polynomial x7 + x6 + x2 +
1, plugging the bits into Eq.(7.1). We use the term code polynomial to refer to the polynomial
corresponding to a code word. The key idea in a CRC (and, indeed, in any cyclic code) is to
ensure that every valid code polynomial is a multiple of a generator polynomial, g(x). We
will look at the properties of good generator polynomials in a bit, but for now lets look at
some properties of codes built with this property. All arithmetic in our CRC will be done in
F2. The normal rules of polynomial addition, division, multiplication, and division apply,
except that all coefficients are either 0 or 1 and the coefficients add and multiply using the F2
rules. In particular, note that all minus signs can be replaced with + signs, making life quite
convenient.

Program
#include<stdio.h>
#include<conio.h>
#include<iostream.h>
#include<graphics.h>
intxor(intx,int y);
void main()
{
inti,j,k,n,d[20],m,g[10],msb,rem[25],z[30];
clrscr();
cout<<"\nEnter the data bits:";
cin>>n;
cout<<"\nEnter the data(press space after each data bits)";
for(i=0;i<n;i++)
cin>>d[i];
cout<<\"nEnter the no. of generator bits";
cin>>m;
cout<<"\nEnter the generator(press space after each data bits)";
for(i=0;i<m;i++)
cin>>g[i];
for(j=0;j<m-1;j++)
d[n+j]=0;
for(i=0;i<24;i++)
rem[i]=d[i];
cout<<endl;
for(i=0;i<m;i++)
z[i]=0;
for(i=0;i<n;i++)
{
k=0;
msb=rem[i];
for(j=i;j<m+i;j++)
{
if(msb==0)
rem[j]=xor(rem[j],z[k]);
else
rem[j]=xor(rem[j],g[k]);
k++;
}
rem[m+i]=d[m+i];
}
cout<<endl<<"The code bits are\n";
for(i=n;i<n+m-1;i++)
{
d[i]=rem[i];
cout<<d[i];
}
cout<<"\nThe coded data is\n";
for(i=0;i<m+n-1;i++)
cout<<d[i];
getch();
}
intxor(intx,int y)
{
if(x==y)
return(0);
else
return(1);
}

Conclusion:------------------------------------------------------------------------------- .

Exp.No.-9

ARQ
Aim: Study of

Theory:
PROGRAM:

#include<stdio.h>
#include<iostream.h>
#include<conio.h>
#include<dos.h>
#include<time.h>
#include<math.h>
#include<stdlib.h>
void main()
{
inti,j,k,n;
long d[8];
clrscr();
printf("Enter the data frame:");
scanf("%1d",&n);
for(i=0;i<n;i++)
{
printf("frame%d=",i);
scanf("%1d",&d[i]);
}
randomize();
for(i=0;i<n;i++)
{
j=random(1000);
if(j<500)
{
printf("\nFrame%d=%d is successfully transmitted\n",i,d[i]);
}
else
{
printf("\nFrame%d=%d is lost\nretransmitframe%d",i,i);
i--;
delay(1000);
}
}
getch();
}
Conclusion:------------------------------------------------------------------------------- .

You might also like