PROGRAM 2&3.tcl
PROGRAM 2&3.tcl
PROGRAM 2&3.tcl
2.Implement simple ESS and with transmitting nodes in wire-less LAN by simulation
and determine the throughput with respect to transmission of packets.
# Create nodes
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
# initial state
$ns at 0.0 "$n0 setdest 10 10 15"
$ns at 0.0 "$n1 setdest 100 100 15"
$ns at 0.0 "$n2 setdest 400 400 15"
# move n1 near to node n2 at 50s and come back near to node n0 at 100s
$ns at 50 "$n1 setdest 300 300 15"
$ns at 100 "$n1 setdest 100 100 15"
proc finish { } {
global ns nf tf
$ns flush-trace
exec nam out.nam &
close $tf
set ctr1 0
set ctr2 0
set tf [open out.tr r]
# schedule events
PROGRAM 3
#include<stdio.h>
int rem(int,int);
void main()
{
int i,j,k,d,dl;
int data[10],div[5],newdata[15],crc[5],datacrc[15],revdata[15],remd[5];
printf("\n Enter the data length= ");
scanf("%d",&d);
printf("\n Enter the divisor length= ");
scanf("%d",&dl);
printf("\n Enter the data : ");
for(i=0;i<d;i++)
scanf("%d",&data[i]);
printf("\n Enter the divisor : ");
for(i=0;i<dl;i++)
scanf("%d",&div[i]);
printf("\n The new data is : ");
for(i=0;i<(d+dl-1);i++)
{
if(i<d)
newdata[i]=data[i];
else
newdata[i]=0;
printf("%d",newdata[i]);
}
for(j=0;j<=d;j++)
{
for(i=0;i<dl;i++)
{
crc[i]=newdata[i+j];
if(crc[0]==1)
newdata[i+j]=rem(newdata[i+j],div[i]);
else
newdata[i+j]=rem(newdata[i+j],0);
}
printf("\n The Crc is : ");
for(i=0;i<dl-1;i++)
printf("%d",crc[i]);
}
OUTPUT
The reminder is : 1
The reminder is : 1
The reminder is : 0
The reminder is : 1
The reminder is : 1
There is error found.