It Network Lab Manual
It Network Lab Manual
It Network Lab Manual
DEPARTMENT
OF
INFORMATION TECHNOLOGY
NAME :___________________
REG NO :___________________
YEAR :___________________
SEM :___________________
ANNA UNIVERSITY
SAKTHI ENGINEERING COLLEGE
REG
NO:______________
SEM:_______________
This is certified to be the bonafide record of work done by the student in the
CS1305 NETWORK LAB of Sakthi Engineering College during
Jan’ 09 to may’ 09.
PAGE
EXPNO DATE EXPERIMENT NAME SIGNATURE
NO
1 LINUX COMMANDS
2 SOCKET CREATION
SIMULATION OF
3
ARP/RARP
4 BIT STUFFING
CYCLIC REDUNDANCY
5
CHECK
SIMULATION OF SLIDING
6
WINDOW PROTOCOL
STUDY OF NETWORK
11
SIMULATOR NS2
LINUX COMMANDS
4) cp: This is used to copy content from one file to another file.
Syntax: $cp oldfile newfile
Example: $cp fcfs fc.c
8) wc: This command is used to count the no of words (or) characters in the file.
Syntax: $wc filename
Example: $wc dine.c
10) echo: This command is used to display the string printed in the command line.
Syntax: $echo “string”
Example: $echo “hello”
11)who: This is used to display the information about the current user.
Syntax:$who
12) grep: This is used to display the information about the current user.
Syntax: $grep[option] pattern filename
Example: $cat>count
ab
ac
ba
grep”a” count
ab
ac
14) sort: This command is used to sort the content of the file name.
Syntax: $sort file name
Example: $cat>mm
sa
co
en
$sort mm
Output: co
en
sa
15) read command: This command is used to read the variables.
Syntax: read varname
Example: read a
Result:
Thus the basic Linux commands has been executed and verified.
SOCKET CREATION
AIM:
ALGORITHM:
Thus the c program for implementing socket creation has been executed and verified.
SIMULATION OF ARP/RARP
AIM:
ALGORITHM:
Step 4: Create a file and with that file declare the physical and logical address.
Step 5: Get the choice of operation. If it is ARP show the logical address and if its RARP
display the physical address.
.
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct file
{
char phyadd[30];
char logadd[30];
}f[15];
File *fp
int n;
void arp(char *ladd)
{
int i;
for(i=0;i<n;i++)
{
if(strcmp,(ladd,f[i].logadd))
{
printf("\n corresponding logical address is",f[i].phyadd);
break;
}
if(i==n)
printf("the address is not found");
}
}
void rarp(char *padd)
{
int i;
for(i=0;i<n;i++)
{
if(!strcmp,(padd,f[i].phyadd))
{
printf("\n corresponding physical address is",f[i].logadd);
break;
}
}
if(i==n)
printf("the address is not found");
}
int main()
{
int i=0,ch;
char padd[30],ladd[30];
fp=fopen("data.txt","r");
if(fp=null)
{
pritnf(" \n file not found");
exit(0);
}
while(!feof(fp))
{
fscanf(fp,"%s%s",f[i].phyadd,f[i].logadd);
i++;
}
fclose(fp);
n=i;
while(1);
{
printf("\n 1.ARP \n 2.RARP \n 3.EXIT");
printf(" enter your choice");
scanf("%d",&ch);
switch(ch)
{
case 1:
printf("enter the physical address");
scanf("%s",ladd);
arp(ladd);
break;
case 2:
printf(" enter the logical address");
scanf("%s",padd);
rarp(padd);
break;
case 3:
exit(1);
break;
}
}
return(0);
}
Output:
1. ARP
2. RARP
3. EXIT
AIM:
To write a c program to implement bit stuffing for the given bits of information.
ALGORITHM:
Step 2: Declare the variable and obtain the information size and need it.
Step 3: Create an input file and copy the information into it.
Step 4: Create another file with read mode and check for the condition.
original data:
111111
data after stuffing:
1111101
Result:
Thus the program for bit stuffing is verified and written successfully.
CYCLIC REDUNDANCY CHECK
AIM:
ALGORITHM:
Step 3: Perform the binary division and the CRC remainder is found.
else
{
for(i=0;i<divlen;i++)
{
if(dividend[i]='0')
crc[i]='0';
else
crc[i]='1';
dividend[m]=crc[i];
m++;
}
}
for(k=m;dividend[k]!='\0';k++)
dividend[k]=dividend[k+1];
m=0;
j++;
}
for(j=0;j<divlen-1;j++)
crc[j]=dividend[j];
crc[j]='\0';
printf("\n the crc is: %s",crc);
strcat(orgdiv,crc);
printf("the append data is p: %s",orgdiv);
}
Output:
Thus the program for cyclic redundancy check is verified and written successfully.
SIMULATION OF SLIDING WINDOW PROTOCOL
AIM:
ALGORITHM:
Step 5: Enter the sequence number to be sent and the current sender window.
Thus the program for sliding window protocol is verified and written successfully.
DOMAIN NAME SYSTEM
AIM:
ALGORITHM:
dsp@dsp-desktop:~$ cc dnsser.c
dsp@dsp-desktop:~$ ./a.out
enter the domain name: www.annauniv.edu
ipaddr= 10.0.0.1
dsp@dsp-desktop:~$ cc dnscli.c
dsp@dsp-desktop:~$ ./a.out
Thus the program for domain name system is verified and written successfully.
FTP USING RS232
AIM:
ALGORITHM:
Step 6: If data is send print “data ready”. If not send an error repeat.
Step 7:Display the text that is present in the file name mentioned.
1.sender
2.receiver
3.exit
Data ready
Thus the program for FTP using RS232 is verified and written successfully.
OPEN SHORTEST PATH FIRST ALGORITHM
AIM:
To write a c++ program for open shortest path between server and destination
Node.
ALGORITHM:
Step 4: Get the Number of nodes and the cost of the edge between various nodes.
Step 6: Find the shortest path between source and destination node.
Number of nodes : 3
1.shortest path
2.exit
Choice……….. 1
Choice……….. 2
Result:
Thus the program for open shortest path specification is verified and written
successfully.
GETTING HOST NAME
AIM:
To write a c program for open shortest path between server and destination
Node.
ALGORITHM:
Step 5: If the host name of the parameter value is equal to NULL then print error
message.
dsp@dsp-desktop:~$ ./a.out
hostname:dsp-desktop
Address[0]: 127.0.0.1
Result:
Thus the program for getting host name is verified and written successfully.
NETWORK SIMULATOR (NS2)
A discrete event simulator targeted at networking research. Ns provides substantial support for
simulation of TCP, routing, and multicast protocols over wired and wireless (local and satellite)
networks. Simulation of protocols (TCP, routing, multicast...) over networks (wireless,
Wired, satellite).
Ns began as a variant of the REAL network simulator in 1989 and have evolved substantially
over the past few years. In 1995 ns development was supported by DARPA through the VINT project
at LBL, Xerox PARC, UCB, and USC/ISI. Currently ns development is support through DARPA with
SAMAN and through NSF with CONSER, both in collaboration with other researchers including
ACIRI. Ns have always included substantial contributions from other researchers, including wireless
code from the UCB Daedelus and CMU Monarch projects and Sun Microsystems. For documentation
on recent changes, see the version 2 change log.
While we have considerable confidence in ns, ns is not a polished and finished product, but the
result of an on-going effort of research and development. In particular, bugs in the software are still
being discovered and corrected. Users of ns are responsible for verifying for themselves that their
simulations are not invalidated by bugs. We are working to help the user with this by significantly
expanding and automating the validation tests and demos.
Similarly, users are responsible for verifying for themselves that their simulations are not
invalidated because the model implemented in the simulator is not the model that they were expecting.
The ongoing Ns Manual should help in this process.
NS is Object Oriented Tcl (OTcl) script interpreter that has a simulation event scheduler and
network component object libraries, and network setup module libraries. To run a simulation network,
a user should write an OTcl script that initiates an event scheduler, sets up the network topology using
the network objects and the plumbing functions in the library, and tells traffic sources when to start
and stop transmitting packets through the event scheduler. Another major component of NS beside
network objects is the event scheduler. An event is NS is a packet ID that is unique for a packet with
scheduled time and the pointer to an object that handles the event.
All the network components that need to spend some simulation time handling a packet (i.e.
need a delay) use the event scheduler by issuing an event for the packet and waiting for the vent to be
fired to itself before doing further action handling the packet. Another use of an event scheduler is
timer.
It can generally implemented in split language programming using C++ and TCL.
SPLIT-LANGUAGE PROGRAMMING
Ns separate the data path implementation from control path implementations. In order to
reduce packet and event processing time, the event scheduler and the basic network component objects
in the data path are written and compiled using C++.
General, architecture of NS a user can be thought of standing at the left bottom corner,
designing and running simulations in Tcl using the simulator objects in the OTcl library. The event
scheduler and most of the network components are implemented in C++ and available to OTcl through
an OTcl linkage that is implemented using tclcl. When a simulation is finished, NS produces one or
more text-based output that files that contain detailed simulation data. The data can be used for
simulation analysis or as and input to a graphical simulation display too called Network Animator
(NAM) that is developed as a part of VINT project.