19EC412 Networks Manual
19EC412 Networks Manual
LAB MANUAL
1
LIST OF EXPERIMENTS:
2
INDEX
3
CYCLE–I EXPERIMENTS
4
EXPT.NO: 1
DATE:
AIM:
To simulate a network with Topology, using Cisco Packet Tracer and to verify the connectivity between
computer using ICMP.
EQUIPMENTS REQUIRED:
Desktop computer
Cisco Packet Tracer 5.0 Software.
IP ASSIGNMENT:
PROCEDURE:
5
IP CONNECTIVITY TABLE:
NETWORK DIAGRAM:
6
Example:
C:\ping 172.17.80.1
To Display IP to Physical address Translation Table and trace the route
i) Arp Command
Syntax:
C:\arp –a
(ii)To trace the route
Syntax:
C:\tracert <ipaddress (or) specific address>
Example:
C:\tracert 172.17.80.1
C:\tracert www.saveetha.ac.in
RESULT:
Thus, the computers in same network are able to communicate with each other and the communication
between computers is verified.
7
EXPT.NO: 2
DATE:
AIM:
To connect computers in multiple networks using Distance Vector Routing Protocol and to verify the
connectivity between computers.
EQUIPMENTS REQUIRED:
IP ASSIGNMENT:
8
NETWORK DIAGRAM:
PROCEDURE:
ROUTER CONFIGURATION:
Command: ROUTER0
Router >enable
Router#config
Router(config)#interface fast Ethernet 0/0
Router(config-if)#no shutdown
Router(config-if)#ip address
Router(config-if)#exit
Router(config)#interface serial 2/0
Router(config-if)#no shutdown
Router(config-if)#ip address
Command: ROUTER1
Router >enable
Router#config
Router(config)#interface fast Ethernet 0/0
Router(config-if)#no shutdown
Router(config-if)#ip address
Router(config-if)#exit
Router(config)#interface serial 2/0
Router(config-if)#no shutdown
Router(config-if)#ip address
Router(config-if)#exit
///////////////////////////////////////////////////configuring RIP////////////////////////////////////////////////////////
Router(config)#router rip
Router(config-router)#network
Router(config-router)#network
Router(config)#exit
////////////////////////////////////////////////End configuring RIP//////////////////////////////////////////////////////
Router#show ip address
RESULT:
Thus, the computers in multiple networks using Distance Vector Routing Protocol is connected and the
connectivity between the computers is verified.
10
EXPT.NO: 3
DATE:
AIM:
To connect computers in multiple networks using Open Shortest Path First Routing Protocol and to verify
the connectivity between computers.
EQUIPMENTS REQUIRED:
IP ASSIGNMENT:
11
NETWORK DIAGRAM:
PROCEDURE:
ROUTER CONFIGURATION:
Chennai (config-router)#end
RESULT:
Thus, the computers in multiple networks using Open Shortest Path First Routing Protocol is connected
and the connectivity between the computers is verified.
13
EXPT.NO: 4
DATE:
To create and monitor Bus Topology and effective data transmission using NS2 Software.
APPARATUS REQUIRED:
ALGORITHM:
PROGRAM:
BUS
#Create a simulator object
set ns [new Simulator]
#Open the nam trace file
set nf [open out.nam w]
$ns namtrace-all $nf
#Define a 'finish' procedure
proc finish {} {
global ns nf
$ns flush-trace
#Close the trace file
close $nf
#Execute nam on the trace file
exec nam out.nam &
exit 0
14
}
#Create five nodes
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
set n4 [$ns node]
#Create Lan between the nodes
set lan0 [$ns newLan "$n0 $n1 $n2 $n3 $n4" 0.5Mb 40ms LL Queue/DropTail MAC/Csma/Cd
Channel]
#Create a TCP agent and attach it to node n0
set tcp0 [new Agent/TCP]
$tcp0 set class_ 1
$ns attach-agent $n1 $tcp0
#Create a TCP Sink agent (a traffic sink) for TCP and attach it to node n3
set sink0 [new Agent/TCPSink]
$ns attach-agent $n3 $sink0
#Connect the traffic sources with the traffic sink
$ns connect $tcp0 $sink0
# Create a CBR traffic source and attach it to tcp0
set cbr0 [new Application/Traffic/CBR]
$cbr0 set packetSize_ 500
$cbr0 set interval_ 0.01
$cbr0 attach-agent $tcp0
#Schedule events for the CBR agents
$ns at 0.5 "$cbr0 start"
$ns at 4.5 "$cbr0 stop"
#Call the finish procedure after 5 seconds of simulation time
$ns at 5.0 "finish"
#Run the simulation
$ns run
RESULT:
Thus, the Bus, Topology using NS2 software is created and monitored.
15
EXPT.NO: 5
DATE:
AIM:
To write a NS2 program to Study the performance of the network with Carrier Sense Multiple
Access/Collision Detection
.
APPARATUS REQUIRED:
ALGORITHM:
PROGRAM:
RESULT:
Thus, the NS2 program to Study the performance of the network with Carrier Sense Multiple
Access/Collision Detection is written.
18
EX.NO:6
DATE
AIM:
To implement stop and wait protocol using NS2 program.
EQUIPMENTS REQUIRED:
1. PC with ubuntu operating system
2. NS2 Software
ALGORITHM:
Step 1: Start the program.
Step 2: Declare the global variables ns for creating a new simulator.
Step 3: Open the network animator file in the write mode.
Step 4: Open the trace file in the write mode.
Step 5: Transfer the packets in network.
Step 6: Create the capable no of nodes.
Step 7: Create the duplex-link between the nodes including the delay time, bandwidth and dropping queue
mechanism.
Step 8: Set a tcp connection for source node.
Step 9: Set the destination node using tcp sink.
Step 10: Set the window size and the packet size for the tcp.
Step 11: Set up the ftp over the tcp connection.
Step 12: Define the plot window and finish procedure.
Step 13: In the definition of the finish procedure declare the global variables.
Step 14: Close the trace file and namfile and execute the network animation file.
Step 15: At the particular time call the finish procedure.
Step 16: Stop the program.
PROGRAM:
set ns [new Simulator]
set namfile [open out.nam w]
$ns namtrace-all $namfile
proc finish {} {
global ns namfile
$ns flush-trace
close $namfile
exec nam out.nam &
exit 0
}
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
$ns duplex-link $n0 $n1 2Mb 200ms DropTail
$ns duplex-link $n1 $n2 2Mb 10ms DropTail
$ns duplex-link $n2 $n3 2Mb 10ms DropTail
$ns queue-limit $n0 $n1 15
19
set tcp [new Agent/TCP]
$tcp set window_ 1
$tcp set maxcwnd_ 1
$ns attach-agent $n0 $tcp
set sink [new Agent/TCPSink]
set sink [new Agent/TCPSink]
$ns attach-agent $n1 $sink
$ns connect $tcp $sink
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ns add-agent-trace $tcp tcp
#$ns moniter-agent-trace $tcp
$tcp tracevar cwnd_
$ns at 0.1 "$ftp start"
$ns at 3.0 "$ns detach-agent $n0 $tcp ; $ns detach-agent $n1 $sink"
$ns at 3.5 "finish"
$ns at 0.0 "$ns trace-annotate \"Stop and Wait with normal operation\""
$ns at 0.05 "$ns trace-annotate \"FTP starts at 0.1\""
$ns at 0.11 "$ns trace-annotate \"Send Packet_0\""
$ns at 0.35 "$ns trace-annotate \"Recive Ack_0\""
$ns at 0.56 "$ns trace-annotate \"Send Packet_1\""
$ns at 0.79 "$ns trace-annotate \"Recive Ack_1\""
$ns at 0.99 "$ns trace-annotate \"Send Packet_2\""
$ns at 1.23 "$ns trace-annotate \"Recive Ack_2\""
$ns at 1.43 "$ns trace-annotate \"Send Packet_3\""
$ns at 1.67 "$ns trace-annotate \"Recive Ack_3\""
212215106298
$ns at 1.88 "$ns trace-annotate \"Send Packet_4\""
$ns at 2.11 "$ns trace-annotate \"Recive Ack_4\""
$ns at 2.32 "$ns trace-annotate \"Send Packet_5\""
$ns at 2.55 "$ns trace-annotate \"Recive Ack_5\""
$ns at 2.75 "$ns trace-annotate \"Send Packet_6\""
$ns at 2.99 "$ns trace-annotate \"Recive Ack_6\""
$ns at 3.1 "$ns trace-annotate \"FTP stops\""
$ns at 0.0 "$n0 label Sender"
$ns at 0.0 "$n1 label Reciver"
$ns run
RESULT:
Thus the stop and wait protocol is implemented and the output is executed and verified
successfully.
20
CYCLE–II EXPERIMENTS
21
EX.NO:7
DATE
IMPLEMENTATION OF GO-BACK-N PROTOCOL
AIM:
To write and execute a program for Go-Back-N protocol.
EQUIPMENTS REQUIRED:
Personal Computer
Turbo C Compiler
PROCEDURE:
1. Connect two computers in Wired/Wireless LAN.
2.Make sure that two computers are in one network and could able to ping each other.
3.In the codeblocker open new c file and type the program.
4.In the menu choose->Project->Properties->Project Build options->Linker settings->Add
netproto and pthread.
5. Execute the program in both server and client.
6. Enter the IP address of the remote machine, port address of both local & remote machine and
error rate.
7. Choose the file and verify the go back protocol operation.
PROGRAM:
#include<stdio.h>
/* Assume 7 frames of data are to sent using GO BACK N ARQW*/
void main()
{char frame[8][10];
int i,j;
printf("GO BACK N ARQ\n");
printf("Enter message in format\n");
for(i=1;i<=7;i++)
{
printf("Content for frame %d :",i);
scanf("%s",&frame[i]);
}
printf("Enter frame number with no ACK :");
scanf("%d",&j);
for(i=1;i<=7;i++)
{if(i<j)
printf("\n Sending frame %d \n FRAME ACKNOWLEDGED.....\n",i);
else
printf("\n Frame not Acknowledeged........\n");
}
printf("No Acknowlegement for frame %d ...\n",j);
for(i=j;i<=7;i++)
{
printf("Resending....Content from frame %d :%s\n\n",i,frame[i]);
}
}
22
RESULT:
Thus the Go-Back-N protocol was implemented and the output is verified successfully.
23
EX.NO:8
DATE
RESULT:
Thus a socket program is written to transfer data between client and server.
26
EX.NO:9
DATE
EQUIPMENTS REQUIRED:
1. Personal Computer
2. C++ compiler
ALGORITHM:
1] Open code blocks application and create a new file.
2] After creating the file type the codes.
3] After typing the codes save the file using the .c extension in the desired location.
4] Run the program using build and run.
5] Give polynomial values and the generated polynomial is obtained, and by other means arraive
at the desired output which uses the error detection technique.
6] Thus the output polynomial is obtained through this technique.
PROGRAM:
#include<stdio.h>
#include<string.h>
#define N strlen(g)
char t[128],cs[128],g[]="111";
int a,e,c;
void xor()
{
for(c=1;c<N;c++)
cs[c]=((cs[c]==g[c])?'0':'1');
}
void crc()
{
for(e=0;e<N;e++)
cs[e]=t[e];
212215106298
do{
if(cs[0]=='1')xor();
for(c=0;c<N-1;c++)
cs[c]=cs[c+1];
cs[c]=t[e++];
}
while(e<=a+N-1);
}
void main()
{
printf("\n Enter poly:");
scanf("%s",t);
printf("\nGen poly is : %s",g);
a=strlen(t);
27
for(e=a;e<a+N-1;e++)
t[e]='0';
printf("\nModfied t[u] :%s",t);
crc();
printf("\nChecksum is:%s",cs);
for(e=a;e<a+N-1;e++)
t[e]=cs[e-a];
printf("\nFinal code word is:%s",t);
printf("\nTest error detection 0(yes) 1(no)?:");
scanf("%d",&e);
if(e==0)
{
printf("Enter position where is to inserted");
scanf("%d",&e);
t[e]=(t[e]=='0')?'1':'0';
printf("erroneous data :%s\n",t);
}
crc();
for(e=0;(e<N-1)&&(cs[e]!='1');e++)
if(e<N-1)
printf("Error detected");
else printf("no error detected");
}
RESULT:
Thus the error detection using CRC-CCITT [16 BIT] technique is implemented and the output is
verified successfully.
28
EX.NO:10
DATE
AIM:
To implement encryption and decryption using C program.
EQUIPMENTS REQUIRED:
PROCEDURE:
1] Open code blocks and type the program for encryption and decryption.
2] Save the program using extension .c
3] Run the program using build and run.
4] Prime number is given as input. If it is not a prime number then wrong input is displayed.
5] Then a message is entered.
6] The encrypted form of the message is displayed.
7] The decrypted form is also displayed as final output.
8] Thus the output is obtained.
PROGRAM:
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
longintp,q,n,t,flag,e[100],d[100],temp[100],j,m[100],en[100],i;
char msg[100];
int prime(longint);
void ce();
long int cd(longint);
void encrypt();
void decrypt();
void main()
{
printf("\nENTERFIRSTPRIMENUMBER\n");
scanf("%d",&p);
flag=prime(p);
if(flag=0)
{
printf("\nWRONGINPUT\n");
exit(1);
}
printf("\nENTERANOTHERPRIMENUMBER\n");
scanf("%d",&q);
flag=prime(q);
if(flag==0||p==q)
{
printf("\nWRONGINPUT\n");
29
exit(1);
}
printf("\nENTERMESSAGE\n");
fflush(stdin);
scanf("%s",msg);
for(i=0;msg[i]!=NULL;i++)
m[i]=msg[i];
n=p*q;
t=(p-1)*(q-1);
ce();
212215106298
printf("\nPOSSIBLEVALUESOFeANDdARE\n");
for(i=0;i<j-1;i++)
printf("\n%ld\t%ld",e[i],d[i]);
encrypt();
decrypt();
}
int prime(long int pr)
{
int i;
j=sqrt(pr);
for(i=2;i<=j;i++)
{
if(pr%i==0)return0;
}
return1;
}
Void ce()
{
int k;
k=0;
for(i=2;i<t;i++)
{
if(t%i==0)
continue;
flag=prime(i);
if(flag==1&&i!=p&&i!=q)
{
e[k]=i;
flag=cd(e[k]);
if(flag>0)
{
d[k]=flag;
k++;
}
if(k==99)break;
}
}
}
long int cd(long int x)
30
{
long int k=1;
while(1)
{
k=k+t;
if(k%x==0)return(k/x);
}
}
void encrypt()
{
longintpt,ct,key=e[0],k,len;
i=0;
len=strlen(msg);
while(i!=len)
{
pt=m[i];pt=pt-96;
k=1;
for(j=0;j<key;j++)
{
k=k*pt;
k=k%n;
}
temp[i]=k;
ct=k+96;
en[i]=ct;
212215106298
i++;
}
en[i]=-1;
printf("\nTHEENCRYPTEDMESSAGEIS\n");
for(i=0;en[i]!=-1;i++)
printf("%c",en[i]);
}
void decrypt()
{
long int pt,ct,key=d[0],k;
i=0;
while(en[i]!=-1)
{
ct=temp[i];
k=1;
for(j=0;j<key;j++)
{
k=k*ct;
k=k%n;
}
pt=k+96;m[i]=pt;
i++;
}
m[i]=-1;
31
printf("\nTHEDECRYPTEDMESSAGEIS\n");
for(i=0;m[i]!=-1;i++)
printf("%c",m[i]);
}
RESULT:
Thus the encryption and decryption is implemented and the output is obtained and verified
successfully.
32
EX.NO :11
DATE
AIM:
To study different types of network simulators and Congestion control using NS.
NETWORK SIMULATOR:
A network simulator is software that predicts the behavior of a computer network .Since communication
Networks have become too complex for traditional analytical methods to provide an accurate understanding of
system behavior network simulator are used. In simulators, the computer network is typically modeled with
devices, links, applications etc. and the performance is analyzed. Simulators typically come with support for the
most popular technologies and networks in use today.
SIMULATIONS:
Most of the commercial simulators are GUI driven, while some network simulators are CLI driven. The
network model / configuration describes the state of the network (nodes, routers, switches, and links) and the
events (data transmissions, packet error etc.). An important output of simulations are the trace files. Trace files
log every packet, every event that occurred in the simulation and are used for analysis. Network simulators can
also provide other tools to facilitate visual analysis of trends and potential trouble spots. Most network simulators
use discrete event simulation, in which a list of pending "events" is stored, and those events are processed in
order, with some events triggering future events—such as the event of the arrival of a packet at one node triggering
the event of the arrival of that packet at a downstream node. Simulation of networks is a very complex task. For
example, if congestion is high, then estimation of the average occupancy is challenging because of high variance.
To estimate the likelihood of a buffer overflow in a network, the time required for an accurate answer can be
extremely large. Specialized techniques such as "control variates" and "importance sampling"have been
developed to speed simulation.
NETWORK EMULATION:
A network emulator allows users to introduce real devices and applications into a test network (simulated)
that alters packet flow in such a way as to mimic the behavior of a live network. Live traffic can pass through the
simulator and be affected by objects within the simulation.The typical methodology is that real packets from a
live application reach the emulation server (where the virtual network is simulated. The real packet gets modulated
into a simulation packet.The Simulation packet gets demodulated into real packet after experiencing effects of
loss, errors, delay, jitter etc., thereby transferring these network effects into the real packet. Thus it is as-if the
real packet flowed through the real networks but in reality it flowed through the
simulated network. Emulation is widely used in the design stage for validating communication networks prior to
deployment.
There are a wide variety of network simulators, ranging from the very simple to the very
complex. Minimally, a network simulator must enable a user to
1. Model the network topology specifying the nodes on the network and the links
between those nodes
2. Model the application flow (traffic) between the nodes
3. Providing network performance metrics as output
4. Visualization of the packet flow
5. Logging of packet / events for drill down analyses / debugging.
For each duplicate ACK received, the cwnd is inflated by 1 segment. A segment is transmitted if
allowed by the new value of congestion window and receivers advertised window. When the next ACK arrives
that acknowledges new data, cwnd is set to ssthresh. This is termed as “deflating" the window.
34
RESULT:
Thus different types of network simulators and Congestion control is studied using NS.
35