You are on page 1of 42

Ex.No: 1.

IMPLEMENTATION OF ERROR DETECTION AND ERROR


CORRECTION USING HAMMING CODE
AIM

To write a c program to implement hamming code.

ALGORITHM

Step1:start the program


Step2:read input binary values
Step3:append parity bit
Step4:read received code bits
Step5:check for errors
Step6:if the bits are received in correct order the print you have received correct code
Step7:else print the single bit error with correct code.

CODING

#include<stdio.h>
#include<math.h>
void main()
{
int i,a[4],c[3],r[7],clk[3],n,sum=0;
printf("Enter data bits\n");
for(i=3;i>=0;i--)
scanf("%d",&a[i]);
printf("\n");
c[0]=(a[0]+a[1]+a[2])%2;
c[1]=(a[1]+a[2]+a[3])%2;
c[2]=(a[1]+a[0]+a[3])%2;
printf("data bits after hamming code is\n");
for(i=3;i>=0;i--)
printf("%d",a[i]);
for(i=2;i>=0;i--)
printf("%d",c[i]);
printf("Enter recieved code\n");
for(i=0;i<7;i++)
scanf("%d",&r[i]);
clk[0]=(r[3]+r[1]+r[2]+r[6])%2;
clk[1]=(r[0]+r[2]+r[1]+r[5])%2;
clk[2]=(r[0]+r[2]+r[3]+r[4])%2;
sum=4*clk[2]+2*clk[1]+1*clk[0];
if(sum==0)
printf("\n u have recivedcoorrect code\n");
if(sum==1)
{
printf("Error in check bit 2\n");
printf("The correct code is");
r[6]=(r[6]+1)%2;
for(i=0;i<7;i++)
printf("%d",r[i]);
}
if(sum==2)
{
printf("Error in check bit 1\n");
printf("The correct code is");
r[5]=(r[5]+1)%2;
for(i=0;i<7;i++)
printf("%d",r[i]);
}
if(sum==3)
{
printf("\nError in data bit 1");
printf("The correct code is");
r[1]=(r[1]+1)%2;
for(i=0;i<7;i++)
printf("%d",r[i]);
}
if(sum==4)
{
printf("\n Error in chect bit 0");
printf("The correct code is");
r[4]=(r[4]+1)%2;
for(i=0;i<7;i++)
printf("%d",r[i]);
}
if(sum==5)
{
printf("\n Error in data bits 3");
printf("The correct code is");
r[3]=(r[3]+1)%2;
for(i=0;i<7;i++)
printf("%d",r[i]);
}
if(sum==6)
{
printf("Error in data bits 0");
printf("The correct code");
r[0]=(r[0]+1)%2;
for(i=0;i<7;i++);
printf("%d",r[i]);
}
if(sum==7)
{
printf("Error in data bits 2");
printf("The correct code is");
r[2]=(r[2]+1)%2;
for(i=0;i<7;i++)
printf("%d",r[i]);
}
}

OUTPUT
Enter data bits
1111
Data bits after hamming code
1111111
Enter received code
1111111
You have received correct code

RESULT

Thus the C program for hamming code can be written and successfully implemented.
Ex.No: 2 IMPLEMENTATION OF STOP AND WAIT
PROTOCOL

AIM

To write a program to simulate stop and wait protocol.

ALGORITHM

Step 1: Start the program.


Step 2: Generate a random that gives the total number of frames to be transmitted.
Step 3: Transmit the first frame.
Step 4: Receive the acknowledgement for the first frame.
Step 5: Transmit the next frame
Step 6: Find the remaining frames to be sent.
Step 7: If an acknowledgement is not received for a particular frame retransmit that frame
alone again.
Step 8: Repeat the steps 5 to 7 till the number of remaining frames to be send becomes zero.
Step 9: Stop the program.

PROGRAM

#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
void main()
{
int i,j,noframes,x,x1=10,x2;
clrscr();
for(i=0;i<200;i++)
rand();
noframes=rand()/200;
i=1;j=1;
noframes = noframes / 8;
printf("\n number of frames is %d",noframes);
getch();
while(noframes>0)
{
printf("\nsending frame %d",i);
srand(x1++);
x = rand()%10;
if(x%2 == 0)
{
for (x2=1; x2<2; x2++)
{
printf("waiting for %d seconds\n", x2);
sleep(x2);
}
printf("\nsending frame %d",i);
srand(x1++);
x = rand()%10;
}
printf("\nack for frame %d",j);
noframes-=1;
i++;
j++;
}
printf("\n end of stop and wait protocol");
getch();
}

OUTPUT

No of frames is 6
Sending frame 1
Acknowledgement for frame 1
Sending frame 2
Acknowledgement for frame 2
Sending frame 3
Acknowledgement for frame 3
Sending frame 4
Acknowledgement for frame 4
Sending frame 5
Waiting for 1 second
Retransmitting frame 5
Acknowledgement for frame 5
Sending frame 6
Waiting for 1 second
Sending frame 6
Acknowledgement for frame 6
End of stop and wait protocol

RESULT
Thus the program for stop and wait protocol can be written and successfully implemented.
Ex.No: 3 IMPLEMENTATION AND STUDY OF GOBACK-N
PROTOCOLS AND SELECTIVE REPEAT PROTOCOL

AIM

To write a program to perform simulation on sliding window protocol.

ALGORITHM – GO BACK N PROTOCOL

Step 1: Start the program.


Step 2: Generate a random that gives the total number of frames to be transmitted.
Step 3: Set the size of the window.
Step 4: Generate a random number less than or equal to the size of the current window and
identify the number of frames to be transmitted at a given time.
Step 5: Transmit the frames and receive the acknowledgement for the frames sent.
Step 6: Find the remaining frames to be sent.
Step 7: Find the current window size.
Step 8: If an acknowledgement is not received for a particular frame retransmit the frames
from that frame again.
Step 9: Repeat the steps 4 to 8 till the number of remaining frames to be send becomes zero.
Step 10: Stop the program.
ALGORITHM – SELECTIVE REPEAT PROTOCOL

Step 1: Start the program.


