CN Lab Manual - Bhavani.k

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 67

Aim1.

A: Study of following Network Devices in Detail


 Repeater
 Hub
 Switch
 Bridge
 Router
 Gate Way

1. Repeater: Functioning at Physical Layer. A repeater is an electronic device that


receives a signal and retransmits it at a higher level and/or higher power, or onto the
other side of an obstruction, so that the signal can cover longer distances. Repeater have
two ports ,so cannot be use to connect for more than two devices

Important features of a repeater are as follows:


• A repeater connects different segments of a LAN

• A repeater forwards every frame it receives

• A repeater is a regenerator, not an amplifier

• It can be used to create a single extended LAN

Figure Repeater connecting two LAN segments

Figure Operation of a repeater as a level-1 relay

2. Hub: An Ethernet hub, active hub, network hub, repeater hub, hub or concentrator
is a device for connecting multiple twisted pair or fiber optic Ethernet devices together
and making them act as a single network segment. Hubs work at the physical layer
(layer 1) of the OSI model. The device is a form of multiport repeater. Repeater hubs
also participate in collision detection, forwarding a jam signal to all ports if it detects a
collision.
Figure: Hub as a multi-port repeater can be connected in a hierarchical manner to
form a single LAN with many nodes

3. Switch: A network switch or switching hub is a computer networking device that


connects network segments. The term commonly refers to a network bridge that
processes and routes data at the data link layer (layer 2) of the OSI model. Switches that
additionally process data at the network layer (layer 3 and above) are often referred to
as Layer 3 switches or multilayer switches.

Figure: Difference between a switch and a bridge

Some of important functionalities are:

• Ports are provided with buffer

• Switch maintains a directory: #address - port#

• Each frame is forwarded after examining the #address and


forwarded to the proper port#
4. Bridge: A network bridge connects multiple network segments at the data link
layer (Layer 2) of the OSI model. In Ethernet networks, the term bridge formally means
a device that behaves according to the IEEE 802.1 D standards. A bridge and switch are
very much alike; a switch being a bridge with numerous ports. Switch or Layer 2 switch
is often used interchangeably with bridge. Bridges can analyze incoming data packets
to determine if the bridge is able to send the given packet to another segment of the
network.

Key features of a bridge are mentioned below:

• A bridge operates both in physical and data-link layer

• A bridge uses a table for filtering/routing

• A bridge does not change the physical (MAC) addresses in a frame

• Types of bridges:

i)Transparent Bridges

ii) Source routing bridges

Figure: A bridge connecting two separate LANs

Figure Information flow through a bridge

5. Router: A router is an electronic device that interconnects two or more computer


networks, and selectively interchanges packets of data between them. Each data packet
contains address information that a router can use to determine if the source and
destination are on the same network, or if the data packet must be transferred from one
network to another. Where multiple routers are used in a large collection of
interconnected networks, the routers exchange information about target system
addresses, so that each router can build up a table showing the preferred paths between
any two systems on the interconnected networks.

There are two types of routers:

1. Static routers - Are configured manually and route data packets


based on information in a router table.

2. Dynamic routers - Use dynamic routing algorithms. There


are two types of algorithms:
Distance vector routing
Link state routing

Figure: Communication through a router

Gate Way: A gateway, as the name suggests, is a passage to connect two


networks together that may work upon different networking models.

They basically works as the messenger agents that take data from one system,
interpret it, and transfer it to another system. Gateways are also called protocol
converters and can operate at any network layer. Gateways are generally more
complex than switch or router. A gateway can translate information between
different network data formats or network architectures.
 A gateway may contain devices such as protocol translators, impedance
matching devices, rate converters, fault isolators, or signal translators as
necessary to provide system interoperability. It also requires the establishment
of mutually acceptable administrative procedures between both networks.

Figure: Communication through a gateway

Aim1.B: Connect the computers in Local Area Network.

Procedure: On the host computer

On the host computer, follow these steps to share the Internet connection:

1. Log on to the host computer as Administrator or as Owner.

2. Click Start, and then click Control Panel.

3. Click Network and Internet Connections.

4. Click Network Connections.

5. Right-click the connection that you use to connect to the Internet. For example, if
you connect to the Internet by using a modem, right-click the connection that you want
under Dial-up / other network available.

6. Click Properties.
7. Click the Advanced tab.

8. Under Internet Connection Sharing, select the Allow other network users to
connect through this computer's Internet connection check box.

9. If you are sharing a dial-up Internet connection, select the Establish a dial-up
connection whenever a computer on my network attempts to access the Internet
check box if you want to permit your computer to automatically connect to the Internet.

10. Click OK. You receive the following message:

When Internet Connection Sharing is enabled, your LAN adapter will be set to use IP
address 192.168.0.1. Your computer may lose connectivity with other computers on
your network. If these other computers have static IP addresses, it is a good idea to set
them to obtain their IP addresses automatically. Are you sure you want to enable
Internet Connection Sharing?

11. Click Yes.


The connection to the Internet is shared to other computers on the local area network (LAN).

The network adapter that is connected to the LAN is configured with a static IP address
of 192.168.0.1 and a subnet mask of 255.255.255.0

On the client computer

To connect to the Internet by using the shared connection, you must confirm the LAN
adapter IP configuration, and then configure the client computer. To confirm the LAN
adapter IP configuration, follow these steps:

1. Log on to the client computer as Administrator or as Owner.

2. Click Start, and then click Control Panel.

3. Click Network and Internet Connections.

4. Click Network Connections.

5. Right-click Local Area Connection and then click Properties.

6. Click the General tab, click Internet Protocol (TCP/IP) in the connection uses
the following items list, and then click Properties.

7. In the Internet Protocol (TCP/IP) Properties dialog box, click Obtain an IP


address automatically (if it is not already selected), and then click OK.
Note: You can also assign a unique static IP address in the range of 192.168.0.2 to
192.168.0.254. For example, you can assign the following static IP address, subnet
mask, and default gateway:

8. IP Address 192.168.31.202
9. Subnet mask 255.255.255.0
10. Default gateway 192.168.31.1

11. In the Local Area Connection Properties dialog box, click OK.

12. Quit Control Panel.


AIM 2.A: Write a Program to implement the data link layer farming methods such as
Character stuffing

PROGRAM:

#include<stdio.h>
#include<string.h>
#include<process.h>
void main()
{
int i=0,j=0,n,pos;
char a[20],b[50],ch;
printf("Enter string\n");
scanf("%s",&a);
n=strlen(a);
printf("Enter position\n");
scanf("%d",&pos);
if(pos>n)
{
printf("invalid position, Enter again :");
scanf("%d",&pos);}
printf("Enter the character\n");
ch=getche();
b[0]='d';
b[1]='l';
b[2]='e';
b[3]='s';
b[4]='t';
b[5]='x';
j=6;
while(i<n)
{
if(i==pos-1)
{
b[j]='d';
b[j+1]='l';
b[j+2]='e';
b[j+3]=ch;
b[j+4]='d';
b[j+5]='l';
b[j+6]='e';
j=j+7;
}
if(a[i]=='d' && a[i+1]=='l' && a[i+2]=='e')
{
b[j]='d';
b[j+1]='l';
b[j+2]='e';
j=j+3;
}
b[j]=a[i];
i++;
j++;
}
b[j]='d';
b[j+1]='l';
b[j+2]='e';
b[j+3]='e';
b[j+4]='t';
b[j+5]='x';
b[j+6]='\0';
printf("\nframe after stuffing:\n");
printf("%s",b);
}

OUTPUT:
ENTER STRING: COMPUTER
ENTER POSITION:3
ENTER THE CHARATER: @
FRAME AFTER STUFFING: dlestxcodle@dlemputerdleetx
AIM 2.B: Write a Program to implement the data link layer farming methods such as
Bit stuffing
#include<stdio.h>
#include<conio.h>
void main()
{
int i=0,count=0;
char databits[80];
printf("Enter Data Bits: ");
scanf("%s",databits);
printf("\nData Bits After Bit stuffing: ");
for(i=0; i<strlen(databits); i++)
{
if(databits[i]=='1')
count++;
else
count=0;
printf("%c",databits[i]);
if(count==5)
{
printf("0");
count=0;
}
}
getch();
}

Output:
Enter data bits: 0111110111110
Data bits after data stuffing: 01111100111110
AIM 3:
Write a Program to implement data link layer farming method checksum.
PROGRAM:
AIM 3: Write a Program to implement data link layer farming method checksum.

PROGRAM:

#include<stdio.h>
#include<conio.h>
int add(int, int);
int com(int);
void main() {
int i, j, dl, dil;
int data1[10], data2[10], newdata[10], comp[10], checksum[10];
printf("\n Enter the data length=");
scanf("%d", &dl);
printf("\n Enter the frame1 or data1 in the form of 0's and 1's : \n");
for (i = 0; i < dl; i++)
scanf("%d", &data1[i]);
printf("\n Enter the frame2 or data2 in the form of 0's and 1's: \n");
for (i = 0; i < dl; i++)
scanf("%d", &data2[i]);
for (i = dl - 1; i >= 0; i--) {
newdata[i] = add(data1[i], data2[i]);
}

printf("\n\n Data 1 : ");


for (i = 0; i < dl; i++)
printf("%d", data1[i]);
printf("\n Data 2 : ");
for (i = 0; i < dl; i++)
printf("%d", data2[i]);

printf("\n\n The new data is : ");


for (i = 0; i < dl; i++) {
printf("%d", newdata[i]);
}
printf("\n Checksum : ");
for (i = 0; i < dl; i++) {
checksum[i] = com(newdata[i]);
printf("%d", checksum[i]);
}

printf("\n\n Receiver Side : \n");


printf("\n Data : ");
for (i = 0; i < dl; i++)
printf("%d", data1[i]);
printf(" ");
for (i = 0; i < dl; i++)
printf("%d", data2[i]);
printf(" ");
for (i = 0; i < dl; i++)
printf("%d", checksum[i]);

printf("\n Addition : ");


for (i = dl - 1; i >= 0; i--) {
newdata[i] = add(newdata[i], checksum[i]);
}
for (i = 0; i < dl; i++) {
printf("%d", newdata[i]);
}
printf("\n Compliment : ");
for (i = 0; i < dl; i++) {
comp[i] = com(newdata[i]);
printf("%d", comp[i]);
}
}

int add(int x, int y) {


static int carry = 0;
if (x == 1 && y == 1 && carry == 0) {
carry = 1;
return 0;
} else if (x == 1 && y == 1 && carry == 1) {
carry = 1;
return 1;
} else if (x == 1 && y == 0 && carry == 0) {
carry = 0;
return 1;
} else if (x == 1 && y == 0 && carry == 1) {
carry = 1;
return 0;
} else if (x == 0 && y == 1 && carry == 0) {
carry = 0;
return 1;
} else if (x == 0 && y == 1 && carry == 1) {
carry = 1;
return 0;
} else if (x == 0 && y == 0 && carry == 0) {
carry = 0;
return 0;
} else {
carry = 0;
return 1;
}
}
int com(int a) {
if (a == 0)
return 1;
else
return 0;
}

Output:
Enter the data length= 4
Enter the frame1 or data1 in the form of 0's and 1's:1100
Enter the frame2 or data2 in the form of 0's and 1's:0101
Data 1:1100
Data 2:0101
New data is:10001
Checksum:01110
Receiver side:
Data:1100 0101 0110
Addition:11111
Compliment:00000

AIM 4: Write a program for Hamming Code generation for error detection and correction.
PROGRAM:

#include<stdio.h>

#include<conio.h>

void main() {

int data[7],rec[7],i,c1,c2,c3,c;

printf("this works for message of 4bits in size \nenter message bit one by one:
");

scanf("%d%d%d%d",&data[0],&data[1],&data[2],&data[4]);

data[6]=data[0]^data[2]^data[4];

data[5]=data[0]^data[1]^data[4];

data[3]=data[0]^data[1]^data[2];

printf("\nthe encoded bits are given below: \n");

for (i=0;i<7;i++) {

printf("%d ",data[i]);

printf("\nenter the received data bits one by one: ");

for (i=0;i<7;i++) {

scanf("%d",&rec[i]);

c1=rec[6]^rec[4]^rec[2]^rec[0];

c2=rec[5]^rec[4]^rec[1]^rec[0];

c3=rec[3]^rec[2]^rec[1]^rec[0];

c=c3*4+c2*2+c1 ;

if(c==0) {

printf("\ncongratulations there is no error: ");

} else {

printf("\nerron on the postion: %d\nthe correct message is \n",c);


if(rec[7-c]==0)

rec[7-c]=1; else

rec[7-c]=0;

for (i=0;i<7;i++) {

printf("%d ",rec[i]);

getch();

Output:
AIM 5: Write a Program to implement on a data set of characters the three CRC polynomials
– CRC 12, CRC 16 and CRC CCIP
PROGRAM:

#include<stdio.h>
#include<conio.h>
#include<string.h>
#define N strlen(g)
char t[28],cs[28],g[28];
int a,e,c,b;
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];
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);
}
int main()
{
int flag=0;
do{
printf("\n1.crc12\n2.crc16\ncrc ccit\n4.exit\n\nEnter your option.");
scanf("%d",&b);
switch(b)
{
case 1:strcpy(g,"1100000001111");
break;
case 2:strcpy(g,"11000000000000101");
break;
case 3:strcpy(g,"10001000000100001");
break;
case 4:return 0;
}
printf("\n enter data:");
scanf("%s",t);
printf("\n---------------------------\n");
printf("\n generating polynomial:%s",g);
a=strlen(t);
for(e=a;e<a+N-1;e++)
t[e]='0';
printf("\n------------------------------\n");
printf("modified data is:%s",t);
printf("\n---------------------------\n");
crc();
printf("checksum is:%s",cs);
for(e=a;e<a+N-1;e++)
t[e]=cs[e-a];
printf("\n---------------------------\n");
printf("\n final codeword is : %s",t);
printf("\n----------------------------\n");
printf("\ntest error detection 0(yes) 1(no)?:");
scanf("%d",&e);
if(e==0)
{
do{
printf("\n\tenter the position where error is to be inserted:");
scanf("%d",&e);
}
while(e==0||e>a+N-1);
t[e-1]=(t[e-1]=='0')?'1':'0'; printf("\n \n");
printf("\n\terroneous data:%s\n",t);
}
crc();
for(e=0;(e<N-1)&&(cs[e]!='1');e++); if(e<N-1)
printf("error detected\n\n"); else
printf("\n no error detected \n\n"); printf("\n ");
}while(flag!=1);
}
crc();
for(e=0;(e<N-1)&&(cs[e]!='1');e++); if(e<N-1)
printf("error detected\n\n"); else
printf("\n no error detected \n\n"); printf("\n ");
}while(flag!=1);
OUTPUT:
1.crc12

2.crc16

3.crc ccit

4.exit
Enter your option.1
enter data:1100110011100011

generating polynomial:1100000001111

modified data is:11001100111000110000000000001100000001111

checksum is:1101110110001

final codeword is : 11001100111000111101110110001100000001111

test error detection 0(yes) (no)?:1 no error


detected

1.crc12 2.crc16 3.crc


cit 4.exit

Enter your option.2


enter data:11001100111000

generating polynomial:11000000000000101

modified data is:110011001110000000000000000000000000000000101


AIM 6: Write a Program to implement Sliding window protocol for Goback N.

PROGRAM.CPP:

#include<bits/stdc++.h>

#include<ctime>

#define ll long long int


using namespace std;

void transmission(ll & i, ll & N, ll & tf, ll & tt) {


while (i <= tf) {
int z = 0;
for (int k = i; k < i + N && k <= tf; k++) {
cout << "Sending Frame " << k << "..." << endl;
tt++;
}
for (int k = i; k < i + N && k <= tf; k++) {
int f = rand() % 2;
if (!f) {
cout << "Acknowledgment for Frame " << k << "..." << endl;
z++;
} else {
cout << "Timeout!! Frame Number : " << k << " Not Received" << endl;
cout << "Retransmitting Window..." << endl;
break;
}
}
cout << "\n";
i = i + z;
}
}

int main() {
ll tf, N, tt = 0;
srand(time(NULL));
cout << "Enter the Total number of frames : ";
cin >> tf;
cout << "Enter the Window Size : ";
cin >> N;
ll i = 1;
transmission(i, N, tf, tt);
cout << "Total number of frames which were sent and resent are : " << tt <<
endl;
return 0;
}

OUTPUT:
Enter the Total number of frames : 12
Enter the Window Size : 4
Sending Frame 1…
Sending Frame 2…
Sending Frame 3…
Sending Frame 4…
Timeout!! Frame Number : 1 Not Received
Retransmitting Window…
Sending Frame 1…
Sending Frame 2…
Sending Frame 3…
Sending Frame 4…
Acknowledgment for Frame 1…
Timeout!! Frame Number : 2 Not Received
Retransmitting Window…

Sending Frame 2…
Sending Frame 3…
Sending Frame 4…
Sending Frame 5…
Timeout!! Frame Number : 2 Not Received
Retransmitting Window…

Sending Frame 2…
Sending Frame 3…
Sending Frame 4…
Sending Frame 5…
Acknowledgment for Frame 2…
Acknowledgment for Frame 3…
Acknowledgment for Frame 4…
Timeout!! Frame Number : 5 Not Received
Retransmitting Window…

Sending Frame 5…
Sending Frame 6…
Sending Frame 7…
Sending Frame 8…
Timeout!! Frame Number : 5 Not Received
Retransmitting Window…

Sending Frame 5…
Sending Frame 6…
Sending Frame 7…
Sending Frame 8…
Acknowledgment for Frame 5…
Timeout!! Frame Number : 6 Not Received
Retransmitting Window…
Sending Frame 6…
Sending Frame 7…
Sending Frame 8…
Sending Frame 9…
Acknowledgment for Frame 6…
Timeout!! Frame Number : 7 Not Received
Retransmitting Window…

Sending Frame 7…
Sending Frame 8…
Sending Frame 9…
Sending Frame 10…
Acknowledgment for Frame 7…
Acknowledgment for Frame 8…
Acknowledgment for Frame 9…
Acknowledgment for Frame 10…

Sending Frame 11…


Sending Frame 12…
Timeout!! Frame Number : 11 Not Received
Retransmitting Window…

Sending Frame 11…


Sending Frame 12…
Timeout!! Frame Number : 11 Not Received
Retransmitting Window…

Sending Frame 11…


Sending Frame 12…
Acknowledgment for Frame 11…
Acknowledgment for Frame 12…

Total number of frames transmitted(sent + resent) are : 38


code in C: Write a Program to implement Sliding window protocol for Goback N

#include<stdio.h>
int main()
{
int windowsize,sent=0,ack,i;
printf("enter window size\n");
scanf("%d",&windowsize);
while(1)
{
for( i = 0; i < windowsize; i++)
{
printf("Frame %d has been transmitted.\n",sent);
sent++;
if(sent == windowsize)
break;
}
printf("\nPlease enter the last Acknowledgement received.\n");
scanf("%d",&ack);

if(ack == windowsize)
break;
else
sent = ack;
}
return 0;
}

output:-

enter window size


8
Frame 0 has been transmitted.
Frame 1 has been transmitted.
Frame 2 has been transmitted.
Frame 3 has been transmitted.
Frame 4 has been transmitted.
Frame 5 has been transmitted.
Frame 6 has been transmitted.
Frame 7 has been transmitted.
Please enter the last Acknowledgement received.
2
Frame 2 has been transmitted.
Frame 3 has been transmitted.
Frame 4 has been transmitted.
Frame 5 has been transmitted.
Frame 6 has been transmitted.
Frame 7 has been transmitted.

Please enter the last Acknowledgement received.


8
--------------------------------

AIM 7: Write a Program to implement Sliding window protocol for Selective repeat.
PROGRAM:
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<unistd.h>
int n,r;
struct frame
{
char ack;
int data;
}frm[10];
int sender(void);
void recvack(void);
void resend(void);
void selective(void);
int main()
{
int c;
do
{
printf("\n\n1.Selective repeat ARQ\n \n2.exit");
printf("\nEnter your choice:");
scanf("%d",&c);
switch(c)
{
case 1:selective();
break;
case 2:exit(0);
break;
}
}while(c>=4);
}
void selective()
{
sender();
recvack();
resend();
printf("\nAll packets sent successfully");
}
int sender()
{
int i;
printf("\nEnter the no. of packets to be sent:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
printf("\nEnter data for packets[%d]",i);
scanf("%d",&frm[i].data);
frm[i].ack='y';
}
return 0;
}
void recvack()
{
int i;
rand();
r=rand()%n;
frm[r].ack='n';
for(i=1;i<=n;i++)
{
if(frm[i].ack=='n')
printf("\nThe packet number %d is not received\n",r);
}
}
void resend() //SELECTIVE REPEAT
{
printf("\nresending packet %d",r);
sleep(2);
frm[r].ack='y';
printf("\nThe received packet is %d",frm[r].data);
}

OUTPUT:
1.selective repeat ARQ
2.exit
Enter your choice:1
Enter the no.of packets to be sent:3
Enter data for packets[1] 101
Enter data for packets[2] 010
Enter data for packets[3] 111
The packet number 2 is not received
resending packet 2
The received packet is 010
All packets sent successfully.

AIM 8: Write a Program to implement Stop and Wait Protocol.


PROGRAM:
#include<stdio.h
>
int sender();
int recv();
int timer=0,wait_for_ack=-1,frameQ=0,cansend=1,t=0;
main()
{
int i,j;
int frame[5];

printf("enter the time when data frame will be ready\n");


for(j=0;j<3;j++)
{

sender( i,frame[]);
recv(i);
}
sender(int i,int frame[])
{
wait_for_ack++;
if(wait_for_ack==3)
{

if(i==frame[t])
{
frameQ++;
t++;
}
if(frameQ==0)
printf("NO FRAME TO SEND at time=%d \n",i);
if(frameQ>0 && cansend==1)
{
printf("FRAME SEND AT TIME=%d\n",i);
cansend=-1;
frameQ--;
timer++;
printf("timer in sender=%d\n",timer);
}
if(frameQ>0 && cansend==-1)
printf("FRAME IN Q FOR TRANSMISSION AT
TIME=%d\n",i);
if(frameQ>0)
t++;
}
printf("frameQ=%d\n",frameQ);
printf("i=%d t=%d\n",i,t);
printf("value in frame=%d\n",frame[t]);
return 0;
}

int recv(int i )
{ printf("timer in recvr=%d\n",timer);
if(timer>0)
{
timer++;
}
if(timer==3)
{
printf("FRAME ARRIVED AT TIME= %d\
n",i);
wait_for_ack=0;
timer=0;
}
Else
printf("WAITING FOR FRAME AT TIME
%d\n",i);
return 0;

}
}
OUTPUT:
enter the time when data frame will be ready
frameQ=0
i=1,t=0
value in frame=3
time in recvr=0
WAITING FOR FRAME AT TIME 1
enter the time when data frame will be ready
frameQ=0
i=1,t=0
value in frame=3
time in recvr=0
WAITING FOR FRAME AT TIME 1
enter the time when data frame will be ready
frameQ=0
i=1,t=0
value in frame=3
time in recvr=0
WAITING FOR FRAME AT TIME 1

AIM 9: Write a program for congestion control using leaky bucket algorithm

Program:
#include<stdio.h>
int main()
{
int incoming, outgoing, buck_size, n, store = 0;
printf("Enter bucket size, outgoing rate and no of inputs: ");
scanf("%d %d %d", &buck_size, &outgoing, &n);
while (n != 0)
{
printf("Enter the incoming packet size : ");
scanf("%d", &incoming);
printf("Incoming packet size %d\n", incoming);
if (incoming <= (buck_size - store)){
store += incoming;
printf("Bucket buffer size %d out of %d\n", store, buck_size);
}
else {
printf("Dropped %d no of packets\n", incoming - (buck_size - store));
printf("Bucket buffer size %d out of %d\n", store, buck_size);
store = buck_size;
}
store = store - outgoing;
printf("After outgoing %d packets left out of %d in buffer\n", store, buck_size);
n--;
}
}

Output

AIM 10: Write a Program to implement Dijkstra‘s algorithm to compute the Shortest path through a
graph.
PROGRAM:

#include<stdio.h>
#include<string.h>
#include<math.h>
main()
{
int u,v,num,i,j,l,k,s[10],min,cost[10][10],dist[10],path[10],n;
clrscr();
printf("\n ENTER VERTECES:");
scanf("%d",&n);
printf("\n ENTER ADJECENCY MATRIX:\n");
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
scanf("%d",&cost[i][j]);
}
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
if(i==j) cost[i][j]=0;
else if(cost[i][j]==-1)
cost[i][j]=30000;
printf("\nENTER SOURCE VERTEX:");
scanf("%d",&v); clrscr();
for(i=1;i<=n;i++)
{
s[i]=0;
path[i]=v; dist[i]=cost[v][i];
}
dist[v]=0; for(num=2;num<=n;num+
+)
{
min=30000; u=0;
for(i=1;i<=n;i++)
{
if(s[i]!=1) if(min>dist[i])
{
u=i; min=dist[i];
}
}
s[u]=1;
for(i=1;i<=n;i++)
{ if(s[i]!=1) if(dist[i]>(min+cost[u]
[i]))
{
dist[i]=min+cost[u][i];
path[i]=u;
}
}
}
printf("\n");
printf("\nPATH MATRIX:\n"); printf("\
nDISTANCE NODE PATH\n");
for(i=1;i<=n;i++)
{ printf("\n
%d",dist[i]); printf("
%d ",i);
j=i;
do
{
printf(" --> %d
",path[j]); u=path[j];
j=u;
}while(u!=v);
}
getch();
}

INPUT/OUTPUT:
ENTER VERTECES:8

ENTER ADJECENCY MATRIX:

0 2 -1 -1 -1 -1 6 -1
2 0 7 -1 2 -1 -1 -1
-1 7 0 3 -1 3 -1 -1
-1 -1 3 0 -1 -1 -1 2
-1 2 -1 -1 0 2 1 -1
-1 -1 3 -1 2 0 -1 2
6 -1 -1 -1 1 -1 0 4
-1 -1 -1 2 -1 2 4 0

ENTER SOURCE VERTEX:1

PATH MATRIX:

DISTANCE NODE PATH

0 1 --> 1
2 2 --> 1
9 3 --> 2 --> 1
10 4 --> 8 --> 6 --> 5 --> 2 --> 1
4 5 --> 2 --> 1
6 6 --> 5 --> 2 --> 1
5 7 --> 5 --> 2 --> 1
8 8 --> 6 --> 5 --> 2 --> 1
AIM 11: Write a Program to implement Distance vector routing algorithm by obtaining
routing table at each node (Take an example subnet graph with weights indicating delay
between nodes).

PROGRAM:
Take an example subnet graph with weights indicating delay between nodes

PROGRAM:
#include<stdio.h>
#include<conio.h>
struct full
{
char line[10],dest[10]; int hops;
}f[20];
main()
{
int nv,min,minver,i; char sv[2],temp;
clrscr();
printf("\nEnter number of vertices:"); scanf("%d",&nv);
printf("\n Enter source vertex: "); scanf("%s",sv);
printf("\n Enter full table for source vertex %s :\n",sv); for(i=0;i<nv;i++)
scanf("%s %s %d",f[i].dest,f[i].line,&f[i].hops); printf("\n HIERARCHIAL TABLE\n\n");
for(i=0;i<nv;)
{
if(sv[0]==f[i].dest[0])
{
printf("\n %s %s %d",f[i].dest,f[i].line,f[i].hops); i++;
}
else
{
min=1000;
minver=0;
temp=f[i].dest[0];
while(temp==f[i].dest[0])
{
if(min>f[i].hops)
{
min=f[i].hops; minver=i;
} i++;
}
printf("\n %c %s %d ",temp,f[minver].line,f[minver].hops);
}
}
getch();
}
INPUT/OUTPUT:
Enter number of vertices: 8
Enter source vertex :1A
Enter full table for source vertex 1A
: 1A - -
1B 1B 1
1C 1C 1
2A 1B 1
2B 1B 2
3A 1C 2
3B 1C 3
4A 1C 3
HIERARCHIAL TABLE
1A - 0
1B 1B 1
1C 1C 1
2 1B 1
3 1C 2
4 1C 3
PROGRAM: Now obtain Routing table for each node using distance vector routing.

#include<stdio.h>
#include<math.h>
#include<conio.h>
main()
{
int i,j,k,nv,sn,noadj,edel[20],tdel[20][20],min; char sv,adver[20],ch;
clrscr();
printf("\n ENTER THE NO.OF VERTECES:");
scanf("%d",&nv);
printf("\n ENTER THE SOURCE VERTEX NUM,BER AND NAME:");
scanf("%d",&sn);
flushall(); sv=getchar();
printf("\n NETER NO.OF ADJ VERTECES TO VERTEX %c",sv);
scanf("%d",&noadj);
for(i=0;i<noadj;i++)
{
printf("\n ENTER TIME DELAY and NODE NAME:");
scanf("%d %c",&edel[i],&adver[i]);
}
for(i=0;i<noadj;i++)
{
printf("\n ENTER THE TIME DELAY FROM %c to ALL OTHER
NODES: ",adver[i]); for(j=0;j<nv;j++) scanf("%d",&tdel[i][j]);
}

printf("\n DELAY VIA--VERTEX \n "); for(i=0;i<nv;i++)


{
min=1000; ch=0;
for(j=0;j<noadj;j++)
if(min>(tdel[j][i]+edel[j]))
{
min=tdel[j][i]+edel[j];
ch=adver[j];
}
if(i!=sn-1)
printf("\n%d %c",min,ch); else
printf("\n0 -");
}
getch();
}
INPUT/OUTPUT:
ENTER THE NO.OF VERTECES:12
ENTER THE SOURCE VERTEX NUMBER AND NAME:10 J
ENTER NO.OF ADJ VERTECES TO VERTEX 4
ENTER TIME DELAY and NODE NAME:8 A
ENTER TIME DELAY and NODE NAME:10 I
ENTER TIME DELAY and NODE NAME:12 H
ENTER TIME DELAY and NODE NAME:6 K
ENTER THE TIME DELAY FROM A to ALL OTHER NODES: 0 12 25 40 14 23 18 17 21 9 24 29
ENTER THE TIME DELAY FROM I to ALL OTHER NODES: 24 36 18 27 7 20 31 20 0 11 22 33
ENTER THE TIME DELAY FROM H to ALL OTHER NODES: 20 31 19 8 30 19 6 0 14 7 22 9
ENTER THE TIME DELAY FROM K to ALL OTHER NODES: 21 28 36 24 22 40 31 19 22 10 0 9
DELAY VIA--VERTEX
8a
20 a
28 i
20 h
17 i
30 i
18 h
12 h
10 i
0 -
6 k 15 k
AIM 12: Write a Program to implement Broadcast tree by taking subnet of hosts.
PROGRAM:
#include<stdio.h>
int a[10][10],n;
void main()
{
int i,j,root;
clrscr();
printf("Enter no.of nodes:");
scanf("%d",&n);
printf("Enter adjacent matrix\n");
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
{
printf("Enter connecting of %d-->%d::",i,j);
scanf("%d",&a[i][j]);
}
printf("Enter root node:");
scanf("%d",&root);
adj(root);
}
adj(int k)
{
int i,j;
printf("Adjacent node of root node::\n");
printf("%d\n\n",k);
for(j=1;j<=n;j++)

{
if(a[k][j]==1 || a[j][k]==1)
printf("%d\t",j);
}
printf("\n");
for(i=1;i<=n;i++)
{
if((a[k][j]==0) && (a[i][k]==0) && (i!=k)) printf("%d",i);
}
}
OUTPUT
***************
Enter no.of nodes:5 Enter adjacent matrix
Enter connecting of 1-->1::0
Enter connecting of 1-->2::1
Enter connecting of 1-->3::1
Enter connecting of 1-->4::0
Enter connecting of 1-->5::0
Enter connecting of 2-->1::1
Enter connecting of 2-->2::0
Enter connecting of 2-->3::1
Enter connecting of 2-->4::1
Enter connecting of 2-->5::0
Enter connecting of 3-->1::1
Enter connecting of 3-->2::1
Enter connecting of 3-->3::0
Enter connecting of 3-->4::0
Enter connecting of 3-->5::0
Enter connecting of 4-->1::0
Enter connecting of 4-->2::1
Enter connecting of 4-->3::0
Enter connecting of 4-->4::0
Enter connecting of 4-->5::1
Enter connecting of 5-->1::0
Enter connecting of 5-->2::0
Enter connecting of 5-->3::0
Enter connecting of 5-->4::1
Enter connecting of 5-->5::0
Enter root node:2
Adjacent node of root node::
2
134
5
AIM 13: Wireshark

What is Wireshark?
Wireshark is an open-source packet analyzer, which is used for education, analysis, software
development, communication protocol development, and network troubleshooting.

It is used to track the packets so that each one is filtered to meet our specific needs. It is commonly
called as a sniffer, network protocol analyzer, and network analyzer. It is also used by network
security engineers to examine security problems.

Wireshark is a free to use application which is used to apprehend the data back and forth. It is often
called as a free packet sniffer computer application. It puts the network card into an unselective
mode, i.e., to accept all the packets which it receives.

Uses of Wireshark:
Wireshark can be used in the following ways:

1. It is used by network security engineers to examine security problems.


2. It allows the users to watch all the traffic being passed over the network.
3. It is used by network engineers to troubleshoot network issues.
4. It also helps to troubleshoot latency issues and malicious activities on your network.
5. It can also analyze dropped packets.
6. It helps us to know how all the devices like laptop, mobile phones, desktop, switch, routers,
etc., communicate in a local network or the rest of the world.

Functionality of Wireshark:
Wireshark is similar to tcpdump in networking. Tcpdump is a common packet analyzer which
allows the user to display other packets and TCP/IP packets, being transmitted and received over a
network attached to the computer.

It has a graphic end and some sorting and filtering functions. Wireshark users can see all the traffic
passing through the network.

Wireshark can also monitor the unicast traffic which is not sent to the network's MAC address
interface. But, the switch does not pass all the traffic to the port.

Hence, the promiscuous mode is not sufficient to see all the traffic. The various network taps or port
mirroring is used to extend capture at any point.
Port mirroring is a method to monitor network traffic. When it is enabled, the switch sends
the copies of all the network packets present at one port to another port.

Features of Wireshark
o It is multi-platform software, i.e., it can run on Linux, Windows, OS X, FreeBSD, NetBSD,
etc.
o It is a standard three-pane packet browser.
o It performs deep inspection of the hundreds of protocols.
o It often involves live analysis, i.e., from the different types of the network like the Ethernet,
loopback, etc., we can read live data.
o It has sort and filter options which makes ease to the user to view the data.
o It is also useful in VoIP analysis.
o It can also capture raw USB traffic.
o Various settings, like timers and filters, can be used to filter the output.
o It can only capture packet on the PCAP (an application programming interface used to
capture the network) supported networks.
o Wireshark supports a variety of well-documented capture file formats such as the PcapNg
and Libpcap. These formats are used for storing the captured data.
o It is the no.1 piece of software for its purpose. It has countless applications ranging from the tracing
down, unauthorized traffic, firewall settings, etc.

Installation of Wireshark Software


Below are the steps to install the Wireshark software on the computer:

o Open the web browser.


o Search for 'Download Wireshark.'
o Select the Windows installer according to your system configuration, either 32-bt or 64-bit.
Save the program and close the browser.
o Now, open the software, and follow the install instruction by accepting the license.
o The Wireshark is ready for use.

On the network and Internet settings option, we can check the interface connected to our computer.
I. Packet Capture Using Wire shark

Use Wireshark to perform a packet capture of network traffic:


Visit the Wireshark download site, and download the appropriate Wireshark package or installer for
the operating system running on the system which is to be used for packet capture.

When installing, ensure all components are selected for installation, including the optional
“Winpcap” application.

In some cases, you may want to perform packet captures with Wireshark. One case might be
when you want to perform a packet capture on channel 12 or 13.

Set up the Packet Capture

1. Click View > Wireless Toolbar. The Wireless Toolbar will appear just below the Main
toolbar.

2.Use the Wireless Toolbar to configure the desired channel and channel width.
3.Under Capture, click on AirPcap USB wireless capture adapter to select the capture
interface.

Note: If the AirPcap isn't listed, press F5 to refresh the list of available packet capture interfaces.

Note: The AirPcap has been discontinued by RiverBed and is 802.11n only.

4. Click the Start Capture button to begin the capture.

5.When you are finished capturing, click the Stop button


Saving the Capture
1. To save the capture, click File > Save.

2. Name the file, and click Save.

Note: .Pcap and .Pcap-ng are good filetypes to use for the capture if you plan to use Eye P.A. to
open the capture.
2. Eye P.A. can now open the capture file.
II. STARTING WIRESHARK:

Two different methods for starting Wireshark are available. These include the Start menu and the Run
command box

Method 1 - Start Menu


To start Wireshark using the Start menu:

1. Open the Start menu.


2. Select All Programs.
3. Select Wireshark.

Method 2 - Run Command


To start Wireshark using the Run command box:

1. Open the Start menu or press the Windows key + R.


2. Type Wireshark in the Run command box.
3. Press Enter
III. Viewing Packets You Have Captured:

Once you have captured some packets or you have opened a previously saved capture file, you can
view the packets that are displayed in the packet list pane by simply clicking on a packet in the packet
list pane, which will bring up the selected packet in the tree view and byte view panes.

You can then expand any part of the tree to view detailed information about each protocol in each
packet. Clicking on an item in the tree will highlight the corresponding bytes in the byte view. An
example with a TCP packet selected is shown in Figure 6.1, “Wireshark with a TCP packet selected
for viewing”. It also has the Acknowledgment number in the TCP header selected, which shows up in
the byte view as the selected bytes.

Figure 6.1. Wireshark with a TCP packet selected for viewing

You can also select and view packets the same way while Wireshark is capturing if you selected
“Update list of packets in real time” in the “Capture Preferences” dialog box.

In addition you can view individual packets in a separate window as shown in Figure 6.2, “Viewing a
packet in a separate window”. You can do this by double-clicking on an item in the packet list or by
selecting the packet in which you are interested in the packet list pane and selecting View → Show
Packet in New Window. This allows you to easily compare two or more packets, even across multiple
files.
Figure 6.2. Viewing a packet in a separate window

Along with double-clicking the packet list and using the main menu there are a number of
other ways to open a new packet window:

 Hold down the shift key and double-click on a frame link in the packet details.
AIM 14: How to run Nmap scan

PROCEDURE:
NMAP: NMAP stands for Network Mapper which is an open-source tool used for network
exploration and security auditing, in comparison to this, a tool named Nessus is used by
industry professionals. These tools are mainly used by cybersecurity experts and hackers .
1. Nmap is a network scanner created by Gordon Lyon.
2. Nmap is used to discover hosts and services on a computer network by sending packets
and analyzing the responses.
3. Nmap provides a number of features for probing computer networks, including host
discovery and service and operating system detection
4. Ensuring that your router is protected from unwanted intruders is

one of the foundations of a secure network.


5. One of the basic tools for this job is Nmap, or Network Mapper.

6. This program will scan a target and report which ports are open and

which are closed, among other things. Security specialists use this
program to test the security of a network.
METHOD 1:

1. Download the Nmap installer. This can be found for free from the developer’s website. It is
highly recommended that you download directly from the developer to avoid any potential viruses
or fake files. Downloading the Nmap installer includes Zenmap, the graphical interface for Nmap
which makes it easy for newcomers to perform scans without having to learn command lines.
 The Zenmap program is available for Windows, Linux, and Mac OS X. You can find the
installation files for all operating systems on the Nmap website.
2.Install Nmap. Run the installer once it is finished downloading. You will be
asked which components you would like to install. In order to get the full
benefit of Nmap, keep all of these checked. Nmap will not install any adware or
spyware.

3. Run the "Nmap – Zenmap" GUI program. If you left your settings at default
during installation, you should be able to see an icon for it on your desktop. If
not, look in your Start menu. Opening Zenmap will start the program.

4. Enter in the target for your scan. The Zenmap program makes
scanning a fairly simple process. The first step to running a scan is
choosing your target. You can enter a domain (example.com), an IP
address (127.0.0.1), a network (192.168.1.0/24), or a combination of
those.
 Depending on the intensity and target of your scan, running an Nmap scan may be against
the terms of your internet service provider, and may land you in hot water. Always check
your local laws and your ISP contract before performing Nmap scans on targets other than
your own network.

5. Choose your Profile. Profiles are preset groupings of modifiers that


change what is scanned. The profiles allow you to quickly select
different types of scans without having to type in the modifiers on
the command line. Choose the profile that best fits your needs: [1]
 Intense scan - A comprehensive scan. Contains Operating System (OS) detection, version
detection, script scanning, traceroute, and has aggressive scan timing. This is considered an
intrusive scan.
 Ping scan - This scan simply detects if the targets are online, it does not scan any ports.
 Quick scan - This is quicker than a regular scan due to aggressive timing and only scanning
select ports.
 Regular scan - This is the standard Nmap scan without any modifiers. It will return ping and
return open ports on the target.
6. Click Scan to start scanning. The active results of the scan will be
displayed in the Nmap Output tab. The time the scan takes will depend on
the scan profile you chose, the physical distance to the target, and the
target’s network configuration.

7. Read your results. Once the scan is finished, you’ll see the
message "Nmap done" at the bottom of the Nmap Output tab. You
can now check your results, depending on the type of scan you
performed. All of the results will be listed in the main Nmap Output
tab, but you can use the other tabs to get a better look at specific
data.[2]
 Ports/Hosts - This tab will show the results of your port scan, including the services for
those ports.
 Topology - This shows the traceroute for the scan you performed. You can see how many
hops your data goes through to reach the target.
 Host Details - This shows a summary of your target learned through scans, such as the
number of ports, IP addresses, hostnames, operating systems, and more.
 Scans - This tab stores the commands of your previously-run scans. This allows you to
quickly re-scan with a specific set of parameters.
AIM 15: Operating System Detection using Nmap

OS detection using NMAP:

Now we need to run the actual commands to perform OS detection using NMAP, and at first, we
will get the IP address of the host system, and then will perform a scan to get all active devices on
the network.
Step 1: Getting the IP of the System
Ifconfig

Step 2: List of active devices in the Network


nmap -sn 192.168.232.128/24

Let’s do an SYN scan with OS detection in one of the active IPs


Let’s select IP: 192.168.232.2
nmap -sS 192.168.232.2 –O
Running: VMware Player.
OS details: VMware Player virtual NAT device.

Let’s now perform an Aggressive scan To guess the OS

 -sV stands for Service version.


 -A stands for Aggressive.
It will only display the chance of Operation System (OS) on the host computer with the help of
Probability and Percentage.
nmap -sV 192.168.232.2 –A
AIM 16: Do the following using NS2 Simulator
I. NS2 Simulator-Introduction

Network Simulator (Version 2), widely known as NS2, is simply an event-driven simulation tool that has
proved useful in studying the dynamic nature of commu-nication networks. Simulation of wired as well as
wireless network functions and protocols (e.g., routing algorithms, TCP, UDP) can be done using NS2. In
general, NS2 provides users with a way of specifying such network protocols and simulating their
corresponding behaviors.
Due to its flexibility and modular nature, NS2 has gained constant popularity in the networking research
community since its birth in 1989. Ever since, several revolutions and revisions have marked the growing
maturity of the tool, thanks to substantial contributions from the players in the field. Among these are the
University of California and Cornell University who developed the REAL network simulator,1 the
foundation on which NS is invented. Since 1995 the Defense Advanced Research Projects Agency
(DARPA) supported the development of NS through the Virtual InterNetwork Testbed (VINT) project
Currently the National Science Foundation (NSF) has joined the ride in development. Last but not the least,
the group of researchers and developers in the community are constantly working to keep NS2 strong and
versatile.
Again, the main objective of this book is to provide the readers with insights into the NS2 architecture. This
chapter gives a brief introduction to NS2. NS2 Beginners are recommended to go thorough the detailed
introductory online resources. For example, NS2 official website provides NS2 source code as well as
detailed installation instruction. The web pages in and are among highly recommended ones which provide
tutorial and examples for setting up basic NS2 simulation.

2.1 Basic Architecture


Figure 2.1 shows the basic architecture of NS2. NS2 provides users with an executable command “ns”
which takes one input argument, the name of a Tcl simulation scripting file. In most cases, a simulation
trace file is created and is used to plot graph and/or to create animation.
NS2 consists of two key languages: C and Object-oriented Tool Command Language (OTcl). While the
C defines the internal mechanism (i.e., a backend) of the simulation, the OTcl sets up simulation by
assembling and configuring the objects as well as scheduling discrete events (i.e., a frontend). The C and
the OTcl are linked together using TclCL. Mapped to a C object, variables in the OTcl domains are
sometimes referred to as handles. Conceptually, a handle is just a string (e.g., “_o10”) in the OTcl
domain and does not contain any functionality. Instead, the functionality (e.g., receiving a packet) is
defined in the mapped C object (e.g., of class Connector). In the OTcl domain, a handle acts as a
frontend which interacts with users and other OTcl objects.
II. Simulate to Find the Number of Packets Dropped

Simulate a three-node point-to-point network with a duplex link between them. Set the queue size
and vary the bandwidth and find the number of packets dropped.

Sender:-
stcp –p 2000 –l 1024 1.0.1.2

Receiver:-
rtcp –p 2000 –l 1024

Parameters:-
Drop Packets and Collision Packets.

Step1: Drawing topology


1. Select/click the HOST icon on the toolbar and click the left mouse button on the editor,
to place a HOST1 on the editor.
Repeat the above procedure and place another host “HOST2” on the editor.

2. Select/click the HUB icon on the toolbar and click the left mouse button on the editor,
to place HUB1 on the editor.

3. Click on the LINK icon on the toolbar and connect HOST1 to HUB1 and HUB1 to
HOST2
4. Click on the “E” icon on the toolbar to save the current topology
e.g: file1.tpl
(Look for the ******.tpl extension.)

NOTE: Changes cannot / (should not) be done after selecting the “E” icon.

Step2: Configuration
1. Double click the left mouse button while cursor is on HOST1 to open the HOST
window.

2. Select Add button on the HOST window to invoke the command window and
provide the following command in the command textbox.
stg –u 1024 100 1.0.1.2

3. Click OK button on the command window to exit and once again click on the OK
button on the HOST window to exit.

4. Double click the left mouse button while cursor is on HOST2 to open the HOST
window.

5. Select Add button on the HOST window to invoke the command window and
provide the following command in the command textbox.
rtg –u –w log1

6. Click OK button on the command window to exit.

7. Click NODE EDITOR Button on the HOST window and select the MAC tab from the
modal window that pops up.

8. Select LOG STATISTICS and select checkboxes for Number of Drop Packet and
Number of Collisions in the MAC window

9. Click OK button on the MAC window to exit and once again click on the OK button
on the HOST window to exit.

Note: To set QUEUE size

1. Double click the left mouse button while cursor is on HOST2 to open the HOST
window.

2. Click NODE EDITOR Button on the HOST window and select the FIFO tab from the
modal window that pops up.

3. Change Queue size (Default 50).


4. Click OK button on the FIFO window to exit and once again click on the OK button
on the HOST window to exit.

Step3: Simulate
i. Click “R” icon on the tool bar
ii. Select Simulation in the menu bar and click/ select RUN in the
dropdown list to execute the simulation.
iii. To start playback select “►” icon located at the bottom right corner of the
editor.
iv. To view results, Open up new TERMINAL window, move to file1.results
folder and open collision and drop log files in separate TERMINAL
window.
Caution: file1 is the hypothetical name given to this simulation.
(Refer Step 1.4)

Changing configurations
Change 1
1. Open the above file,
2. Do not change the topology or any other configuration,
3. Select E icon on the toolbar
4. Reduce the bandwidth at link2 by double clicking the left mouse button while cursor
is on link2 .(Change bandwidth on both tabs Uplink/Downlink)
5. Repeat Step3 (Simulate)

Change 2
1. Open the above file,
2. Remove HUB and replace it with SWITCH.
3. Do not change anything in the
configuration Repeat Step3(Simulate)
III. Simulate to Find the Number of Packets Dropped by
TCP/UDP

Simulate a four-node point-to-point network and connect the link as follows: Apply a TCP
agent between n0 to n3 and apply a UDP agent between n1 and n3. Apply relevant
applications over TCP and UDP agents changing the parameters and determine the number
of packets sent by two agents.

Topology:-

Sender:-
stcp –p 3000 –l 1024 1.0.1.3
stg –u 1024 1.0.1.3

Receiver:-
rtcp –p 3000 –l 1024
rtg –u 3000

Parameters:-
Throughput of incoming and outgoing Packets

Step1: Drawing topology


1. Select/click the HOST icon on the toolbar and click the left mouse button on the editor,
to place a host on the editor.
Repeat the above procedure and place two other hosts “HOST2” and “HOST3” on the
editor.

2. Select/click the HUB (or SWITCH) icon on the toolbar and click the left mouse
button on the editor, to place a HUB (or SWITCH) on the editor.
3. Click on the LINK icon on the toolbar and connect HOST1 to HUB, HOST2 to HUB and
HUB to HOST3

4. Click on the “E” icon on the toolbar to save the current topology e.g: file2.tpl
(Look for the ******.tpl extension.)
NOTE: Changes cannot / (should not) be done after selecting the “E” icon.

Step2: Configuration
1. Double click the left mouse button while cursor is on HOST1 to open the HOST
window.

2. Select Add button on the HOST window to invoke the command window and
provide the following command in the command textbox.
stcp –p 21 –l 1024 1.0.1.3

3. Click OK button on the command window to exit

4. Click NODE EDITOR Button on the HOST window and select the MAC tab from the
modal window that pops up.

5. Select LOG STATISTICS and select checkbox for output throughput in the MAC
window

6. Click OK button on the MAC window to exit and once again click on the OK button
on the HOST window to exit.

7. Double click the left mouse button while cursor is on HOST2 to open the HOST
window.

8. Select Add button on the HOST window to invoke the command window and
provide the following command in the command textbox.
stg –u 1024 100 1.0.1.3

9. Click OK button on the command window to exit

10. Click NODE EDITOR Button on the HOST window and select the MAC tab from
the modal window that pops up.

11. Select LOG STATISTICS and select checkbox for output throughput in the
MAC window

12. Click OK button on the MAC window to exit and once again click on the OK button
on the HOST window to exit.

13. Double click the left mouse button while cursor is on HOST3 to open the
HOST window.

14. Select Add button on the HOST window to invoke the command window and
provide the following command in the command textbox.
rtcp –p 21 –l 1024

15. Click OK button on the command window to exit.

16. Also add the following command on HOST3


rtg –u –w log1

17. Click NODE EDITOR Button on the HOST window and select the MAC tab from the
modal window that pops up.

18. Select LOG STATISTICS and select checkbox for input and
output throughput in the MAC window

19. Click OK button on the MAC window to exit and once again click on the OK
button on the HOST window to exit.

Step3: Simulate
i. Click “R” icon on the tool bar
ii. Select Simulation in the menu bar and click/ select RUN in the
dropdown list to execute the simulation.
iii. To start playback select “►” icon located at the bottom right corner of the editor.
iv. To view results, Open up new TERMINAL window, move to file2.results
folder and open input and output throughput log files in separate TERMINAL
window.
Caution: file2 is the hypothetical name given to this simulation.
(Refer Step 1.4)
IV. Simulate to Find the Number of
Packets Dropped due to Congestion

Simulate the transmission of ping messages over a network topology consisting of 6 nodes and
find the number of packets dropped due to congestion.

Topology:-

Sender:-
stcp –p 2000 –l 1024 1.0.1.4

Receiver:-
rtcp –p 2000 –l 1024

Command Console:-
Goto tools-> simulation time and change Simulation time to 100. During run mode, double
click host 2 and then click command console. And execute the following command.

ping 1.0.1.4

Parameters:-
Drop Packets and Collision Packets.
Step1: Drawing topology

1. Select/click the SUBNET icon on the toolbar and click the left mouse button on the
editor, to place a SUBNET on the editor.

2. A pop up window appears requesting the number of nodes and radius for the
subnet Set number of nodes=6;
Set radius of subnet >150
3. Click on the “E” icon on the toolbar to save the current topology e.g: file4.tpl
(Look for the ******.tpl extension.)
NOTE: Changes cannot / (should not) be done after selecting

Step2: Configuration

4. Double click the left mouse button while cursor is on a HOST to open the HOST
window.

5. Click NODE EDITOR Button on the HOST window and select the
INTERFACE tab (1st tab) from the modal window that pops up.

6. Determine the IP address of the selected host.

7. Click OK button on the INTERFACE window to exit and once again click on the OK
button on the HOST window to exit.

8. Repeat the above step for 2 other HOSTS

9. Also click NODE EDITOR Button on the HOST window and select the MAC tab
from the modal window that pops up.

10. Select LOG STATISTICS and select checkbox for drop and collision log statistics
in the MAC window

11. Click OK button on the MAC window to exit and once again click on the OK
button on the HOST window to exit.

12. Repeat steps 6 to 9 for the other hosts selected at step 5.

13. Select G_Setting from the menu bar and select Simulation from the drop down list
Set simulation time>600sec

Step3: Simulate

i. Click “R” icon on the tool bar


ii. Select Simulation in the menu bar and click/ select RUN in the dropdown list to
execute the simulation.
iii. During simulation, open a new terminal window.
iv. Type ping IP address of a host in the subnet at the command prompt.
v. To view results, Open up new TERMINAL window, move to file4.results folder
and open drop and collision log files in separate TERMINAL window.
V. Simulate to Compare Data Rate & Throughput

Simulate an Ethernet LAN using N nodes (6-10), change error rate and data rate and compare
throughput.

Topology:-

Sender:-
stcp –p 2000 –l 1024 1.0.1.4

Receiver:-
rtcp –p 2000 –l 1024

Double click on receiver link and change BER to 0.000001, Run Again.

Parameters:-
Throughput of outgoing Packets

Step1: Drawing topology

1. Select/click the HOST icon on the toolbar and click the left mouse button on the editor,
to place HOST1 on the editor.
Repeat the above procedure and place 5 other hosts “HOST2”, “HOST3”, “HOST4”,
“HOST5”, and “HOST6”on the editor.

2. Select/click the HUB icon on the toolbar and click the left mouse button on the editor,
to place HUB1 on the editor.
Repeat the above procedure and place another host “HUB2” on the editor

3. Click on the LINK icon on the toolbar and connect HOST1, HOST2 and HOST3 to
HUB1, HOST4, HOST5 and HOST6 to HUB2.

4. Select/click the SWITCH icon on the toolbar and click the left mouse button on the
editor, to place SWITCH1 on the editor.

5. Click on the LINK icon on the toolbar and connect HUB1 to SWITCH1 and HUB2 to
SWITCH1.

6. Click on the “E” icon on the toolbar to save the current topology e.g: file5.tpl
(Look for the ******.tpl extension.)
NOTE: Changes cannot / (should not) be done after selecting the “E” icon.

Step2: Configuration

1. Double click the left mouse button while cursor is on HOST1 to open the HOST
window.

2. Select Add button on the HOST window to invoke the command window and
provide the following command in the command textbox.
stcp –p 21 –l 1024 1.0.1.4

3. Click OK button on the command window to exit and once again click on the OK
button on the HOST window to exit.

4. Repeat this step at HOST 2 and HOST3, but use different commands
stcp –p 21 –l 1024 1.0.1.5 at HOST2
stcp –p 21 –l 1024 1.0.1.6 at HOST3

5. Double click the left mouse button while cursor is on HOST4 to open the HOST
window.

6. Select Add button on the HOST window to invoke the command window and
provide the following command in the command textbox.
rtcp –p 21 –l 1024

7. Click OK button on the command window to exit.

8. Click NODE EDITOR Button on the HOST window and select the MAC tab from the
modal window that pops up.

9. Select LOG STATISTICS and select checkbox for output throughput in the MAC
window

10. Click OK button on the MAC window to exit and once again click on the OK
button on the HOST window to exit.
11. Repeat this step at HOST 5 and HOST6, but use different commands
rtcp –p 21 –l 1024 at
HOST5 rtcp –p 21 –l 1024
at HOST6

12. Double click the left mouse button while cursor is on HOST5 to open the
HOST window.

13. Click NODE EDITOR Button on the HOST5 window and select
the PHYSICAL tab from the modal window that pops up.

14. Change Bit Error Rate

15. Click OK button on the PHYSICAL window to exit and once again click on the
OK button to return to the HOST window

16. Click NODE EDITOR Button on the HOST window and select the MAC tab from
the modal window that pops up.

17. Select LOG STATISTICS and select checkbox for output throughput in the
MAC window

18. Click OK button on the MAC window to exit and once again click on the OK
button on the HOST window to exit.

19. Repeat this step HOST6, Change Bandwidth this time while undoing the
change in Bit Error Rate, also select the output throughput at HOST6.

Step3: Simulate

i. Click “R” icon on the tool bar


ii. Select Simulation in the menu bar and click/ select RUN in the dropdown
list to execute the simulation.
iii. To start playback select “►” icon located at the bottom right
iv. To view results, Open up new TERMINAL window, move to file5.results folder
and open output throughput log files in separate TERMINAL window.

You might also like