Sunday, 27 July 2014

Client Server Program in C to Simulate Go-Back-N-ARQ


  This program was also written some 5 years before. This again is a simulation program trying to imitate Go-Back-N ARQ. It is a client server program. Click here to view the Wikipedia article on Go-Back-N_ARQ. Here also the server side acts as the receiver and hence you should run this program first. Afterwards you should also run the client program which acts as the sender side. 

Figure Below Shows the Receiver

Figure Below Shows the Sender


The line given below sets the window size for the sender and the receiver.

#define W 5 
If you want you can change the window size to some other value. Currently the window size is 5.

The following lines in the receiver side decides the probability with which a frame fails to reach the destination.

#define P1 50
#define P2 10

You can increase the probability of a frame being corrupted by increasing the value of P2 and decrease the probability by decreasing the value of P2. Currently there is a 20% probability for frame corruption.

Click here to download the Receiver Side program.

Click here to download the Sender Side program.


Click here to view the article on Selective Repeat ARQ.

Client Server Program in C to Simulate Selective Repeat ARQ


  I wrote these programs 5 years ago. It is a simulation program trying to imitate the working of Selective Repeat ARQ. Click here to view the Wikipedia article on Selective Repeat ARQ. A client server C program is used to simulate the working of Selective Repeat ARQ. The server acts as the receiver. The client acts as the sender. Because of this reason first run the receiver program and afterwards run the sender program. 

Figure Below Shows theReceiver



Figure Below Shows the Sender
  

The line given below sets the window size for the sender and the receiver.

#define W 5 
If you want you can change the window size to some other value. Currently the window size is 5.

The following lines in the receiver side decides the probability with which a frame fails to reach the destination.

#define P1 50
#define P2 10

You can increase the probability of a frame being corrupted by increasing the value of P2 and decrease the probability by decreasing the value of P2. Currently there is a 20% probability for frame corruption.




In C and C++ typedef is a Storage Class Specifier


  Consider the program given below.

#include<stdio.h>
int main()
{
   typedef static int i;
   i a = 0;
   printf("%d", a);
   return 0;
}


The program when compiled as C or C++ will give you the following error "multiple storage classes in declaration specifiers". The error tells us that typedef in C and C++ is treated as a storage class specifier and this leads to the error since it is not allowed to use two storage class specifiers with a variable.

The C Reference Manual says "The typedef specifier does not reserve storage and is called a storage class specifier only for syntactic convenience".