Step 2: Generate a random that gives the total number of frames to be transmitted.
Step 3: Set the size of the window.
Step 4: Generate a random number less than or equal to the size of the current window and
identify the number of frames to be transmitted at a given time.
Step 5: Transmit the frames and receive the acknowledgement for the frames sent.
Step 6: Find the remaining frames to be sent.
Step 7: Find the current window size.
Step 8: If an acknowledgement is not received for a particular frame retransmit that frame
alone again.
Step 9: Repeat the steps 4 to 8 till the number of remaining frames to be send becomes zero.
Step 10: Stop the program.

CODING: SLIDING WINDOW PROTOCOL (GOBACK-N)

#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
void main()
{
int temp1,temp2,temp3,temp4,i,winsize=8,noframes,moreframes;
char c;
intreciever(int);
int simulate(int);
clrscr();
temp4=0,temp1=0,temp2=0,temp3=0;
for(i=0;i<200;i++)
rand();
noframes=rand()/200;
printf("\n number of frames is %d",noframes);
getch();
moreframes=noframes;
while(moreframes>=0)
{
temp1=simulate(winsize);
winsize-=temp1;
temp4+=temp1;
if(temp4 >noframes)
temp4 = noframes;
for(i=temp3+1;i<=temp4;i++)
printf("\nsending frame %d",i);
getch();
temp2=reciever(temp1);
temp3+=temp2;
if(temp3 >noframes)
temp3 = noframes;
printf("\n acknowledgement for the frames up to %d",temp3);
getch();
moreframes-=temp2;
temp4=temp3;
if(winsize<=0)
winsize=8;
}
printf("\n end of sliding window protocol");
getch();
}
intreciever(int temp1)
{
inti;
for(i=1;i<100;i++)
rand();
i=rand()%temp1;
returni;
}
int simulate(intwinsize)
{
int temp1,i;
for(i=1;i<50;i++)
temp1=rand();
if(temp1==0)
temp1=simulate(winsize);
i = temp1%winsize;
if(i==0)
returnwinsize;
else
return temp1%winsize;
}

OUTPUT

Number of frames: 55
Sending frame 1
Sending frame 2
Sending frame 3
Acknowledgement for the frames upto 0
Sending frame 1
Acknowledgement for the frames upto 0
Sending frame 1
Sending frame 3Sending frame 4
Acknowledgement for the frames upto 4
Acknowledgement for the frames upto 54
Sending frame 55
Acknowledgement for the frames upto 55
End of sliding window protocol

CODING: SLIDING WINDOW PROTOCOL (SELECTIVE REPEAT)

#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
void main()
{
int temp1,temp2,temp3,temp4,temp5,i,winsize=8,noframes,moreframes;
char c;
intreciever(int);
int simulate(int);
intnack(int);
clrscr();
temp4=0,temp1=0,temp2=0,temp3=0,temp5 = 0;
for(i=0;i<200;i++)
rand();
noframes=rand()/200;
printf("\n number of frames is %d",noframes);
getch();
moreframes=noframes;
while(moreframes>=0)
{
temp1=simulate(winsize);
winsize-=temp1;
temp4+=temp1;
if(temp4 >noframes)
temp4 = noframes;
for(i=noframes - moreframes;i<=temp4;i++)
printf("\nsending frame %d",i);
getch();
temp2=reciever(temp1);
temp3+=temp2;
if(temp3 >noframes)
temp3 = noframes;
temp2 = nack(temp1);
temp5+=temp2;
if (temp5 !=0)
{
printf("\n No acknowledgement for the frame %d",temp5);
getch();
for(i=1;i<temp5;i++);
printf("\n Retransmitting frame %d",temp5);
getch();
}
moreframes-=temp1;
if(winsize<=0)
winsize=8;
}
printf("\n end of sliding window protocol Selective Reject");
getch();
}
intreciever(int temp1)
{
inti;
for(i=1;i<100;i++)
rand();
i=rand()%temp1;
returni;
}
intnack(int temp1)
{
inti;
for(i=1;i<100;i++)
rand();
i=rand()%temp1;
returni;
}
int simulate(intwinsize)
{
int temp1,i;
for(i=1;i<50;i++)
temp1=rand();
if(temp1==0)
temp1=simulate(winsize);
i = temp1%winsize;
if(i==0)
returnwinsize;
else
return temp1%winsize; }
OUTPUT

Number of frames: 55

Sending frame 1
Sending frame 2
Sending frame 3
Sending frame 4
No Acknowledgement for the frame 2
Retransmitting frame 2
Sending frame 5
Sending frame 6
No Acknowledgement for the frame 2
Retransmitting frame 2
Sending frame 3
Sending frame 4
No Acknowledgement for the frame 4
.
Sending frame 54
Sending frame 55
End of sliding window protocol

RESULT
Thus the program code to perform sliding window protocol can be implemented successfully.
Ex.No: 4 IMPLEMENTATION OF HIGH LEVEL
DATA LINK CONTROL

AIM
To implement high level data link Control using Cisco Packet Tracer 6.0.1.
INTRODUCTION
High level data link control (HDLC) is a bit oriented code transparent synchronous data link
layer protocol developed by the International Organization for Standardization (ISO).The
Original ISO standards for HDLC are:

 ISO 3309- Frame Structure


 ISO 4335- Elements of Procedure
 ISO 6159- Unbalanced classes of Procedure
 ISO 6256- Balanced Classes of Procedure

The current standard fro HDLC is ISO 13239,which replaces all of those standards.

HDLC provides both connection-oriented and connectionless service.

HDLC can be used for point to multipoint connections, but is now used almost exclusively to
connect one device to another, using what is known as Asynchronous Balanced Mode
(ABM).The Original master-slave modes Normal Response Mode (NRM) and Asynchronous
Response Mode (ARM) are rarely used.

HDLC(High-level Data Link Control) is a group of protocols or rules fr transmitting data


between network points(sometimes called nodes).In HDLC, data is organized into a unit
(called a frame) and sent across a network to a destination that verifies its successful arrival.
The HDLC protocol also manages the flow at which data is sent.

HDLC is one of the most commonly, used protocols in what is layer 2 of the industry
communication reference model called Open Systems Interconnection(OSI).(Layer 1 is the
detailed physical level that involves actually generating and receiving the electronic signals.
Layer 3 is the higher level that has knowledge about the network, including access to router
tables that indicates where to forward or send data. On sending, programming in layer 3
creates a frame that usually contains source and destination network address. HDLC (Layer
2) encapsulated the layer 3 frame, adding data link control information to a new, larger
frame.)

