sliding window

7
Title : Sliding window flow control Aim : Write a program in C language to calculate the maximum efficiency of a sliding window flow control. Theory : Sliding Window Flow Control : Allows transmission of multiple frames Assigns each frame a k-bit sequence number Range of sequence number is [0..2k-1], i.e., frames are counted modulo 2k Operation of Sliding Window Sending Window : At any instant, the sender is permitted to send frames with sequence numbers in a certain range (the sending window) Receiving Window : The receiver maintains a receiving window corresponding to the sequence numbers of frames that are accepted How is “flow control” achieved? Receiver can control the size of the sending window By limiting the size of the sending window data flow from sender to receiver can be limited

Upload: ubaidsaudagar

Post on 27-Apr-2015

99 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: Sliding Window

Title : Sliding window flow control

Aim : Write a program in C language to calculate the maximum efficiency of a sliding window flow

control.

Theory :

Sliding Window Flow Control :

Allows transmission of multiple frames

Assigns each frame a k-bit sequence number

Range of sequence number is [0..2k-1], i.e., frames are counted modulo 2k

Operation of Sliding Window

Sending Window :

At any instant, the sender is permitted to send

frames with sequence numbers in a certain

range (the sending window)

Receiving Window :

The receiver maintains a receiving window

corresponding to the sequence numbers of frames that are accepted

How is “flow control” achieved?

Receiver can control the size of the sending

window

By limiting the size of the sending window data

flow from sender to receiver can be limited

Interpretation of ACK N message:

Receiver acknowledges all packets until (but not including) sequence number N

Analysis of Sliding Windows :

Page 2: Sliding Window

If the window size is sufficiently large the sender

can continuously transmit packets:

n W ³ 2a+1: Sender can transmit continuously

n W < 2a+1: Sender can transmit W frames every 2a+1 time units

Conclusion :

In this program we calculated for the maximum efficiency of a sliding window flow control , after

performing the program what we observe from the o/p is that till a certain window size , the efficiency

is less than 1, after that when the window size is much larger , the efficiency is equal to 1.

Page 3: Sliding Window

Algorithm :

Step 1: Intake the window size from the user .

Step 2: Intake the propagation time from the user .

Step 3: Intake the acknowledgement time from the user .

Step 4: Intake the processing time from the user .

Step 5: Intake the data frame transmission time from the user .

Step 6:Calculate the value of a = tp/tframe.

Step 7 : Calculate the maximum efficiency of the sliding window protocol .

Step 8: Depending upon the ack. and proc. time the efficiency changes , i.e. if the window size is

sufficiently large then efficiency is 1.

Step 9 :Display the maximum efficiency.

Step 10 :Stop.

Page 4: Sliding Window

Program :

#include<conio.h>

#include<stdio.h>

#include<math.h>

void main()

{

int n;

float tp,tframe,tack,tproc,a,eff;

clrscr();

printf("Enter the window size :\t");

scanf("%d",&n);

printf("Enter the propagation time :\t");

scanf("%f",&tp);

printf("Enter the acknowledgement time :\t");

scanf("%f",&tack);

printf("Enter the processing time :\t");

scanf("%f",&tproc);

printf("Enter the data frame transmission time :\t");

scanf("%f",&tframe);

a = tp/tframe;

eff = (n*tframe)/(tframe+(2*tp)+(2*tproc)+tack);

if(tproc<0.001)

Page 5: Sliding Window

{

eff = (n*tframe)/(tframe+(2*tp)+tack);

}

else if(tack<0.001)

{

eff = n/(1+(2*a));

}

if(n>1+(2*a))

{

eff = 1.0;

}

else

{

}

printf("Maximum efficiency of sliding window flow control is :%f",eff);

getch();

}

Page 6: Sliding Window

o/p: