CN Manual Lab (R20)
CN Manual Lab (R20)
CERTIFICATE
This is to Certify that the bonafide record of practical work done in the
InternalExaminer ExternalExaminer
INDEX
S.NO List of Experiments DATE SIGNATURE
Repeater
Hub
Switch
Bridge
Router
Gate Way
practical.
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
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 (layer1) 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.
Switch:
A networkswitchor switching hubis a computer networking device that connects network segments.The
term commonly refers to a network bridge that processes androutes 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 switchesor multilayer switches.
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.1D
standard. 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.
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 upa table showing the preferred paths between any two systems on the interconnected
networks.
Gate Way:
In a communications network, a network node equipped for interfacing with another network that uses different
protocols.
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.
A. protocol translation/mapping gateway interconnects networks with different network protocol
technologies by performing the required protocol conversions.
B. Connect the computers in Local Area Network.
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.
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 Connectionwhenever 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.
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
11. In the Local Area Connection Properties dialog box, click OK.
The Data Link Layer is the second layer in the OSI model, above the Physical Layer, which ensures that the
error free data is transferred between the adjacent nodes in the network. It breaks the datagram’s passed down
by above layers and convert them into frames ready for transfer. This is called Framing. It provides two main
functionalities
Reliable data transfer service between two peer network layers
Flow Control mechanism which regulates the flow of frames such that data congestion is not there at
slow receivers due to fast senders.
What is Framing?
Since the physical layer merely accepts and transmits a stream of bits without any regard to meaning or
structure, it is upto the data link layer to create and recognize frame boundaries. This can be accomplished by
attaching special bit patterns to the beginning and end of the frame. If these bit patterns can accidentally occur
in data, special care must be taken to make sure these patterns are not incorrectly interpreted as frame
delimiters. The four framing methods that are widely used are
Character count
Starting and ending characters, with character stuffing
Starting and ending flags, with bit stuffing
Physical layer coding violations
1. Character Count :
This method uses a field in the header to specify the number of characters in the frame. When the data link layer
at the destination sees the character count,it knows how many characters follow,and hence where the end of the
frame is. The disadvantage is that if the count is garbled by a transmission error, the destination will lose
synchronization and will be unable to locate the start of the next frame. So, this method is rarely used.
2. Character stuffing :
In the second method, each frame starts with the ASCII character sequence DLE STX and ends with the
sequence DLE ETX.(where DLE is Data Link Escape, STX is Start of Text and ETX is End of Text.) This
method overcomes the drawbacks of the character count method.
If the destination ever loses synchronization, it only has to look for DLE STX and DLE ETX characters. If
however, binary data is being transmitted then there exists a possibility of thecharacters DLE STX and DLE
ETX occurring in the data. Since this can interfere with the framing, a technique called character stuffing is
used.
The sender's data link layer inserts an ASCII DLE character just before the DLE character in the data. The
receiver's data link layer removes this DLE before this data is given to the network layer. However character
stuffing is closely associated with 8-bit characters and this is a major hurdle in transmitting arbitrary sized
characters.
3. Bit stuffing :
The third method allows data frames to contain an arbitrary number of bits and allows character codes with an
arbitrary number of bits per character. At the start and end of each frame is a flag byte consisting of the special
bit pattern 01111110 . Whenever the sender's data link layer encounters five consecutive 1s in the data, it
automatically stuffs a zero bit into the outgoing bit stream. This technique is called bit stuffing. When the
receiver sees five consecutive 1s in the incoming data stream, followed by a zero bit, it automatically destuffs
the 0 bit. The boundary between two frames can be determined by locating the flag pattern.
Program Output:
Enter string
MLRITM
Enter position
2
Enter the character
frame after stuffing:
dlestxMdldleLRITMdleetx
Code: // BIT Stuffing program
#include<stdio.h>
#include<string.h>
void main() {
int a[20],b[30],i,j,k,count,n;
printf("Enter frame length:");
scanf("%d",&n);
printf("Enter input frame (0's & 1's only):");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
i=0; count=1; j=0;
while(i<n)
{
if(a[i]==1)
{
b[j]=a[i];
for(k=i+1;a[k]==1 && k<n && count<5;k++)
{ j+
+;
b[j]=a[k];
count++;
if(count==5)
{ j+
+;
b[j]=0;
}
i=k;
}}
else
{
b[j]=a[i];
} i+
+;
j++;
}
printf("After stuffing the frame is:");
for(i=0;i<j;i++)
printf("%d",b[i]);
}
Program Output:
Enter frame length:5
Enter input frame (0's & 1's only):
1
1
1
1
1
After stuffing the frame is:111110
(program exited with code: 6)
EXPERIMENT:3
Checksum:
A checksum is a error detection method in Data Communication. It is used for errors which may have
been introduced during transmission or storage. It is usually applied to an installation file after it is
received from the download server. Checksum method can only detect errors but is unable to correct
the error.
In this method a checksum is calculated based on the given binary strings which is sent with the data
as redundant bits. This data + checksum is received at receiver end and checksum is calculated again,
if checksum is 0 it means no error in data received, else there exists some error in the received data.
For the purpose of this program we are finding checksum for 2 binary strings.
Checksum Program in C
1 #include<stdio.h>
2 #include<string.h>
3
4 int main()
5{
6 char a[20],b[20];
7 char sum[20],complement[20];
8 int i,length;
9
10 printf("Enter first binary string\n");
11 scanf("%s",&a);
12 printf("Enter second binary string\n");
13 scanf("%s",&b);
14
15 if(strlen(a)==strlen(b)){
16 length = strlen(a);
17 char carry='0';
18
19 for(i=length-1;i>=0;i--)
20 {
21 if(a[i]=='0' && b[i]=='0' && carry=='0')
22 {
23 sum[i]='0';
24 carry='0';
25 }
26 else if(a[i]=='0' && b[i]=='0' &&
carry=='1') 27 {
28 sum[i]='1';
29 carry='0';
30
31 }
32 else if(a[i]=='0' && b[i]=='1' &&
carry=='0') 33 {
34 sum[i]='1';
35 carry='0';
36
37 }
38 else if(a[i]=='0' && b[i]=='1' &&
carry=='1') 39 {
40 sum[i]='0';
41 carry='1';
42
43 }
44 else if(a[i]=='1' && b[i]=='0' &&
carry=='0') 45 {
46 sum[i]='1';
47 carry='0';
48
49 }
50 else if(a[i]=='1' && b[i]=='0' &&
carry=='1') 51 {
52 sum[i]='0';
53 carry='1';
54
55 }
56 else if(a[i]=='1' && b[i]=='1' &&
carry=='0') 57 {
58 sum[i]='0';
59 carry='1';
60
61 }
62 else if(a[i]=='1' && b[i]=='1' &&
carry=='1') 63 {
64 sum[i]='1';
65 carry='1';
66
67 }
68 else
69 break;
70 }
71
72 printf("\nSum=%c%s",carry,sum);
73 for(i=0;i<length;i++)
74 {
75 if(sum[i]=='0')
76 complement[i]='1';
77 else
78 complement[i]='0';
79 }
80
81 if(carry=='1')
82 carry='0';
83 else
84 carry='1';
85
86 printf("\nChecksum=%c%s",carry,complement);
87 }
88 else {89
90
91
92
printf("\nWrong input strings");
}
}
Output:
Enter first binary string
101101
Enter second binary string
110010
Sum=1011111
Checksum=0100000
Process exited with return value 17
Press any key to continue……
EXPERIMENT:4
Hamming code:
Hamming code is a popular error detection and error correction method in data communication.
Hamming code can only detect 2 bit error and correct a single bit error which means it is unable
to correct burst errors if may occur while transmission of data.
Hamming code uses redundant bits (extra bits) which are calculated according to the below
formula:- 2
r
≥ m+r+1
Where r is the number of redundant bits required and m is the number of data bits.
R is calculated by putting r = 1, 2, 3 … until the above equation becomes true.
R1 bit is appended at position 2
0
R2 bit is appended at position 2
1
R3 bit is appended at position 2
2
and so on.
These redundant bits are then added to the original data for the calculation of error at receiver’s end.
At receiver’s end with the help of even parity (generally) the erroneous bit position is identified
and since data is in binary we take complement of the erroneous bit position to correct received
data.
Respective index parity is calculated for r1, r2, r3, r4 and so on.
Easy to encode and decode data at both sender and receiver end.
Easy to implement.
Disadvantages of Hamming Code:
Cannot correct burst errors.
Redundant bits are also sent with the data therefore it requires more bandwidth to send the data.
Program:
#include<stdio.h>
void main() {
int data[10];
int dataatrec[10],c,c1,c2,c3,i;
printf("Enter 4 bits of data one by one\n");
scanf("%d",&data[0]); scanf("%d",&data[1]);
scanf("%d",&data[2]);
scanf("%d",&data[4]);
//Calculation of even parity
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("\nEncoded data is\n");
for(i=0;i<7;i++)
printf("%d",data[i]);
printf("\n\nEnter received data bits one by one\n");
for(i=0;i<7;i++)
scanf("%d",&dataatrec[i]);
c1=dataatrec[6]^dataatrec[4]^dataatrec[2]^dataatrec[0];
c2=dataatrec[5]^dataatrec[4]^dataatrec[1]^dataatrec[0];
c3=dataatrec[3]^dataatrec[2]^dataatrec[1]^dataatrec[0];
c=c3*4+c2*2+c1 ;
if(c==0) {
printf("\nNo error while transmission of data\n");
}
else {
printf("\nError on position %d",c);
printf("\nData sent : ");
for(i=0;i<7;i++)
printf("%d",data[i]); printf("\
nData received : "); for(i=0;i<7;i+
+) printf("%d",dataatrec[i]);
printf("\nCorrect message is\n");
//if errorneous bit is 0 we complement it else vice
versa if(dataatrec[7-c]==0)
dataatrec[7-c]=1;
else
dataatrec[7-c]=0;
for (i=0;i<7;i++) {
printf("%d",dataatrec[i]);
}
}}
Output :
Enter 4 bits of data one by
one 1
0
1
0
Encoded data is
1010010
Enter received data bits one by one
1
0
1
0
0
EXPERIMENT:5
CRC method can detect a single burst of length n, since only one bit per column will be changed ,a burst
of length n+1 will pass undetected, if the first bit is inverted, the last bit is inverted and all other bits are
correct.
If the block is badly garbled by a long burst or by multiple shorter burst, the probability that any of the n
columns will have the correct parity that is 0.5.
so the probability of a bad block being expected when it should not be 2 power(-n). This
scheme sometimes is known as Cyclic Redundancy Code.
CRC method:
CRC method can detect a single burst of length n, since only one bit per column will be changed, a burst
of length n+1 will pass undetected, if the first bit is inverted, the last bit is inverted and all other bits are
correct. If the block is badly garbled by a long burst or by multiple shorter burst, the probability that any
of the n columns will have the correct parity that is 0.5. so the probability of a bad block being expected
when it should not be 2 power(-n). This scheme sometimes is known as Cyclic Redundancy Code.
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("mod-ified 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:"); canf("%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
ccit4.exit
Enter your option.1
enter data:1100110011100011
generating polynomial:1100000001111
checksum is:1101110110001
generating polynomial:11000000000000101
Image Source
In sliding window protocol the receiver has to have some memory to compensate any
loss intransmission or if the frames are received unordered.
Selective Repeat: Sender transmits only that frame which is erroneous or is lost.
Go back n: Sender transmits all frames present in the window that occurs after the error bit
including error bit also
.
Program:
#include<iostream>
#include<stdio.h>
#include<sys/types.h>
#include<netinet/in.h>
#include<netdb.h>
#define cls() printf(“33[H33[J”)
//structure definition for designing the packet.
struct frame
{
int packet[40];
};
//structure definition for accepting the acknowledgement.
struct ack
{
int
acknowledge[40];
};
int main()
{
int serversocket;
sockaddr_in serveraddr,clientaddr;
socklen_t len;
int windowsize,totalpackets,totalframes,framessend=0,i=0,j=0,k,l,m,n,repacket[40];
ack acknowledgement;
frame f1;
char req[50];
serversocket=socket(AF_INET,SOCK_DGRAM,0);
bzero((char*)&serveraddr,sizeof(serveraddr));
serveraddr.sin_family=AF_INET;
serveraddr.sin_port=htons(5018);
serveraddr.sin_addr.s_addr=INADDR_ANY; bind(serversocket,
(sockaddr*)&serveraddr,sizeof(serveraddr));
bzero((char*)&clientaddr,sizeof(clientaddr));
len=sizeof(clientaddr);
//connection establishment. printf(“\
nWaiting for client connection.\n”); recvfrom(serversocket,req,sizeof(req),0,
(sockaddr*)&clientaddr,&len); printf(“\nThe client connection obtained.\t%s\
n”,req);
//sending request for
windowsize. printf(“\nSending request for window size.\n”);
sendto(serversocket,”REQUESTFORWINDOWSIZE.”,sizeof(“REQUESTFOR WINDOWSIZE.”),0,
(sockaddr*)&clientaddr,sizeof(clientaddr));
//obtaining windowsize.
printf(“\nWaiting for the windowsize.\n”);
recvfrom(serversocket,(char*)&windowsize,sizeof(windowsize),0,(sockaddr*)&clientaddr,&len);
cls();
printf(“\nThe windowsize obtained as:\t%d\n”,windowsize);
printf(“\nObtaining packets from network layer.\n”);
printf(“\nTotal packets obtained:\t%d\n”,(totalpackets=windowsize*5));
printf(“\nTotal frames or windows to be transmitted:\t%d\n”,(totalframes=5));
//sending details to client.
SELECTIVE REPEATPROTOCOL:
/*Program to demonstrate the working of ‘SELECTIVE REPEAT PROTOCOL’.
This module acts as a client which establishes a connection with the server, sends thewindowsize, accepts
the frames and then sends acknowledgement for each packet wihinthe given frame.
The connection used is UDP and the window size is taken from the user(should be<=40)
It uses two structures viz. ‘frame’ for accepting the frames send by the server and ‘ack’ forsending
the acknowledgement.
Here the acknowledgement for each packet is accepted from the user. The usercan enter -1for negative
acknowledgement or any other integer for positive acknowledgement.
NOTE: This module can be compiled using the command ‘c++ selectiverepeat_server.cpp –o b’ and executed
using the command ‘./b’
PROGRAM:
#include<iostream>
#include<stdio.h>
#include<sys/types.h>
#include<netinet/in.h>
#include<netdb.h>
#define cls()
printf(“33[H33[J”) //structure definition for accepting the packets.
struct frame
{
int packet[40];
};
//structure definition for constructing the acknowledgement frame
struct ack
{
int
acknowledge[40];
};
int main(){
int clientsocket;
sockaddr_in serveraddr;
socklen_t len;
hostent * server;
frame f1;
int windowsize,totalpackets,totalframes,i=0,j=0,framesreceived=0,k,l,m,repacket[40];
ack acknowledgement;
char req[50];
clientsocket=socket(AF_INET,SOCK_DGRAM,0);
bzero((char*)&serveraddr,sizeof(serveraddr));
serveraddr.sin_family=AF_INET;
serveraddr.sin_port=htons(5018);
server=gethostbyname(“127.0.0.1”);
bcopy((char*)server->h_addr,(char*)&serveraddr.sin_addr.s_addr,sizeof(server->h_addr));
//establishing the connection.
printf(“\nSending request to the client.\n”);
sendto(clientsocket,”HI I AM CLIENT.”,sizeof(“HI I AM CLIENT.”), 0, (sockaddr*) & serveraddr, size
of (serveraddr));
printf(“\nWaiting for reply.\n”);
recvfrom(clientsocket,req,sizeof(req),0,(sockaddr*)&serveraddr,&len);
printf(“\nThe server has send:\t%s\n”,req);
//accepting window size from the user.
printf(“\nEnter the window size:\t”);
scanf(“%d”,&windowsize);
//sending the window size.
printf(“\n\nSending the window size.\n”);
sendto(clientsocket,(char*)&windowsize,sizeof(windowsize),0,(sockaddr*)&serveraddr,sizeof(servera
ddr));
cls();
//collecting details from server.
printf(“\nWaiting for the server response.\n”);
recvfrom(clientsocket,(char*)&totalpackets,sizeof(totalpackets),0,(sockaddr*)&serveraddr,&len);
printf(“\nThetotalpacketare:\t%d\n”,totalpackets);
sendto(clientsocket,”RECEIVED.”,sizeof(“REEIVED.”),0,(sockaddr*)&serveraddr,sizeof(serveradd
r));
recvfrom(clientsocket,(char*)&totalframes,sizeof(totalframes),0,(sockaddr*)&serveraddr,&len);
printf(“\nThetotalframes/windowsare:\t%d\n”,totalframes);
sendto(clientsocket,”RECEIVED.”,sizeof(“RECEIVED.”),0,(sockaddr*)&serveraddr,sizeof(serveradd
r));
//starting the process.
printf(“\nStarting the process of receiving.\n”);
j=0;
l=0;
while(l<totalpackets)
{ //initialising the receive
buffer. printf(“\nInitialising the receive buffer.\n”);
printf(“\nThe expected frame is %d with packets: “,framesreceived);
for(m=0;m<j;m++)
{ //readjusting for packets with negative
acknowledgement. printf(“%d “,repacket[m]);
}
while(j<windowsize && i<totalpackets)
{
printf(“%d “,i);
i++;
j++;
}
printf(“\n\nWaiting for the frame.\n”);
//acceptingtheframe. recvfrom(clientsocket,(char*)&f1,sizeof(f1),0,
(sockaddr*)&serveraddr,&len); printf(“\nReceived frame %d\n\nEnter -1 to send negative
acknowledgement for the following
packets.\n”,framesreceived);
//constructing the acknowledgement frame.
j=0;
m=0;
k=l;
while(m<windowsize && k<totalpackets)
{
printf(“\nPacket: %d\n”,f1.packet[m]);
//accepting acknowledgement from the user.
scanf(“%d”,&acknowledgement.acknowledge[m]);
if(acknowledgement.acknowledge[m]==-1)
{
repacket[j]=f1.packet[m];
j++;
}
else
{ l+
+;
} m+
+; k+
+;
}
framesreceived++;
//sendingacknowledgementtotheserver. sendto(clientsocket,
(char*)&acknowledgement,sizeof(acknowledgement),0,(sockaddr*)&server
addr,si zeof(serveraddr));
cls();
}
printf(“\nAll frames received successfully.\n\nClosing connection with the server.\n”);
close(clientsocket);
}
Output:
EXPERIMENT-8
AIM:Write a Program to implement Stop and Wait Protocol.
Implement Stop and Wait Protocol.
#include <conio.h>
#include <dos.h>
#include <stdio.h>
#include <stdlib.h>
#define TIMEOUT 5
#define MAX_SEQ 1
#define TOT_PACKETS 8
define inc(k) if(k<MAX_SEQ) k++; else k=0;
typedef struct
{
int data;
}packet; typedef struct
{
int kind; int seq; int ack;
packet info;
int err;
}frame; frame DATA;
Type def enum{frame_arrival,err,timeout,no_event} event_type;
void from_network_layer(packet *);
void to_network_layer(packet *);
void to_physical_layer(frame *);
void from_physical_layer(frame *);
_*/
void main()
{
clrscr();
randomize();
while(!DISCONNECT)
{
sender();
delay(400);
reciever();
}
getch();
}
/*
_*/
void sender()
{
static int
frame_to_send=0; static
frame s;
packet buffer;
event_type event;
static int flag=0;
if(flag==0)
{
from_network_layer(&buffer);
s.info = buffer;
s.seq = frame_to_send;
printf("SENDER :Info = %d,Seq No =
%d",s.info,s.seq); turn = 'r';
to_physical_layer(&s);
flag = 1;
}
wait_for_event_sender(&event);
if(turn=='s')
{
if(event==frame_arrival)
{
from_network_layer(&buffer);
inc(frame_to_send);
s.info = buffer;
s.seq = frame_to_send;
printf("SENDER : Info = %d Seq No = %d ",s.info,s.seq);
turn = 'r';
to_physical_layer(&s);
}
if(event==timeout)
{
printf("SENDER : Resending Frame ");
turn = 'r';
to_physical_layer(&s);
}
}
}
/*
*/
void reciever()
{
static int frame_expected=0;
frame r,s;
event_type event;
wait_for_event_reciever(&event);
if(turn=='r')
{
if(event==frame_arrival)
{
from_physical_layer(&r);
if(r.seq==frame_expected)
to_{ network_layer(&r.
info);
inc(frame_expected);
}
else
_*/
void from_network_layer(packet *buffer)
{
(*buffer).data = i;
i++;
}
/*
*/
if(turn=='s')
{
timer++;
if(timer==TIMEOUT)
{
*e = timeout;
printf("SENDER : Ack not recieved=> TIMEOUT\n");
timer = 0;
return;
}
if(DATA.err==0)
*e = err;
else
{
timer = 0;
*e = frame_arrival;
}
}
}
wait_for_event_reciever(event_type *
e)
{
if(turn=='r')
{
if(DATA.err==0)
*e = err;
else
*e = frame_arrival;
}
}
OUTPUT:
Theory
The congesting control algorithms are basically divided into two groups: open loop and closed loop .
Open loop solutions attempt to solve the problem by good design, in essence, to make sure it does
not occur in the first place. Once the system is up and running, midcourse corrections are not made.
Open loop algorithms are further divided into ones that act at source versus ones that act at the
destination.
In contrast, closed loop solutions are based on the concept of a feedback loop if there is any congestion.
Closed loop algorithms are also divided into two sub categories: explicit feedback and implicit
feedback. In explicit feedback algorithms, packets are sent back from the point of congestion to warn
the source.
In implicit algorithm, the source deduces the existence of congestion by making local
observation, such as the time needed for acknowledgment to come back.
The presence of congestion means that the load is (temporarily) greater than the resources (in part of
the system)can handle. For subnets that use virtual circuits internally, these methods can be used at the
network layer.
Another open loop method to help manage congestion is forcing the packet to be transmitted at
amorepredictablerate.ThisapproachtocongestionmanagementiswidelyusedinATMnetworksandis called
traffic shaping.
The other method is the leaky bucket algorithm. Each host is connected to the network by an interface
containing a leaky bucket, that is, a finite internal queue. If a packet arrives at the queue when it is
full, the packet is discarded. In other words, if one or more process are already queued, the new packet
is unceremoniously discarded. This arrangement can be built into the hardware interface or simulate d
by the host operating system. In fact it is nothing other than a single server queuing system with
constant service time.
The host is allowed to put one packet per clock tick onto the network. This mechanism turns an
uneven flow of packet from the user process inside the host into an even flow of packet onto the
network, smoothing outbursts and greatly reducing the chances of congestion.
Program:
#include<iostream.h>#include<dos.h>
#include<stdlib.h>#definebucketSize512
voidmain(){
}
Output
Theory:
Dijkstra algorithm is also called single source shortest path algorithm. It is based on greedy technique.
The algorithm maintains a list visited[ ] of vertices, whose shortest distance from the source is already
known.
If visited[1], equals 1, then the shortest distance of vertex i is already known. Initially, visited[i]
is marked as, for source vertex.
At each step, we mark visited[v] as 1. Vertex v is a vertex at shortest distance from thesource vertex.
At each step ofthe algorithm, shortest distance of each vertex is stored inan array distance[ ].
C Program on Dijkstra Algorithm for Finding Minimum (shortest)Distance of Verticesfrom a
Given Source in a Graph
PROGRAM:
C Program on Dijkstra Algorithm for Finding Minimum Distance of Vertices from a Given Program:
#include<stdio.h>
#include<conio.h>
#define INFINITY 9999
#define MAX 105
void dijkstra(int G[MAX][MAX],int n,intstartnode);
int main()
{
int G[MAX][MAX],i,j,n,u;
printf("Enter no. of vertices:");
scanf("%d",&n);
printf("\nEntertheadjacencymatrix:\n");14for(i=0;i<n;i++)
for(j=0;j<n;j++)
scanf("%d",&G[i][j]); printf("\
nEnter the starting node:");
scanf("%d",&u);
dijkstra(G,n,u);
return 0;}
void dijkstra(int G[MAX][MAX],int n,intstartnode)
{
int cost[MAX][MAX],distance[MAX],pred[MAX];
int visited[MAX],count,mindistance,nextnode,i,j;
//pred[] stores the predecessor of each node
//count gives the number of nodes seen so far
//create the cost matrix31for(i=0;i<n;i++)
for(j=0;j<n;j++)
if(G[i][j]==0) cost[i]
[j]=INFINITY; else
cost[i][j]=G[i][j];
//initializepred[],distance[]andvisited[]38for(i=0;i<n;i++)
{
distance[i]=cost[startnode][i];
pred[i]=startnode;
visited[i]=0;
}
distance[startnode]=0;
visited[startnode]=1;
count=1;
while(count<n-1)48{
mindistance=INFINITY;
//nextnode gives the node at minimum distance51for(i=0;i<n;i++)
52if(distance[i]<mindistance&&!visited[i])53{
mindistance=distance[i];
nextnode=i;
}
//check if a better path exists through nextnode
visited[nextnode]=1;
for(i=0;i<n;i++)
if(!visited[i])
if(mindistance+cost[nextnode][i]<distance[i])62{
distance[i]=mindistance+cost[nextnode][i];
pred[i]=nextnode;
}
count++;
}
Output
EXPERIMENT:11
AIM: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).
THEORY:
Distance Vector routing (DVR) algorithm is unlike Dijkstra's algorithm which is a non-adaptive
routing algorithm and means that it is purely static, that is pre-destined and fixed, not flexible in
networks where congestions are more prone to occur.
DVR is an adaptive routing algorithm in which the information from neighbours is
maintained well by each and every node and this helps us to determine the simplest path
possible in a changing network. Though, one of the node may fail, still, the destined node is
reachable through other possible intermediate nodes that are found out by the DVR algorithm.
*/Distance Vector Routing in this program is implemented using Bellman Ford Algorithm:-/*
#include<stdio.h>
struct node
{
unsigneddist[20];
unsignedfrom[20];
}rt[10];
intmain()
{
intcostmat[20][20];
intnodes,i,j,k,count=0;
printf("\nEnter the number of nodes : ");
scanf("%d",&nodes);//Enter the nodes
printf("\nEnter the cost matrix :\n");
for(i=0;i<nodes;i++)
{
for(j=0;j<nodes;j++)
{
scanf("%d",&costmat[i][j]);
costmat[i][i]=0;
rt[i].dist[j]=costmat[i][j];//initialise the distance equal to cost matrix
rt[i].from[j]=j;
}
}
do
{
count=0;
for(i=0;i<nodes;i++)//We choose arbitary vertex k and we calculate the direct distance from the node
i to k using the cost matrix
//and add the distance from k to node j
for(j=0;j<nodes;j++)
for(k=0;k<nodes;k++)
if(rt[i].dist[j]>costmat[i][k]+rt[k].dist[j])
{//We calculate the minimum distance
rt[i].dist[j]=rt[i].dist[k]+rt[k].dist[j];
rt[i].from[j]=k;
count++;
}
}while(count!=0);
for(i=0;i<nodes;i++)
{
printf("\n\n For router %d\n",i+1);
for(j=0;j<nodes;j++)
{
printf("\t\nnode%d via %d Distance %d",j+1,rt[i].from[j]+1,rt[i].dist[j]);
}
}
printf("\n\n");
getch();
}
Output:
A sample run of the program works as:-
Enter the number of nodes :
3
Enter the cost matrix
:027
201
710
For router 1
node 1 via 1 Distance 0
node 2 via 2 Distance 2
node 3 via 3 Distance 3
For router 2
node 1 via 1 Distance 2
node 2 via 2 Distance 0
node 3 via 3 Distance 1
For router 3
node 1 via 1 Distance 3
node 2 via 2 Distance 1
node 3 via 3 Distance 0
EXPERIMENT:12
Theory:
IP addressing is the allocation of unique ID to each and every system connected in a network
to maintan communication among them through out the affixed network.
There are 5 classes of IP Addresses namely A through E with the range varying from one
class to the other class. A subnet is a network allocation to similar systems or same hierarchial
systems present in a allocated network like an organisation.
Each and every system can be reachd through a client-server computing environment where
the server acts as the Master and the clients acts as the Slaves to form a MasterSlave
computing environment. Below programs show the calculation of network addresses with
subnet predefinition and subnet generation.
OUTPUT
(i) PacketCaptureUsingWireshark
Start a Wireshark Capture
To start a Wireshark capture from the Capture Interfaces dialog box:
Observe the available interfaces. If you have multiple interfaces displayed, look for the
interface with the highest packet count. This is your most active network interface.
Select the interface you want to use for the capture using the check box on the left.
Select Start to begin the capture.
capture in Wireshark:
As soon as you click the interface’s name, you’ll see the packets start to appear in real time. Wireshark
captures each packet sent to or from your system.
If you have promiscuous mode enabled—it’s enabled by default—you’ll also see all the other packets
on the network instead of only packets addressed to your network adapter.
To check if promiscuous mode is enabled, click Capture > Options and verify the “Enable promiscuous
mode on all interfaces” checkbox is activated at the bottom of this window.
Click the red “Stop” button near the top left corner of the window when you want to stop capturing
traffic.
Sample capture:
if there’s nothing interesting on your own network to inspect, Wireshark’s wiki has you covered. The
wiki contains a page of sample capture files that you can load and inspect. Click File > Open in
Wireshark and browse for your downloaded file to open one.
You can also save your own captures in Wireshark and open them later. Click File > Save to save your
captured packets.
Figure :Wireshark captures packets and lets you examine their contents.
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.
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.
From Table “The menu items of the “Packet List” pop-up menu”.
From Table , “The menu items of the “Packet Details” pop-up menu”.
If you want to know more about capture modes or discover the features that these two
alternatives provide within Acrylic Wi-Fi products, please visit “Monitor mode and
native capture mode in Acrylic Wi-Fi” article.
Acrylic Wi-Fi Sniffer and WiFi interfaces in Wireshark
This integration is much easier than the previous one. Just install Acrylic Wi-Fi Sniffer and in
the control panel of the sniffer click on the button “Install integration” as shown in the image
below
Acrylic Wi-Fi Sniffer control panel with integration and configuration section highlighted
Once done, start Wireshark as administrator and all Acrylic Wi-Fi Sniffer available interfaces will be
displayed.
Select an interface to use with Acrylic Wi-Fi Sniffer and click on the configuration wheel as
seen in the previous screenshot and configure both channels and bandwidth where the capture
will be carried out.
Once configured, we can start the capture in Wireshark and start receiving packets.
We have added a toolbar in WireShark that allows to quickly change the configuration on-the-
go as shown in the image below
In order to activate it please go to “View” menu > “Interface toolbars” > “Acrylic Wi-Fi
Sniffer interface integration”.
In short, after installing Acrylic Wi-Fi Sniffer we start Wireshark as Administrator (right-click on
Wireshark icon and select “Run as Administrator”) and select any Wi-Fi card that appears with the
name NDIS network interface or Acrylic Wi-Fi Sniffer. In our case “Dell Wireless 1702/b/g/n WiFi
Card” (integrated into Dell equipment) and the “RT8814X” (via Acrylic Wi-Fi Sniffer)
(iv) Analysis and Statistics & Filters
The “Analyze” Menu:
The Wireshark Analyze menu contains the fields shown in Table“Analyze menu items”.
Display Filters… Displays a dialog box that allows you to create and edit display filters. You can
name filters, and you can save them for future use. See Section 6.6, “Defining And
Saving Filters”.
Display Filter Shows a dialog box that allows you to create and edit display filter macros. You can
Macros… name filter macros, and you can save them for future use. See Section 6.7, “Defining
And Saving Filter Macros”.
Apply as Column Shift+Ctrl+I Adds the selected protocol item in the packet details pane as a column to the packet
list.
Apply as Filter Change the current display filter and apply it immediately. Depending on the chosen
menu item, the current display filter string will be replaced or appended to by the
selected protocol field in the packet details pane.
Prepare as Filter Change the current display filter but won’t apply it. Depending on the chosen
menu item, the current display filter string will be replaced or appended to by the
selected protocol field in the packet details pane.
Enabled Shift+Ctrl+E Enable or disable various protocol dissectors. See Section 11.4.1, “The “Enabled
Protocols… Protocols” dialog box”.
Decode As… Decode certain packets as a particular protocol. See Section 11.4.2, “User Specified
Decodes”.
Follow → TCP Open a window that displays all the TCP segments captured that are on the same TCP
Stream connection as a selected packet. See Section 7.2, “Following Protocol Streams”.
Follow → Same functionality as “Follow TCP Stream” but for UDP “streams”.
UDP Stream
Follow → Same functionality as “Follow TCP Stream” but for TLS or SSL streams. See the wiki
TLS Stream page on TLS for instructions on providing TLS keys.
Follow → HTTP Same functionality as “Follow TCP Stream” but for HTTP streams.
Stream
Expert Info Open a window showing expert information found in the capture. Some protocol
dissectors add packet detail items for notable or unusual behavior, such as invalid
checksums or retransmissions. Those items are shown here. See Section 7.4, “Expert
Information” for more information.
The amount of information will vary depend on the protocol
The “Statistics” Menu:
The Wireshark Statistics menu contains the fields shown in Table : “Statistics menu items”.
Capture File Properties Show information about the capture file, see Section 8.2,
“The “Capture File Properties” Dialog”.
I/O Graphs Display user specified graphs (e.g., the number of packets in
the course of time), see Section 8.8, “The “I/O Graphs”
Window”.
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.
EXPERIMENT:15.
Then, Nmap compares the results to its “nmap-os-db” database which contain more than 2600 known
OS fingerprints and print outs any OS details when there is a match.
Metasploitable machine
The actually OS version is 2.6.24 for the Metasploitable machine.
More aggressive Nmap Scan to have a more accurate result:
Change the network to Natnetwork to ensure that the window machine stay in the same network as the
Kali Linux machine.
Start the window machine and open the command prompt to find out the IP address with command
“ipconfig”.
Let’s start the OS detection in windows 10:
First, we try the normal ping command in the terminal to ping the windows machine. The window
system does not responding to the ping requests or we cannot reach the system.
Second, we perform an Nmap ping scan to find out whether the machine is up or not. As a result, the
window machine is up running. Thus, we are unable to reach the system.
Now, I want to scan the top 10 TCP ports of the systems with SYN Scan. The reason parameter is
added to display the reasons of the results. All the port scanned is filtered as there are no responses
from them.
The OS detection is added to the latest Nmap Query and rerun it.In the result, Nmap cannot find the OS
details as it does not have a result set to probe or interrogate.
Enable the Internet Information Services to host a default website of IIS.
Start the Internet Information Services(IIS) Manager to start to host the default website of IIS
.
Open the web browser to reach the website by inserting the IP address of the system into the address bar.
Now, the web service is up.
Now, we test whether if we can reach the IIS website from Kali Linux machine.
If the website is not reachable in Kali machine’s web browser, then you probably need to navigate to the
window defender firewall and allow the HTTP Services. This allows the Kali machine to reach
the Port 80 of the Windows machine.
Run the SYN Scan for the Windows machine(IP address:10.0.2.5) top 10 ports. Here, we notice that the
port 80 is now open.
Now, we reply the scan with OS detection option. Now, we have the OS detection result. First,
Nmap warn us about the OS Scan is unreliable as nmap couldn’t find at least 1 open and 1
closed port to probe from. Here, we only able to find out that 85% is Windows XP SP2. Thus, we
only know the guessing of the Window Machine OS. However, the result is not accurate.
EXPERIMENT-16
AIM: Do the following using NS2 Simulator
i. NS2Simulator-Introduction
ii. Simulate to Find the Number of Packets Dropped
iii. Simulate to Find the Number of Packets Dropped by TCP/UDP
iv. Simulate to Find the Number of Packets Dropped due to Congestion
v. Simulate to Compare Data Rate& Throughput
NS2 Simulator Tutorial for Beginners is one of our prime services started for the beginners,
who wish to learn NS-2 completely. It is also a widespread network simulator used by
majority of students and scholars today.
Our Tutorial for Beginners provides basic information about NS2, which can be utilized
by students to get an idea about NS-2. Right start is the key for right success.
This is the reason; we focus on guiding the beginners as they are like mud which can be
molded in any ways.
We mold our students in a perfect way to make them to walk towards the right path of success.
Also, We start our guidance from the basics of NS-2 and support until the student becomes an
expert of NS-2. Along with tutoring service on NS-2, we offer support for NS-2 based
projects, assignments, lab cycles etc. As a step towards our guidance, we also have provided
few basic concepts of NS2 below, for students to get some knowledge about NS-2.
NS-2 BASICS:
It is also an open source simulator widely used for Educational and research purpose.
Two major things one must know about it, is also the language used in it and it’s
supported Networks. It is also basically implemented in OTCL [Object oriented extension
of TCL].
Two major languages, it also supports are C++ and TCL [Tool command language]. It
is also used to simulate both wired and wireless Networks [Mobile Ad hoc Networks,
Wireless sensor Networks, Wireless body area network etc].
Simulation in NS2 is based on the following constraints i.e. Node creation and also
configuration, Node color description, creation of duplex links and also orientations,
labeling of Nodes, establishing queuing methods, TCP and also UDP connection and
data transmission.
INTRODUCTION
The Network Simulator offers a simplified and complete network simulation experience.
The following diagram depicts this functionality offered by the Network Simulator
The Network Simulator can design and simulate a network with
SNMP,TL1,TFTF,FTP,Telnet and IOS devices , in four simple steps:
Add devices to the Device tree: Add devices with the required configuration to the device tree
in the Network Designer. Preconfigured devices are also bundled with the toolkit.
Create the Network: Create and add bulk devices to the network, at one shot.
Configure the Network devices : Configure the devices in the network, if required.
Start the Network : Start the network or start individual agents in the network. The MIB
Browser and
TL1 Craft Interface test tools, can be used as the manager tools for testing.
Network Emulation: Network emulation refers to actual network traffic passing through
some software which might do some analysis or perhaps modify the traffic in some way. The
Emulation Network in the WAND group is used for testing and evaluation of networking
software and hardware.
The scale is limited; it is made up 24 emulation machines and one central controlling
computer. Setup of such a network is time consuming and expensive: in addition to the
aforementioned 25 computers, a Cisco2950 switch and a Cyclades 32 port terminal server are
included in the network.
Each emulation machine also has a 4 port network interface controller. The controlling
machine includes special capture cards (known as DAG [6] cards) to allow easier capture and
processing of network traffic. This network has no easy way of adding latency and bandwidth
bottlenecks, which means creating adverse conditions on the network is difficult. It is possible
to use Dummynett.add latency, but this is a lot of work.
There is a project to solve this issue; a non blocking crossbar Ethernet switch is being created
for the network ,but the cost involve dislarge.
Other network emulation done in the WAND group include validating the WAND
simulator. This was done by setting up a physical network with FreeBSD machines using
Dummynet to add latency. Dummynet is one example of network emulation software, NIST
Net is another,
it claimsto “allow controlled ,reproducible experiments with network performance
sensitive/adaptive applications and control protocols in a simple laboratory
setting”.
NS-2 also provides some network emulation functionality, it is able to capture packets from
the live network and drop, delay, re-order, or duplicate them. Emulation, especially in the case
of a network simulator like NS-2, is interesting because it is using real world data from real
world network stacks.
Emulation offers something simulation never can: it is performed on a real network, using
actual equipment and real software. However, it is very limited compared to simulation in
other areas; for example scale.
The WAND Emulation Network described earlier requires a lot of setup and is expensive,
yet only contains 24emulation machines. There is no theoretical limit to the number of nodes
a simulator can handle, and increasing the size of a simulation does not cost anything.
The factors to consider are RAM, disk space and the small amount of time taken to change
a simulation script. In general, changing the simulation is a simple step, though it would be
complex in the case a huge amount of nodes being required (a million, for example).
Also, network emulation must of course be run in real time, where simulation can sometimes
simulate large time periods in a small amount of time. In the case of a million nodes, the
simulation might run in greater than real time because the hardware it is run on would limit
performance.
Introduction to Network Simulators
Network simulators implemented in software are valuable tools for researchers to develop,
test, and diagnose network protocols.
Simulation is economical because it can carry out experiments with out the actual hardware.
It is flexible because it can, for example, simulate a link with any bandwidth and
propagation delay.
Simulation results are easier to analyze than experimental results because important information
at critical points can be easily logged to help researchers diagnose network protocols.
Network simulators, however, have their limitations. A complete network simulator needs to
simulate networking devices (e.g., hosts and routers) and application programs that generate
network traffic.
It also needs to provide network utility programs to configure, monitor, and gather
statistics about a simulated network. Therefore, developing a complete network simulator
is a large effort.
Due to limited development resources, traditional network simulators usually have the
following drawbacks:
Simulation results are not as convincing as those produced by real hardware and
software equipment . Inorder to constraint their complexity and development cost ,most
network simulators
Usually can only simulate real-life network protocol implementations with limited details,
and this may lead to incorrect results.
These simulators are not extensible in the sense that they lack the standard UNIX
POSIX application programming interface(API). As such ,existing or to-be-developed
real-life application programs can not run normally to generate traffic for a simulated
network
.Instead, they must be rewritten to use the internal API provided by the simulator (if there
is any)and be compiled with the simulator to form a single ,big, and complex program.
To overcome these problems, Wang invented a kernelre-entering simulation methodology and
used it to implement the Harvard network simulator. Later on, Wang further improved the
methodology and used it to design and implement the NCTU nsnetwork simulator and
emulator.
REAL
Use
NESTisintendedforstudyingthedynamicbehaviorofflowandcongestioncontrolschemesinpacket-switched
data networks (namely TCP/IP).
The package
REAL provides 30 modules written in C that emulate flow-control protocols such as TCP, and 5
scheduling disciplines such as FIFO, Fair Queuing, DEC congestion avoidance and Hierarchical Round
Robin.
The NEST code has been rewritten to make it less general, cleaner and faster. REAL is
still implemented as a client-server program. The code is freely available to anyone willing
to modify it.
Node functions implement computation at each node in the network whereas queue
management and routing functions manage buffers in nodes and packet switching.
Routing is static and is based on Dijkstras's shortest path algorithm. A node could be a source,
a router or a sink. Source nodes implement TCP-like transport layer functionality. Routers
implement the scheduling disciplines, while the sinks are universal receivers that only
acknowledge packets.
Since NEST didn't not allow for timers, REAL sends out a timer packet from a source back to
it self to return after some specified time, but timers cannot be reset using this method.
Simulate at three-node point-to-point network with a duplex link between them .Set the
queue size and vary the band width and find the number of packets dropped.
STEPS:
Step1: Select the hub icon on the tool bar and drag it on to the working window.
Step3: Select the link icon on the toolbar and drag it on the screen from host (node 1) to the hub and
again from host(node 2) to the hub. Here the hub acts as node 3 in the point-to-point network. This
leads to the creation of the 3-node point-to-point network topology. Save this topology as a .tpl file.
Step4:Double-click on host(node 1), a host dialog box will open up. Click on Node editor and you can
see the different layers- interface, ARP, FIFO, MAC, TCPDUMP, Physical layers.
Select MAC and then select full-duplex for switches and routers and half duplex for hubs,
and in log Statistics, select Number of Drop Packets, Number of Collisions, Throughput of
incoming packets and Throughput of outgoing packets.
Select FIFO and set the queue size to50 and press OK. Then click on Add. Another dialog
box popsup. Click on the Command box and type the Command according to the following
syntax:
Step5:Double-click on host(node2),and follow the same step as above with only change in command
according to the following syntax:
rtg[-t][-w log][-pportnumber] and click OK.
Step6: Double click on the link between node1 and the hub to set the bandwidth to some initial
Value say, 10Mbps. Repeat the same for the other node.
Step 7:Click on the E button (Edit Property)present on the toolbar in order to save the changes made
to the topology.
Now click on the R button (Run Simulation).
By doing so a user can run/pause/continue/stop/abort/disconnect/reconnect/submitasimulation.No
simulations settings can be changed in this mode.
Step9:To start the play back, the user can left-click the start icon (|>) of the time bar located at the
bottom. The animation player will the n start playing there corded packet animation.
Step10:Changethebandwidth say, 9Mbps, and run the simulation and compare the two results.
16.2Simulate 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.
STEPS:
Step1:Create the topology as specified in the question, in the draw mode of the simulator.
Step6:Toview the result agents changing the parameters and determine the number of packets sent by
two agents.
The screen shot of the topology is shown below:
.
16.3)Simulate the transmission of pingmessagesoveranetworktopologyconsistingof6nodesandfind the
number of packets dropped due to congestion.
STEPS:
Step 3: In the edit mode, get the IP address of one of the hosts say, host 1 and then for
theotherhostsay,host2set the drop packet and no: of collisions statistics as described in the
earlier experiments.
Step4:Nowrunthesimulation.
Step5:Now click on anyone of the hosts and click on command console and ping the
destination node.
Ping IP Address of the host.
Note:Theno:ofdroppacketsareobtainedonlywhenthetrafficismoreinthenetwork.Forcheckingtheno of
packets dropped press ctrl+C.
STEPS:
Step2:SetupaTCPconnection between a host on one hub and host on another hub using
the following command:
Step3:Setuptheerror rate, data retain the physical layer, input and output through put in the mac layers
described above.