PROCEDURE

1. Open Cisco Packet Tracer Software 6.0.1.


2. Select Routers and place 2Router-2911 in work space.
3. Establish connection between routers by serial connections.
4. Open CLI of routers and execute commands to configure HDLC implementation.
5. Assign IP address and subnet mask for each router.
6. Check the connections using ping command.
7. Display clock rates and details about HDLC encapsulation.
ROUTER – 1
STEP:1

Press RETURN to get started!

Router>enable
Router#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#end
Router#
%SYS-5-CONFIG_I: Configured from console by console
Router#show controllers s0/0/0
Interface Serial0/0/0
Hardware is PowerQUICC MPC860
DCE V.35, clock rate 2000000
idb at 0x81081AC4, driver data structure at 0x81084AC0
SCC Registers:
General [GSMR]=0x2:0x00000000, Protocol-specific [PSMR]=0x8
Events [SCCE]=0x0000, Mask [SCCM]=0x0000, Status [SCCS]=0x00
Transmit on Demand [TODR]=0x0, Data Sync [DSR]=0x7E7E
Interrupt Registers:
Config [CICR]=0x00367F80, Pending [CIPR]=0x0000C000
Mask [CIMR]=0x00200000, In-srv [CISR]=0x00000000
Command register [CR]=0x580
Port A [PADIR]=0x1030, [PAPAR]=0xFFFF
[PAODR]=0x0010, [PADAT]=0xCBFF
Port B [PBDIR]=0x09C0F, [PBPAR]=0x0800E
[PBODR]=0x00000, [PBDAT]=0x3FFFD
Port C [PCDIR]=0x00C, [PCPAR]=0x200
[PCSO]=0xC20, [PCDAT]=0xDF2, [PCINT]=0x00F
Receive Ring
rmd(68012830): status 9000 length 60C address 3B6DAC4
rmd(68012838): status B000 length 60C address 3B6D444
Transmit Ring

Router#

ROUTER – 2
STEP:2

--- System Configuration Dialog ---


Continue with configuration dialog? [yes/no]: NO
Press RETURN to get started!

Router>enable
Router#show controllers s0/0/0
Interface Serial0/0/0
Hardware is PowerQUICC MPC860
DTE V.35 TX and RX clocks detected
idb at 0x81081AC4, driver data structure at 0x81084AC0
SCC Registers:
General [GSMR]=0x2:0x00000000, Protocol-specific [PSMR]=0x8
Events [SCCE]=0x0000, Mask [SCCM]=0x0000, Status [SCCS]=0x00
Transmit on Demand [TODR]=0x0, Data Sync [DSR]=0x7E7E
Interrupt Registers:
Config [CICR]=0x00367F80, Pending [CIPR]=0x0000C000
Mask [CIMR]=0x00200000, In-srv [CISR]=0x00000000
Command register [CR]=0x580
Port A [PADIR]=0x1030, [PAPAR]=0xFFFF
[PAODR]=0x0010, [PADAT]=0xCBFF
Port B [PBDIR]=0x09C0F, [PBPAR]=0x0800E
[PBODR]=0x00000, [PBDAT]=0x3FFFD
Port C [PCDIR]=0x00C, [PCPAR]=0x200
[PCSO]=0xC20, [PCDAT]=0xDF2, [PCINT]=0x00F
Receive Ring
rmd(68012830): status 9000 length 60C address 3B6DAC4
rmd(68012838): status B000 length 60C address 3B6D444
Transmit Ring
tmd(680128B0): status 0 length 0 address 0
tmd(680128B8): status 0 length 0 address 0
tmd(680128C0): status 0 length 0 address 0
tmd(680128C8): status 0 length 0 address 0
tmd(680128D0): status 0 length 0 address 0
tmd(680128D8): status 0 length 0 address 0
tmd(680128E0): status 0 length 0 address 0
tmd(680128E8): status 0 length 0 address 0
tmd(680128F0): status 0 length 0 address 0
tmd(680128F8): status 0 length 0 address 0
tmd(68012900): status 0 length 0 address 0
tmd(68012908): status 0 length 0 address 0
tmd(68012910): status 0 length 0 address 0
tmd(68012918): status 0 length 0 address 0
tmd(68012920): status 0 length 0 address 0
tmd(68012928): status 2000 length 0 address 0

tx_limited=1(2)

SCC GENERAL PARAMETER RAM (at 0x68013C00)


Rx BD Base [RBASE]=0x2830, Fn Code [RFCR]=0x18
Tx BD Base [TBASE]=0x28B0, Fn Code [TFCR]=0x18
Max Rx Buff Len [MRBLR]=1548
Rx State [RSTATE]=0x0, BD Ptr [RBPTR]=0x2830
Tx State [TSTATE]=0x4000, BD Ptr [TBPTR]=0x28B0

SCC HDLC PARAMETER RAM (at 0x68013C38)


CRC Preset [C_PRES]=0xFFFF, Mask [C_MASK]=0xF0B8
Errors: CRC [CRCEC]=0, Aborts [ABTSC]=0, Discards [DISFC]=0
Nonmatch Addr Cntr [NMARC]=0
Retry Count [RETRC]=0
Max Frame Length [MFLR]=1608
Rx Int Threshold [RFTHR]=0, Frame Cnt [RFCNT]=0
User-defined Address 0000/0000/0000/0000
User-defined Address Mask 0x0000

buffer size 1524


PowerQUICC SCC specific errors:
0 input aborts on receiving flag sequence
0 throttles, 0 enables
0 overruns
0 transmitter underruns
0 transmitter CTS losts
0 aborted short frames

Router#

ROUTER – 1
STEP: 3

Router#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#int s0/0/0
Router(config-if)#clock rate ?
Speed (bits per second
1200
2400
4800
9600
19200
38400
56000
64000
72000
125000
128000
148000
250000
500000
800000
1000000
1300000
2000000
4000000
<300-4000000> Choose clockrate from list above
Router(config-if)#clock rate 56000
Router(config-if)#ip address 192.168.32.33 255.255.0.0

Router(config-if)#no shut down

STEP: 4

Router#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#int s0/0/0
Router(config-if)#clock rate ?
Speed (bits per second
1200
2400
4800
9600
19200
38400
56000
64000
72000
125000
128000
148000
250000
500000
800000
1000000
1300000
2000000
4000000
<300-4000000> Choose clockrate from list above
Router(config-if)#clock rate 56000
This command applies only to DCE interfaces
Router(config-if)#ip address 192.168.32.34 255.255.0.0
Router(config-if)#no shut down

Router(config-if)#
%LINK-5-CHANGED: Interface Serial0/0/0, changed state to up

Router(config-if)#do ping
%LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0/0, changed stat
Router(config-if)#do ping 192.168.32.33

Type escape sequence to abort.


Sending 5, 100-byte ICMP Echos to 192.168.32.33, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 31/31/32 ms

Router(config-if)#encapsulation hdlc
Router(config-if)#do sh int s0/0/0
Serial0/0/0 is up, line protocol is up (connected)
Hardware is HD64570
Internet address is 192.168.32.34/16
MTU 1500 bytes, BW 1544 Kbit, DLY 20000 usec,
reliability 255/255, txload 1/255, rxload 1/255
Encapsulation HDLC, loopback not set, keepalive set (10 sec)
Last input never, output never, output hang never
Last clearing of "show interface" counters never
Input queue: 0/75/0 (size/max/drops); Total output drops: 0
Queueing strategy: weighted fair
Output queue: 0/1000/64/0 (size/max total/threshold/drops)
Conversations 0/0/256 (active/max active/max total)
Reserved Conversations 0/0 (allocated/max allocated)
Available Bandwidth 1158 kilobits/sec
5 minute input rate 5 bits/sec, 0 packets/sec
5 minute output rate 5 bits/sec, 0 packets/sec
5 packets input, 640 bytes, 0 no buffer
Received 0 broadcasts, 0 runts, 0 giants, 0 throttles
0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored, 0 abort
5 packets output, 640 bytes, 0 underruns
0 output errors, 0 collisions, 1 interface resets
0 output buffer failures, 0 output buffers swapped out
0 carrier transitions
DCD=up DSR=up DTR=up RTS=up CTS=up
Router(config-if)#

RESULT

Thus the above implementation of High Level Data Link Control using Cisco Packet Tracer
6.0.1 was created successfully.
Ex.No: 5 IMPLEMENTATION OF IP COMMAND SUCH AS PING,
TRACEROUTE, NSLOOKUP

AIM
To implement Ping, Traceroute using cisco packet tracer software and also implement
nslookup using command prompt.

PROCEDURE – PING

1. Open Cisco Packet Tracer Software 6.0.1


2. Select the end devices as Generic pc device (PC0,PC1) and place such end devices in
work space.
3. Select switch, then place switch of type 2950-24 in work space.
4. Establish connection between end devices and switches using Copper-straight through.
5. Configure IP address for all PCs.
6. Check the connections using commands like ping, ipconfig, ipconfig /all.
PROCEDURE - TRACEROUTE
1. Open Cisco Packet Tracer Software 6.0.1
2. Select the end devices as Generic pc device (PC0,PC1) which is act as source and
destination and place such end devices in work space.
3. Select the routers , then place 5 routers of type 2621XM in work space.
4. Establish connection between all routers and connect such end devices to such router
network connection using Copper-straight through.
5. Configure IP address for all PCs.
6. Check the connections using commands like ping, ipconfig, ipconfig /all and traceroute.
7. Simulate the arrangement to get the routers traced.
PROCEDURE - NSLOOKUP
1. Go to start-> Run and Type cmd.
2. Type nslookup <space> website name, then press enter at the command prompt.
3. The address for such website will be displayed.

PING IMPLENTATION
TRACEROUTE IMPLEMENTATION

NSLOOKUP IMPLEMENTATION IN COMMAND PROMPT

RESULT

Thus the implementation of Ping, Traceroute using cisco packet tracer software and then the
implementation of nslookup using command prompt has been done.
Ex.No: 6 IMPLEMENTATION OF IP ADDRESS CONFIGURATION

AIM
To implement IP address Configuration using network simulation software packet tracer
6.0.1.

PROCEDURE

1. Open Cisco Packet Tracer Software 6.0.1.


2. Select the end devices as Generic pc device (PC0, PC1) and place such end devices in
work space.
3. Select the routers , then place such routers of type 1841 in work space.
4. Establish connection between routers and end devices using Copper-cross over.
5. Configure IP address for all PCs, and assign default gateway and subnet mask.
6. IP address configurations can be implemented using commands like ping, ipconfig,
ipconfig /all.
IMPLEMENTATION

Router#config terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#int fa 0/0
Router(config-if)#ip add 192.168.1.1 255.255.255.0
Router(config-if)#no shut
Router(config-if)#ping 192.168.2.2
^
% Invalid input detected at '^' marker.
Router(config-if)#^Z
Router#
%SYS-5-CONFIG_I: Configured from console by console

Router#int fa 0/1
^
% Invalid input detected at '^' marker.
Router#int fa 0/1
^
% Invalid input detected at '^' marker.
Router#enable
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#int fa 0/0
Router(config-if)#ip add 192.168.1.1 255.255.255.0
Router(config-if)#no shut
Router(config-if)#^Z
Router#
%SYS-5-CONFIG_I: Configured from console by console

Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#int fa 0/1
Router(config-if)#ip add 192.168.2.1 255.255.255.0
Router(config-if)#no shut
Router(config-if)#^Z
Router#
%SYS-5-CONFIG_I: Configured from console by console

Router#ping 192.168.2.2

Type escape sequence to abort.


Sending 5, 100-byte ICMP Echos to 192.168.2.2, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 0/0/3 ms

Router#ping 192.168.1.2

Type escape sequence to abort.


Sending 5, 100-byte ICMP Echos to 192.168.1.2, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 0/0/0 ms

Router#ping 192.168.1.2

Type escape sequence to abort.


Sending 5, 100-byte ICMP Echos to 192.168.1.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 0/0/0 ms

Router#ping 192.168.2.2

Type escape sequence to abort.


Sending 5, 100-byte ICMP Echos to 192.168.2.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 0/0/1 ms

Router#
RESULT

Thus the implementation of IP address Configuration using cisco packet tracer software can
be done sucessfully.
Ex.No: 7 CREATE SCENARIO AND STUDY THE PERFORMANCE OF
NETWORK WITH CSMA / CA PROTOCOL AND COMPARISON
WITH CSMA/CD PROTOCOLS

AIM

To Create the scenario and study the performance of network with CSMA/CA PROTOCOL
using Ethernet LAN.

APPARATUS REQUIRED

LTS-01 trainer kit,3 or more computers with win-2k/XP and Ethernet port available on them,
RJ-45 to RJ-45 LAN connecting cables, L-SIM LAN Protocol analyzer and simulator
software.

PROCEDURE

1. Connect three or more computer LAN ports using RJ-45 to RJ-45 LAN connecting cables
provided with the system to LTS-01Star topology ports.
2. Switch on the LTS-01 & Computers.
3. Run L-SIM software on all the computers, one should be server and others should be
client.
4. On the server computer, select type of n/w as LAN
5. On the server computer, select the topology as STAR, select a protocol as CSMA-CA,
click on create network button
6. Remote computer detail will appear on the computer, connected in network, server will
able to see all the clients and all clients will able to see only server
7. Click on the Send RTS button to get your computer into transmitter mode.
8. Select the computer to whom data file is to be transferred, from the load button, previously
stored / selected file information can be loaded
9. File size will appear in the server window, select the packet size, inter packet delay and
click OK
10. Total packets formed for that file will be indicated on computers, same details of the file
will appear on the remote computer to which the file to be transmitted
11. Click on file transfer button to transfer the file
12. File transfer from one computer to another will take place
13. During file transfer process try to get access to transmit file by clicking on send RTS
button, you will be prompted with channel is busy message.
14. Thus collision of two packets transmitted simultaneously from two senders is avoided.
15. File transfer from one computer to another will take place.
16. Multiple file transfer b/w various server client combination should be performed to
observe throughput vs. packets size graph on transmitter computer.
17. Close file transfer window and click ON protocol analyzer and n/w analyzer buttons on
transmitted computer to view details of the log created
18. Under network analyzer window, Click ON graph analyzer button.
19. Calculate throughput and click ON plot graph button
20. Detailed graph of throughput vs. packet size for the total file transfer activity will appear
on graph window
21. The plot can be printed by clicking on print button.
CSMA/CD:

OBJECTIVE

To study CSMA/CD PROTOCOL.

APPARATUS REQUIRED

LTS-01 trainer kit,3 or more computers with win-2k/XP and Ethernet port available on them,
RJ-45 to RJ-45 LAN connecting cables, L-SIM LAN Protocol analyzer and simulator
software.

PROCEDURE

1. Connect three or more computer LAN ports using RJ-45 to RJ-45 LAN connecting cables
provided with the system to LTS-01Star topology ports.
2. Switch on the LTS-01 & Computers.
3. Run L-SIM software on all the computers, one should be server & others should be client.
4. On the server computer, select type of network as LAN.
5. On the server computer, select the topology as STAR, select a protocol as CSMA-CD,
click on create network button.
6. Remote computer detail will appear on the computer, connected in network, server will
able to see all the clients and all clients will able to see only server.
7. Select the computer to whom data file is to be transferred, from the load button, previously
stored / selected file information can be loaded.
8. File size will appear in the server window, select the packet size, inter packet delay and
click OK.
9. Total packets formed for that file will be indicated on computers, same details of the file
will appear on the remote computer to which the file to be transmitted.
10. Click on file transfer button to transfer the file.
11. File transfer from one computer to another will take place.
12. During file transfer process try to send file to same receiver from the computer, file
transfer from second transmitter will also get initiated.
13. When packet from second sender collides with first sender. It will be indicated as
collision packet on server and client1.
14. File from the first sender will resume after some time and second sender file will be kept
on hold till first file transfer gets completed.
15. Once first sender file reached to server, its display is refreshed and server will show
packet status for second sender.
16. Second sender file transfer will also completed and thus collision of two packets
transmitted simultaneously from two senders is detected and cleared.
17. Multiple file transfer between various server client combinations should be performed to
observe throughput Vs packets size graph on transmitter computer.
18. Close file transfer window and click ON protocol analyzer and network analyzer buttons
on transmitted computer to view details of the log created .
19. Under network analyzer window, Click ON graph analyzer button.
20. Calculate throughput and click ON plot graph button.
21. Detailed graph of throughput Vs packet size for the total file transfer activity will appear
on graph window.
22. The plot can be printed by clicking on print button.
PERFORMANCE

CSMA/CD

NETWORK ANALYSER-CSMA-CD
SerialNo FileName FileSize FileNumber
-------------- --------------
New Text
1 Document.txt 1234 1

ReceiverName WorkGroup IPOfReceiver TotalPackets


-------------- -------------- -------------- --------------
ECE-038 WORKGROUP 192.168.5.38 10

Packetlength Timeout Protocol Topology


-------------- --------------
128 1000 CSMA-CD Star

ReceiverMACAddress Port FileSendStartTime FileSendCompleteTime


-------------- -------------- --------------
70-71-BC-CE-84-7A 8000 11:24:2:500 11:24:52:500

TransmissionTime DataRate NoOfResendPacket


--------------
50000 100 0

PROTOCOL ANALYSER-CSMA-CD
WorkGrou
SerialNo FileName FileSize FileNumber ReceiverName p
-------------
-------------- - -------------- --------------
WORKGR
1 New Text Document.txt 1234 1 ECE-038 OUP
WORKGR
2 New Text Document.txt 1234 1 ECE-038 OUP
WORKGR
3 New Text Document.txt 1234 1 ECE-038 OUP
WORKGR
4 New Text Document.txt 1234 1 ECE-038 OUP
WORKGR
5 New Text Document.txt 1234 1 ECE-038 OUP
WORKGR
6 New Text Document.txt 1234 1 ECE-038 OUP
7 New Text Document.txt 1234 1 ECE-038 WORKGR
OUP
WORKGR
8 New Text Document.txt 1234 1 ECE-038 OUP
WORKGR
9 New Text Document.txt 1234 1 ECE-038 OUP
WORKGR
10 New Text Document.txt 1234 1 ECE-038 OUP

IPOfReceiv TotalPack
er CurrentPacket ets Packetlength Delay Protocol
-------------
-------------- - --------------
192.168.5.
38 1 10 128 1000 CSMA-CD
192.168.5.
38 2 10 128 1000 CSMA-CD
192.168.5.
38 3 10 128 1000 CSMA-CD
192.168.5.
38 4 10 128 1000 CSMA-CD
192.168.5.
38 5 10 128 1000 CSMA-CD
192.168.5.
38 6 10 128 1000 CSMA-CD
192.168.5.
38 7 10 128 1000 CSMA-CD
192.168.5.
38 8 10 128 1000 CSMA-CD
192.168.5.
38 9 10 128 1000 CSMA-CD
192.168.5.
38 10 10 128 1000 CSMA-CD

PacketSendTi ACKReceiveTim InterPacke


Topology ReceiverMACAddress Port me e tDelay
-------------- -------------- -------------- -------------- --------------
Star 70-71-BC-CE-84-7A 8000 11:24:2:500 11:24:4:609 2109
Star 70-71-BC-CE-84-7A 8000 11:24:7:609 11:24:9:718 2109
Star 70-71-BC-CE-84-7A 8000 11:24:12:875 11:24:14:984 2109
Star 70-71-BC-CE-84-7A 8000 11:24:18:0 11:24:20:109 2109
Star 70-71-BC-CE-84-7A 8000 11:24:23:218 11:24:25:328 2110
Star 70-71-BC-CE-84-7A 8000 11:24:28:453 11:24:30:562 2109
Star 70-71-BC-CE-84-7A 8000 11:24:33:984 11:24:36:93 2109
Star 70-71-BC-CE-84-7A 8000 11:24:39:468 11:24:41:578 2110
Star 70-71-BC-CE-84-7A 8000 11:24:44:937 11:24:47:46 2109
Star 70-71-BC-CE-84-7A 8000 11:24:50:390 11:24:52:500 2110

DataRate NoOfResendPacket ACKValue WindowSize


-------------
-------------- - --------------
100 0 Success NA
100 0 Success NA
100 0 Success NA
100 0 Success NA
100 0 Success NA
100 0 Success NA
100 0 Success NA
100 0 Success NA
100 0 Success NA
100 0 Success NA
CSMA/CA
NETWORK ANALYSER-CSMA-CA

SerialNo FileName FileSize FileNumber ReceiverName


-------------- -------------- --------------
1 kmsd].txt 11 1 ECE-038

WorkGroup IPOfReceiver TotalPackets Packetlength Timeout


-------------- -------------- --------------
WORKGROUP 192.168.5.38 1 128 1000

Protocol Topology ReceiverMACAddress Port


-------------- -------------- --------------
CSMA-CA Star 70-71-BC-CE-84-7A 8000

FileSendStartTime FileSendCompleteTime TransmissionTime


-------------- --------------
11:45:14:765 11:45:16:875 2110

DataRate NoOfResendPacket
--------------
100 0
PROTOCOL ANALYSER-CSMA-CA

SerialNo FileName FileSize FileNumber ReceiverName WorkGroup


-------------- -------------- -------------- --------------
1 kmsd].txt 11 1 ECE-038 WORKGROUP

IPOfReceiver CurrentPacket TotalPackets Packetlength Delay Protocol


-------------- -------------- --------------
192.168.5.38 1 1 128 1000 CSMA-CA

Topology ReceiverMACAddress Port PacketSendTime ACKReceiveTime


-------------- -------------- -------------- --------------
Star 70-71-BC-CE-84-7A 8000 11:45:14:765 11:45:16:875

InterPacketDela
y DataRate NoOfResendPacket ACKValue WindowSize
-------------- -------------- -------------- --------------
2110 100 0 Success NA

RESULT
Thus CSMA/CD PROTOCOL is implemented successfully.

Ex.No: 8 IMPLEMENTATION OF NETWORK TOPOLOGY –


STAR, BUS, RING

AIM

To implement star, bus and ring topologies using cisco packet tracer 6.0.1 software.

PROCEDURE – RING TOPOLOGY

1. Open Cisco Packet Tracer Software 6.0.1


2. Select Switches and place 5 switches of type 2950-24 in work space.
3. From the end devices select 5 Generic pc devices, place near to the respective switches.
4. Make it as a Ring Topology fashion.
5. Establish connection between all the components by selecting connections.
6. Configure IP address for all PCs, and assign default gateway and subnet mask.
7. Check the connections using message packets, commands like ping, ipconfig, ipconfig
/all.
8. Simulate the ring topology by transmitting packets between PCs.
PROCEDURE – BUS TOPOLOGY
1. Open Cisco Packet Tracer Software 6.0.1
2. Select Switches and place 3 switches of type 2950-24 in work space.
3. From the end devices select 3 Generic pc devices, place near to the respective switches.
4. Make it as a Bus Topology fashion.
5. Establish connection between all the components by selecting connections Fast Ethernet
cables.
6. Configure IP address for all PCs, and assign default gateway and subnet mask.
7. Check the connections using message packets, commands like ping, ipconfig, ipconfig
/all.
8. Simulate the Bus topology by transmitting packets between PCs.
PROCEDURE – STAR TOPOLOGY
1. Open Cisco Packet Tracer Software 6.0.1
2. Select Switches and place it as a centralized switch of type 2950-24 in work space.
3. From the end devices select 5 Generic pc devices, place near to the respective switches.
4. Make it as a Star Topology fashion.
5. Establish connection between all the components by selecting connections Fast Ethernet
cables.
6. Configure IP address for all PCs, and assign default gateway and subnet mask.
7. Check the connections using message packets, commands like ping, ipconfig, ipconfig
/all.
8. Simulate the star topology by transmitting packets between PCs.
RING TOPOLOGY

BUS

STAR

RESULT
Thus the implementation of star, bus and ring topologies using cisco packet tracer 6.0.1
software has been successfully done.
Ex.No: 9 IMPLEMENTATION OF DISTANCE VECTOR ROUTING
ALGORITHM

AIM
To implement the distance vector routing algorithm.

ALGORITHM

1. Start
2. By convention, the distance of the node to itself is assigned to zero and when a node
is unreachable the distance is accepted as 999.
3. Accept the input distance matrix from the user (dm[][]) that represents the distance
between each node in the network.
4. Store the distance between nodes in a suitable variable.
5. Calculate the minimum distance between two nodes by iterating.
o If the distance between two nodes is larger than the calculated alternate
available path, replace the existing distance with the calculated distance.
6. Print the shortest path calculated.
7. Stop.

IMPLEMENTATION

RESULT
Thus the distance vector routing algorithm has been implemented.

Ex.No: 10 IMPLEMENTATION OF LINK STATE ROUTING


ALGORITHM

AIM
To implement the Link State Routing Algorithm.
ALGORITHM
1. Start the program
2. Declare the needed variables
3. Read number of nodes
4. Read the distance of each node in matrix .
5. Calculate minimum distance for each node
6. Print each node with its distance when cost !=0 and cost !=-1 for packet transmission.
7. Stop the program
IMPLEMENTATION

RESULT
Thus the Link State Routing Algorithm has been implemented.

Ex.No: 11 STUDY OF NETWORK SIMULATOR (NS) AND SIMULATION


OF CONGESTION DATE:CONTROL ALGORITHMS USING NS

AIM
To study about OPNET - Network Simulator

INTRODUCTION

OPNET (Optimized Network Engineering Tools) is a commercial tool from MIL3


Inc. It is being developed for almost 15 years. As everyone should guess, no much technical
detail are available about the internals.

USE

Network with several hundreds of nodes can be simulated, but it would take time for
the computation. OPNET is used by companies like Thomson-CSF or CNET which use it to
model ATM networks and validate various layers protocols, packet switched radio
networks. An example of use of OPNET is George Mason University (Quality of Service IP
Network Simulation).

THE PACKAGE

The software comprises several tools and is divided in several parts, OPNET
Modeler and OPNET Planner, the Model Library, and the Analysis tool. Features
included in this generic simulator are an event-driven scheduled simulation kernel,
integrated analysis tools for interpreting and synthesizing output data, graphical
specification of models and a hierarchical object-based modeling.

OPNET Modeler is intended for modeling, simulating and analyzing the performance
of large communications networks, computer systems and applications. Common uses are
assessing and feasibility of new designs, optimizing already developed communication
systems and predicting performance.

The modeling methodology of OPNET is organized in a hierarchical structure. At the


lowest level, Process models are structured as a finite state machine. State and transitions are
specified graphically using state-transition diagrams whereas conditions that specify what
happen within each state are programmed with a C-like language called Proto-C. Those
processes and built-in modules in OPNET (source and destination modules, traffic generators
and queues) are then configured with menus and organized into data flow diagrams that
represent nodes using the graphical Node Editor. Using a graphical Network Editor, nodes
and links are selected to build up the topology of a communication network.

The Analysis Tool provides a graphical environment to view and manipulate data
collected during simulation runs. Results can be analyzed for any network element.

OPNET Planner is an application that allows administrators to evaluate the


performance of communications networks and distributed systems, without programming or
compiling. Planner analyses behavior and performance by discrete-event simulations.
Models are built using a graphical interface. The user only chooses pre-defined models (from
the physical layer to the application) from the library and sets attributes. The user cannot
define new models, he should contact MIL3's modeling service.

The modeling libraries are included with OPNET Modeler and OPNET Planner
and contains protocols and analysis environments, among them ATM, TCP, IP, Frame
Relay, FDDI, Ethernet, link models such as point-to-point or bus, queueing service
disciplines such as First-in-First-Out (FIFO), Last-In-First-Out (LIFO), priority non-
preemptive queueing, shortest first job, round-robin or preempt and resume.

OPNET Modeler is the industry's leading environment for network modeling and
simulation, allowing you to design and study communication networks, devices, protocols,
and applications with unmatched flexibility and scalability. Modeler is used by the world's
largest network equipment manufacturers to accelerate the R&D of network devices and
technologies such as VoIP, TCP, OSPFv3, MPLS, IPv6, and more.

Networking technology has become too complex for traditional analytical


methods or "rules of thumb" to yield an accurate understanding of system behavior.

Since 1986, OPNET Technologies Inc., has been the leader in developing predictive
software solutions for networking professionals. OPNET software enables its users to
optimize the performance and maximize the availability of communications networks and
applications.

OPNET is the state-of-art network simulation tool for modeling, simulating and analysing the
performance of
i. Communication Networks, Distributed Systems

ii. Computer systems and Applications.


Product modules provide value-added capabilities to OPNET's intelligent network
management software. Modules span a wide range of applications and receive regular
updates under OPNET's maintenance program.

OPNET MODULES:
 Modeler
 Terrain Modeling Module (TMM)
 High Level Architecture (HLA)

MODELER:

OPNET Modeler is intended for modeling, simulating and analysing the performance
of large communications networks, computer systems and applications. Common uses are
assessing and feasibility of new designs, optimizing already developed communication
systems and predicting performance.
The modeling methodology of OPNET is organized in a hierarchical structure. At the
lowest level, Process models are structured as a finite state machine. State and transitions are
specified graphically using state-transition diagrams whereas conditions that specify what
happen within each state are programmed with a C-like language called Proto-C. Those
processes, and built-in modules in OPNET (source and destination modules, traffic
generators, queues, ...) are then configured with menus and organized into data flow
diagrams that represent nodes using the graphical Node Editor. Using a graphical Network
Editor, nodes and links are selected to build up the topology of a communication network.

TERRAIN MODELING MODULE (TMM)

Building on the capabilities of OPNET's Wireless Module, the Terrain Modeling


Module provides the next level of accuracy and control for wireless network design and
planning. This module allows you to model environmental effects on wireless network
communications anywhere.
Featuring an open-source Longley-Rice model, the Terrain Modeling Module is ready
to replicate any known atmospheric or topological conditions and their combined impact on
signal propagation. Create elevation maps, line-of-sight profiles, and signal-power
comparisons of mobile network models. Interfaces to read DTED and USGS DEM terrain
data are provided. Open and flexible, the Terrain Modeling Module is supported by the
standard Radio Transceiver Pipeline, which enables easy implementation of custom
propagation models

HIGH LEVEL ARCHITECTURE (HLA)

The High-Level Architecture (HLA) Module supports building and running a


federation of many simulators, each modeling some aspect of a composite system. The
OPNET HLA Module enables OPNET simulations to model some portion (or the entirety)
of the communications aspects of the HLA federation models. The OPNET-HLA interface
provides the various simulators (federates) the necessary mechanisms to share a common
object representation (for persistent elements), to exchange messages (interactions), and to
maintain appropriate time synchronization.
The module supports a large subset of the HLA interface, including:

 Time management such that an OPNET simulation remains synchronized with


overall HLA time
 Generation and reception of RTI interactions using OPNET packet
 Creation, destruction, or discovery of RTI objects during the simulation
 Generation of RTI object attribute updates based on changes to OPNET attribute
values
 Automatic updates of OPNET attributes upon reception of RTI object attribute
updates
 A user-defined mapping specifying the relation between RTI and OPNET objects

RESULT

Thus the Network Simulator-OPNET has been studied.

Ex.No: 12 IMPLEMENTATION OF ENCRYPTION


AND DECRYPTION
AIM

To implement the encryption and decryption process.

ALGORITHM

1. start the program


2. Declare the necessary variables
3. read key values to be converted
4. read the message to be encrypted and decrypted
5. convert the given message into lower case letter if it is in uppercase using tolower
function
6. encrypt the given message using substitution cipher method
7. decrypt the cipher text into original message using ascii values
8. display the encrypted and decrypted messages as output
9. stop the program

CODING: ENCRYPTION
#include<stdio.h>
int main()
{
FILE *fp1, *fp2;
charch;
fp1 = fopen("message.txt","r");
if(fp1 == NULL)
{
printf("Source File Could Not Be Found\n");
}
fp2 = fopen("encypted.txt","w");
if(fp2 == NULL)
{
printf("Target File Could Not Be Found\n");
}
while(1)
{
ch = fgetc(fp1);
if(ch == EOF)
{
printf("\nEnd Of File\n");
break;
}
else
{
ch = ch - (8 * 5 - 3);
fputc(ch, fp2);
}
}
fclose(fp1);
fclose(fp2);
printf("\n");
return 0;
}
CODING: DECRYPTION

#include<stdio.h>
int main()
{
FILE *fp1, *fp2;
charch;
fp1 = fopen("encypted.txt","r");
if(fp1 == NULL)
{
printf("File 1 Not Found\n");
}
fp2 = fopen("decrypted.txt","w");
if(fp1 == NULL)
{
printf("File 2 Not Found\n");
}
while(1)
{
ch = fgetc(fp1);
if(ch == EOF)
{
printf("\nEnd Of File\n");
break;
}
else
{
ch = ch + (8 * 5 - 3);
fputc(ch, fp2);
}
}
fclose(fp1);
fclose(fp2);
printf("\n");
return 0;
}

Output
Enter message
hello
Encrypted message is
lipps
Retrieved message is
hello

RESULT
Thus the implementation of encryption and decryption can be performed successfully.

Ex.No: 13 TO CREATE WIRLESS NETWORKING MODEL USING TOOL


COMMAND LANGUAGE SCRIPT
AIM

The wireless networking model can be created using Tool Command Language
(TCL) script with fixed number of nodes. The sample code discussed below models the
wireless network with 2 nodes. Nodes are configured with the components of channel,
networking interface, radio propagation model, Medium Access Control (MAC) protocol,
adhoc routing protocol, interface queue, link layer, topography object, and antenna type.
The wireless network with 2 nodes can be viewed in the Network Animator (NAM)
window after executing the file sample1.tc

PROGRAM:

#Filename: sample1.tcl

#TCL – Tool Command Language

# Simulator Instance Creation


set ns [new Simulator]

#Fixing the co-ordinate of simutaion area


set val(x) 500
set val(y) 500
# Define options
set val(chan) Channel/WirelessChannel ;# channel type
set val(prop) Propagation/TwoRayGround ;# radio-propagation model

set val(netif) Phy/WirelessPhy ;# network interface type


set val(mac) Mac/802_11 ;# MAC type
set val(ifq) Queue/DropTail/PriQueue ;# interface queue type
set val(ll) LL ;# link layer type
set val(ant) Antenna/OmniAntenna ;# antenna model
set val(ifqlen) 50 ;# max packet in ifq
set val(nn) 2 ;# number of mobilenodes
set val(rp) AODV ;# routing protocol
set val(x) 500 ;# X dimension of topography
set val(y) 400 ;# Y dimension of topography
set val(stop) 10.0 ;# time of simulation end

# set up topography object


set topo [new Topography]
$topo load_flatgrid $val(x) $val(y)

#Nam File Creation nam – network animator


set namfile [open sample1.nam w]

#Tracing all the events and cofiguration


$ns namtrace-all-wireless $namfile $val(x) $val(y)
#Trace File creation
set tracefile [open sample1.tr w]

#Tracing all the events and cofiguration


$ns trace-all $tracefile

# general operational descriptor- storing the hop details in the network


create-god $val(nn)

# configure the nodes


$ns node-config -adhocRouting $val(rp) \
-llType $val(ll) \
-macType $val(mac) \
-ifqType $val(ifq) \
-ifqLen $val(ifqlen) \
-antType $val(ant) \
-propType $val(prop) \
-phyType $val(netif) \
-channelType $val(chan) \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace OFF \
-movementTrace ON

# Node Creation
set node1 [$ns node]
# Initial color of the node
$node1 color black

#Location fixing for a single node


$node1 set X_ 200
$node1 set Y_ 100
$node1 set Z_ 0

set node2 [$ns node]


$node2 color black

$node2 set X_ 200


$node2 set Y_ 300
$node2 set Z_ 0
# Label and coloring
$ns at 0.1 "$node1 color blue"
$ns at 0.1 "$node1 label Node1"
$ns at 0.1 "$node2 label Node2"
#Size of the node
$ns initial_node_pos $node1 30
$ns initial_node_pos $node2 30
# ending nam and the simulation
$ns at $val(stop) "$ns nam-end-wireless $val(stop)"
$ns at $val(stop) "stop"

#Stopping the scheduler


$ns at 10.01 "puts \"end simulation\" ; $ns halt"
#$ns at 10.01 "$ns halt"
proc stop {} {
global namfile tracefile ns
$ns flush-trace
close $namfile
close $tracefile
#executing nam file
exec nam sample1.nam &
}

#Starting scheduler
$ns run

#############################################################
Execution:
ns sample1.tcl

OUTPUT

You might also like