You are on page 1of 75

Ex. No.

: 1 a)
IMPLEMENTATION OF NETWORK TOPOLOGY
Date :
-BUS

AIM
To implement the Bus topology for pocket communication between a number of
nodes connected to a common bus.

APPARATUS REQUIRED
Personal Computer , Data Communication Lan , Trainer Kit.

PROCEDURE
1. From the menu bar , Select Bus Topology option then it shows the Sender and
Receiver window of Bus Topology.

2. Open this window in both side like Receiver and Sender.In Receiver window
shows the Computer Name,Mac Address,Local IP and PORT and received data
to be displayed.

3. In the Sender window set the number of Node,Transmitter node.IP address of


the node.Then enter the data in the data to be sent files & Then click Send
button to which node you want to send the data.

RESULT
Thus the Implementation for Bus Topology connected and implemented
Successfully.

2
Ex. No. : 1 b)
IMPLEMENTATION OF NETWORK TOPOLOGY
Date :
-STAR

AIM
To Implement the ALOHA Protocol for Pocket Communication between a number of
nodes connected to a common bus.

APPARATUS REQUIRED
Personal Computer, Data Communication Lan ,Trainer Kit.

PROCEDURE
1. From the menu bar,Select Star Topology option.Then it shows the sender and
receiver window of star Topology.

2. Open this window in both side like Receiver and Sender.In receiver window
shows the Computer Name,MAC address,Local IP and PORT and received
data to be displayed.

3. In the Sender window set the number of node,Transmitter node, IP address of


the node .Then enter the data in the data to be sent field & then click send
button to which node you want to send the data.

RESULT
Thus the Implement for Star Topology Connected and implemented Successfully

4
Ex. No. : 2
IMPLEMENTATION OF STOP AND WAIT PROTOCOL
Date :

AIM
To Provide reliable Data transfer between two nodes over an Unreliable Network using
the Stop and Wait Protocol.

APPARATUS REQUIRED
Personal Computer, Data Communication Lan, Trainer Kit.

PROCEDURE

TRANSMITTER
1. From the menu bar, select Stop and Wait.Open Transmitter in Client side and
Receiver in Sender side.

2. Change the Remote IP field,if you want to Communicate with other than given
IP.Then click on connect button to establish connection with remote host.you can edit
Data rate to Change data flow speed .you can change Inter packet Delay and Packet
size also. If you want to send data, enter data in Data to be sent field , Click on send
button. To generate error remove data from Error Bit. Disconnect button is used to
terminate Connection from button is used to Terminate Connection from remote
host. To use click on Quit button.

PERFORMANCE ANALYSIS
CALCULATION:
Transmission Time = Packet Size ×No. of Packets ×8µ sec

1000000

CASE Ⅰ
(i) We will keep following parameters constant

Data Rate : 2.5Mbps

Packet size : 64 Bytes

We will vary the No.of packets from 1 to 13 in step 1 and corresponding time taken for the
Data transfer will be noted and a plot of No.of packets Vs time can be viewed & printout can
be taken.

6
(ii) We will keep the following parameter constant

Data Rate : 5.0 Mbps

Packet Size : 64 Bytes

We will vary the No.of Packets from 1 to 13 in step 1 and Corresponding time taken
for the Data transfer will be noted and a plot No.of Packet Vs time can be Viewed and
Printout can be Taken.

(iii) We will keep the following Parameter constant

Data Rate : 7.5 Mbps

Packet size : 64 Bytes

We will Vary the No.of Packet from 1 to 13 in step in 1 and Corresponding time taken
for Data transfer will be noted and plot of No.of Packets Vs time can be Viewed &
printout can be Taken.

(iv) We will keep the following Parameter constant.

Data Rate : 10 Mbps

Packet size : 64 Bytes

We will Vary the No.of Packet from 1 to 13 in step in 1 and Corresponding time taken
for Data transfer will be noted and plot of No.of Packets Vs time can be Viewed &
printout can be Taken.

CASE Ⅱ
(i) We will keep the following Parameter constant.

Data Rate : 2.5 Mbps

Packet size : 128 Bytes

We will Vary the No.of Packet from 1 to 13 in step in 1 and Corresponding time taken
for Data transfer will be noted and plot of No.of Packets Vs time can be Viewed &
print it.

(ii) We will keep the following Parameter constant.

Data Rate : 5.0 Mbps

Packet size : 128 Bytes

We will Vary the No.of Packet from 1 to 13 in step in 1 and Corresponding time taken
for Data transfer will be noted and plot of No.of Packets Vs time can be Viewed &
print it.

8
(iii) We will keep the following Parameter constant.

Data Rate : 7.5 Mbps

Packet size : 128 Bytes

We will Vary the No.of Packet from 1 to 13 in step in 1 and Corresponding time taken
for Data transfer will be noted and plot of No.of Packets Vs time can be Viewed &
print it.

(iv) We will keep the following Parameter constant.

Data Rate : 10 Mbps

Packet size : 128 Bytes

We will Vary the No.of Packet from 1 to 13 in step in 1 and Corresponding time taken
for Data transfer will be noted and plot of No.of Packets Vs time can be Viewed &
print it.

RECEIVER
From the menu bar, Select stop & wait→Receiver.The Stop and Wait receiver
window will be shown.

RESULT
Thus the Stop and Wait Protocol connected and implemented successfully.

10
Ex. No. : 3 a)
IMPLEMENTATION OF GO BACK N PROTOCOL
Date :

AIM
To provide reliable Data transfer between two nodes over an unreliable network using
the sliding window Go Back N Protocol.

APPARATUS REQUIRED
Personal Computer,Data Communication Lan ,Trainer kit.

PROCDURE
TRANSMITTER
1) From the menu bar,select Ethernet Trainer →Go Back N. Open Transmitter in Client
side and receiver in server side.

2) Change the Remote IP field, if you want to communicate with other than given
IP.Then click on connect Button to establish connection with Remote Host. You can
edit Data rate to change data flow speed . You can change Inter Packet Delay and
Packet size also. If you can want to send data , enter data in Data to be sent field
,Click on send button.

3) To generate error remove the Error Bit. Disconnect Button is used to terminate
connection is established or not.Click on Quit Button .

RECEIVER
From the menu bar,Select Go back N→ Receiver

RESULT
Thus the Implementation for Go back N was received successfully.

12
Ex. No. : 3 b)
IMPLEMENTATION OF SELECTIVE REPEAT PROTOCOL
Date :

AIM
To provide reliable Data transfer between two nodes over an unreliable network using
the sliding window Selective Repeat Protocol.

APPARATUS REQUIRED
Personal Computer,Data Communication Lan ,Trainer kit.

PROCDURE
TRANSMITTER
1) From the menu bar, select Selective repeat→ transmitter in client side and Receiver in
server side. Transmitter window looks like as drawn.

2) Change the Remote IP field, if you want to communicate with other than given
IP.Then click on connect Button to establish connection with Remote Host. You can
edit Data rate to change data flow speed . You can change Inter Packet Delay and
Packet size also. If you can want to send data , enter data in Data to be sent field
,Click on send button.

3) To generate error remove the Error Bit. Disconnect Button is used to terminate
connection is established or not.Click on Quit Button .

RECEIVER
From the menu bar, select ethernet trainer→ Selective Repeat → receiver.

The Selective repeat receiver window.

RESULT
Thus data transfer between two nodes over an unreliable network using sliding
Window Protocol.

14
Ex. No. : 4 a)
IMPLEMENTATION OF CSMA/CD PROTOCOL
Date :

AIM
Implement the CSMA/CD Protocol for Packet Communication between a number of
nodes Connected to Common bus.

APPARATUS REQUIRED
Personal computer,Data Communication LAN Trainer kit.

PROCEDURE
TRANSMITTER 1:
1. From the Menu bar,Select CSMA→CSMA/CD→Transmitter 1.

2. In that, Window give the data rate.Time out and Tx data to be


transmitted. Then click the connect button to know the status and send
the data.

TRANSMITTER 2:
1. From the Menu bar,Select CSMA→CSMA/CD→Transmitter 2.

2. In that window give the data rate, time out and Tx data to
transmitted. Then click the button to know the status and send the
data.

RECEIVER
In receiver window , it shows the data which has been Transmitted from
Transmitter 1 and Transmitter 2.

16
RESULT
Thus the implementation of CSMA/CD Protocol connected and implemented
successfully.
18
Ex. No. : 4 b)
IMPLEMENTATION OF CSMA/CA PROTOCOL
Date :

AIM
Implement the CSMA/CA Protocol Communication between a number of nodes
connect to a Common Bus.

APPARATUS REQUIRED
Personal Computer, Data Communication LAN trainer Kit.

THEORY
Carrier sense Multiple Access with collision Avoidance (CSMA/CA) in Computer
networking .It is a wireless network multiple access method in which:

1. A carrier sensing scheme is used.

A node wishing to transmit Data has to first listen to the Channel for a Predetermined
amount of time to determine whether (or) not another node is transmitting.

CSMA/CA is a modification of pure carrier sense Multiple Access (CSMA).Collision


avoidance is use to improve CSMA performance by not allowing wireless transmission
of a node it another node is transmitting.Thus reducing the Probability of collision due to
the use of a random time.Optionally But almost always implemented an IEEE802.11
RTS/CTS exchange can be required to better handle situations such as the hidden node
problem in wireless networking.

CSMA/CA is a layer 2 access method,not a protocol of the OSI


model.A node wishing to send data initiates the process by sending a request to send
frame (RTS).The destination anode replies with a clear to send frame (CTS).Any other
node receiving the RTS (or) CTS frame should refrain from sending data for a given
time.The amount of time the node should wait before trying to get access to the medium
is included in both RTS & CTS frame.

This protocol was designed under the assumption that all nodes
have the same transmission range. RTS/CTS is an additional method to implement
Virtual carrier sensing in carrier sense multiple access with collision avoidance. By
default, 802.11 relies on physical carrier sensing anly which is known to suffer from the
hidden terminal problem. RTS/CTS Packet size threshold is 0.2347 octets. Typically
,sending RTS/CTS frames does not occur unless the packet size the node wants to
transmit is larger than the threshold. The RTS/CTS Handshake gets triggered. Otherwise
the data frame gets sent immediately. RTS/CTS packets carry the expected duration of
the data transmission which will have some implicatons.

20
PROCEDURE
TRANSMITTER 1:
1. From the menu bar select CSMA→CSMA/CA→ Transmitter 1.

2. In the window give the Data rate, Time out & Tx data to be transmitted. Then click
the connect button to know status.

TRANSMITTER 2:
1. From the menu bar select CSMA→CSMA/CA→ Transmitter 2.

2. In the window give the Data rate, Time out & Tx data to be transmitted. Then click
the connect button to know status.

RECEIVER:
In the receiver window shows the data which has been transmitted from
transmitter 1 and 2.

RESULT:
Hence the Implementation of CSMA/CA was executed Successfully.

22
Ex. No. : 5
IMPLEMENTATION OF DISTANCE
Date :
VECTOR ROUTING

AIM:
To implement the distance vector routing algorithm.

APPARATUS REQUIRED:
1. PENTIUM – PC

2. C COMPLIER

3. TURBO C

PRINCIPLE:
It is under dynamic routing algorithm. This algorithm operates by having each route
maintains a table giving the least known distance to reach destination and include line in used
to get these. These are updated by changing information with neighbour. This is called “Bell
mann ford algorithm” and “fod fick” algorithm.

PROCEDURE:
1. Open the Cisco Packet Tracer software.

2. Add the router and PCs accourding to our design.

3. Configure all the routers and PCs.

4. Trace the destination in PC’s command prompt.

5. Verify the output.

DISTANCE ROUTING ALGORITM:


#include<stdlib.h>
#define nul 1000
#define nodes 10
int no;
struct node
{
int a[nodes][4];
}router[nodes];
void init(int r)
{
int i;
for(i=1;i<=no;i++)
{
router[r].a[i][1]=i;
router[r].a[i][2]=999;
router[r].a[i][3]=nul;

24
}
router[r].a[r][2]=0;
router[r].a[r][3]=r;
}
void inp(int r)
{
int i; printf("\nEnter distance from the node %d to other nodes",r);
printf("\nPls Enter 999 of there is no direct route\n",r);
for(i=1;i<=no;i++)
{
if(i!=r)
{
printf("\nEnter dist to node %d:",i);
scanf("%d",&router[r].a[i][2]);
router[r].a[i][3]=i;
}
}
}
void display(int r)
{
int i,j;
printf("\n\nThe routing table for node %d is as follows:",r);
for(i=1;i<=no;i++)
{
if(router[r].a[i][2]>=99)
printf("\n\t\t\t%d\tno link\tno hop",router[r].a[i][1]);
else
printf("\n\t\t\t%d\t\t%d",router[r].a[i][1],router[r].a[i][2],router[r].a[i][3]);
}
}
void dv_algo(int r)
{
int i,j,z;
for(i=0;i<=no;i++)
{
if(router[r].a[i][2]!=999&&router[r].a[i][2]!=0)
{
for(j=1;j<=no;j++)
{
z=router[r].a[i][2]+router[i].a[j][2];
if(router[r].a[j][2]>z)
{

router[r].a[j][2]=z;
router[r].a[j][3]=i;
}
}
}

26
}
}
int main()
{
int i,j,x,y;
char choice;
printf("Enter the no.of nodes required(less than 10 pls):");
scanf("%d",&no);
for(i=1;i<=no;i++)
{
init(i);
inp(i);
}
printf("\nTne configuration of the nodes after initialization is as follows:");
for(i=1;i<=no;i++)
display(i);
for(i=1;i<=no;i++)
dv_algo(i);
printf("\nThe configuration of the nodes after computation of paths is as follows:");
for(i=1;i<=no;i++)
display(i);
while(1)
{
printf("\n\nWanna continue (y/n):");
scanf("%c",&choice);
if(choice=='n') break;
printf("\nEnter the nodes btn which the shortest path is to be found:\n");
scanf("%d%d",&x,&y);
printf("\nThe length of the shortest path is %d",router[x].a[y][2]);
}
}

RESULT:
Thus the distance vector routing algorithm was implemented and the output was
verified successfully.

28
Ex. No. : 6
IMPLEMENTATION AND STUDY OF ENCRYPTION AND
Date : DECRYPTION

AIM
To study and implement the process of Encryption and Decryption.

APPARATUS REQUIRED
1. PENTIUM – PC

2. C COMPLIER

3. TURBO C.

PRINCIPLE:

CRYPTOGRAPHY (secret writing) is the process which uses the encryption and
decryption algorithm. An encryption algorithm transforms the plain-text into ciphertext
(unknown format) and decryption algorithm transforms the ciphertext back into plain-text.
The sender uses an encryption algorithm to send the information in the unknown format and
the receiver uses a decryption algorithm to retrieve the original information.

ALGORITHM:

CLIENT:

• Start the program.

• Initialize the socket for connection establishment.

• Write the message.

• Convert the message to hexcode format.

• Display the message to the server.

• Close all objects.

• Stop.

SERVER:

• Start the program.

• Initialize the server socket 22 .

• Display waiting for connection.

• Display hexcode received from client.

30
• Initialize a new string builder.

• Transform the hexcode into the string format using the string builder.

• Display the decrypted message.

• Close all objects.

• Stop.

ENCRYPTION AND DECRYPTION PROGRAM


#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
unsigned long modexp(unsigned long msg,unsigned long exp,unsigned long n)
{
unsigned long i,k=1;
for(i=0;i<exp;i++)
k=(k*msg)%n;
return k;
}
int main()
{
unsigned long p,q,e,d,n,z,i,C,M;
int len;
char data[100];
system("clear");
printf("\nEnter the value of P and Q(such that p*q>255 and p not equal to q)\n");
scanf("%lu%lu",&p,&q);
n=p*q;
z=(p-1)*(q-1);
for(i=1;i<z;i++)
{
if((z%i)==0)
continue;
else
break;
}
e=i;
printf("\nEncryption key is:%lu",e);
for(i=1;i<z;i++)
if(((e*i-1)%z)==0)
break;
d=i;
printf("\nDecryption key is:%lu",d);
printf("\nPls enter the message:");
scanf("%s",data);

32
len=strlen(data);
for(i=0;i<len;i++)
{
M=(unsigned long)data[i];
C=modexp(M,e,n);
printf("\nEncrypted value its char representation:%lu\t%c\t\n",C,C);
M=modexp(C,d,n);
printf("\nDecrypted value and its char representation:%lu\t%c\t\n",M,M);
}
return 0;
getch();
}

RESULT:
Thus the encryption and decryption concept using java is implemented and verified
successfully.

34
Ex. No. : 7
IMPLEMENTATION OF LINK STATE ROUTING
Date :

AIM:
To implement link state routing algorithm.

APPARATUS REQUIRED:
1. PENTIUM – PC

2. C COMPLIER

3. TURBO C

PRINCIPLE:
Link state routing works on the following principle.

* Discover the neighbour and keep their network address.

* Measure the delay or cost to each of its neighbour.

* Construct a packet telling all it has just learned.

* Send the packet to all router.

* Compute the shortest path to every router.

PROCEDURE:

* Open the Cisco Packet Tracer software.

* Add the router and PCs according to our design.

* Configure all the routers and PCs.

* Trace the destination in PC’s command prompt.

* Verify the output.

LINK STATE ROUTING:


#include<stdio.h>
#include<conio.h>
#include<process.h>
#include<string.h>
#include<math.h>
#define IN 99
#define N 6
int dijkstra(int cost[][N],int source,int target);
char

36
interface[6][6][20]={{"0","0","0","0","0","0"},{"0","0","192.1.1.1","0","200.1.1.1"},{"0","0"
,"0","0","198.1.1.2","0"},{"0","192.1.1.3","0","198.1.1.3","0","200.1.1.2"},{"0","0","200.1.1
.3","0","200.1.1.4","0"}};
int main()
{
int cost[N][N],i,j,w,ch,co;
char ip[10];
int source,target,x,y;
printf("\t the shortest path algorithm(DIJKSRTRA'S ALGORITHM in c\n\n");
for(i=1;i<N;i++)
for(j=1;j<N;j++)
cost[i][j]=IN;
for(x=1;x<N;x++)
{
for(y=x+1;y<N;y++)
{
printf("enter the weight of the path between node%d and %d:",x,y);
scanf("%d",&w);
cost[x][y]=cost[y][x]=w;
}
printf("\n");
}
for(x=1;x<N;x++)
{
for(y=1;y<N;y++)
{
printf("%s:\t",interface[x][y]);
//scanf("%s",&ip);
//interface[x][y][20]=ip;
}
printf("\n");
}
printf("\nEnter the source:");
scanf("%d",&source);
printf("\nEnter the target");
scanf("%d",&target);
co=dijsktra(cost,source,target);
printf("\nThe Shortest Path:%d",co);
return 0;
}

int dijsktra(int cost[][N],int source,int target)


{
int dist[N],prev[N],selected[N]={0},i,m,min,start,d,j,x,y;
char path[N];int path1[N];
for(i=0;i<N;i++)
{
dist[i]=IN;
prev[i]=-1; }
start=source;

38
selected[start]=1;
dist[start]=0;
while(selected[target]==0)
{
min=IN;
m=0;
for(i=1;i<N;i++)
{
d=dist[start]+cost[start][i];
if(d<dist[i]&&selected[i]==0)
{
dist[i]=d;
prev[i]=start;
}
if(min>dist[i]&&selected[i]==0)
{
min=dist[i];
m=i;
}
}
start=m;
selected[start]=1;
}
start=target;
j=0;
while(start!=-1)
{
path[j++]=start+64;
path1[j++]=start;
start=prev[start];
}
path[j]='\0';
strrev(path);
printf("%s",path);
printf("\n");
for(j=j-1;j>=0;j--)
{
printf("%d\t",path1[j]);
if(j>0)
{
x=path1[j];
y=path1[j-1];
printf("%s\t%s\n",interface[x][y],interface[y][x]);
}
}
return dist[target];
}

40
RESULT:
Thus the link state algorithm was implemented and the output was verified successfully.

42
Ex. No. : 8
STUDY OF NETWORK SIMULATOR AND SIMULATION OF
Date : CONGESTION CONTROL ALGORITHMS USING NS .

AIM :
To Study of Network simulator (NS).and Simulation of Congestion Control
Algorithms using NS.

Introduction: ns (from network simulator) is a name for series of discrete event


network simulators, specifically ns-1, ns-2 and ns-3. All of them are discrete-event network
simulator, primarily used in research[4] and teaching. ns-3 is free software, publicly available
under the GNU GPLv2 license for research, development, and use.
The goal of the ns-3 project is to create an open simulation environment for networking
research that will be preferred inside the research community.

• It should be aligned with the simulation needs of modern networking research.


x It should encourage community contribution, peer review, and validation of
the software.

• Since the process of creation of a network simulator that contains a sufficient number
of highquality validated, tested and actively maintained models requires a lot of work,
ns-3 project spreads this workload over a large community of users and developers.

Ns-1
The first version of ns, known as ns-1, was developed at VJ,GEEKLIME, Madurai
(LBNL) in the 1995-97 timeframe by Steve McCanne, Sally Floyd, Kevin Fall, and other
contributors. This was known as the LBNL Network Simulator, and derived from an earlier
simulator known as REAL by S. Keshav. The core of the simulator was written in C++, with
Tcl-based scripting of simulation scenarios.[5] Long-running contributions have also come
from Sun Microsystems, the UC Berkeley Daedelus, and Carnegie Mellon Monarch
projects.it used.
Ns-2
In 1996-97, ns version 2 (ns-2) was initiated based on a refactoring by Steve McCanne.
Use of Tcl was replaced by MIT's Object Tcl (OTcl), an object-oriented dialect Tcl. The core
of ns-2 is also written in C++, but the C++ simulation objects are linked to shadow objects in
OTcl and variables can be linked between both language realms. Simulation scripts are
written in the OTcl language, an extension of the Tcl scripting language. Presently, ns-2
consists of over 300,000 lines of source code, and there is probably a comparable amount of
contributed code that is not integrated directly into the main distribution (many forks of ns-2
exist, both maintained and unmaintained). It runs on GNU/Linux, FreeBSD, Solaris, Mac OS
X and Windows versions that support Cygwin. It is licensed for use under version 2 of the
GNU General Public License.

Ns-3

44
A team led by Tom Henderson, George Riley, Sally Floyd, and Sumit Roy, applied for
and received funding from the U.S. National Science Foundation (NSF) to build a
replacement for ns-2, called ns-3. This team collaborated with the Planete project of INRIA at
Sophia Antipolis, with Mathieu Lacage as the software lead, and formed a new open source
project.In the process of developing ns-3, it was decided to completely abandon
backwardcompatibility with ns-2. The new simulator would be written from scratch, using
the C++ programming language. Development of ns-3 began in July 2006. A framework for
generating Python bindings (pybindgen) and use of the Waf build system were contributed by
Gustavo Carneiro. The first release, ns-3.1 was made in June 2008, and afterwards the project
continued making quarterly software releases, and more recently has moved to three releases
per year. ns-3 made its eighteenth release (ns-3.18) in the third quarter of 2013.

Current status of the three versions is:


➢ ns-1 is no longer developed nor maintained,

➢ ns-2 build of 2009 is not actively maintained (and is not being accepted for journal
publications)

➢ ns-3 is actively developed (but not compatible for work done on ns-2).

Design

ns-3 is built using C++ and Python with scripting capability. The ns-3 library is
wrapped to python thanks to the pybindgen library which delegates the parsing of the ns-3
C++ headers to gccxml and pygccxml to generate automatically the corresponding C++
binding glue. These automaticallygenerated C++ files are finally compiled into the ns-3
python module to allow users to interact with the C++ ns-3 models and core through python
scripts. The ns-3 simulator features an integrated attribute-based system to manage default
and per-instance values for simulation parameters. All of the configurable default values for
parameters are managed by this system, integrated with command-line argument processing,
Doxygen documentation, and an XML-based and optional GTK-based configuration
subsystem. x The large majority of its users focuses on wireless simulations which involve
models for Wi-Fi, WiMAX, or LTE for layers 1 and 2 and routing protocols such as OLSR
and AODV.

Components
ns-3 is split over couple dozen modules containing one or more models for real-world
network devices and protocols

ns-3 has more recently integrated with related projects: the Direct Code Execution extensions
allowing the use of C or C++-based applications and Linux kernel code in the
simulations.

Simulation workflow
The general process of creating a simulation can be divided into several steps:

46
1. Topology definition: to ease the creation of basic facilities and define their
interrelationships, ns-3 has a system of containers and helpers that facilitates this
process.

2. Model development: models are added to simulation (for example, UDP, IPv4,
pointto-point devices and links, applications); most of the time this is done using
helpers.

3. Node and link configuration: models set their default values (for example, the size of
packets sent by an application or MTU of a point-to-point link); most of the time this
is done using the attribute system.

4. Execution: simulation facilities generate events, data requested by the user is logged.

5. Performance analysis: after the simulation is finished and data is available as a


timestamped event trace. This data can then be statistically analysed with tools like R
to draw conclusions.

6. Graphical Visualization: raw or processed data collected in a simulation can be


graphed using tools like Gnuplot, matplotlib or XGRAPH.

Examples of network simulators

There are many both free/open-source and proprietary network simulators.

Examples of notable network simulation software are, ordered after how often they are
mentioned in research papers:

1. ns (open source).

2. OPNET (proprietary software).

3. NetSim (proprietary software)

Uses of network simulators


Network simulators serve a variety of needs. Compared to the cost and time involved in
setting up an entire test bed containing multiple networked computers, routers and data links,
network simulators are relatively fast and inexpensive. They allow engineers, researchers to test
scenarios that might be particularly difficult or expensive to emulate using real hardware - for
instance, simulating a scenario with several nodes or experimenting with a new protocol in the
network. Network simulators are particularly useful in allowing researchers to test new networking
protocols or changes to existing protocols in a controlled and reproducible environment. A typical
network simulator encompasses a wide range of networking technologies and can help the users to
build complex networks from basic building blocks such as a variety of nodes and links. With the help
of simulators, one can design hierarchical networks using various types of nodes like computers,
hubs, bridges, routers, switches, links, mobile units etc. Various types of Wide Area Network (WAN)
technologies like TCP, ATM, IP etc. and Local Area Network (LAN) technologies like

48
Ethernet, token rings etc., can all be simulated with a typical simulator and the user can test,
analyze various standard results apart from devising some novel protocol or strategy for
routing etc. Network simulators are also widely used to simulate battlefield networks in
Network-centric warfare.

Packet loss:
When one or more packets of data travelling across a computer network fail to
reach their destination. Packet loss is distinguished as one of the three main error types
encountered in digital communications; the other two being bit error and spurious packets
caused due to noise. Packets can be lost in a network because they may be dropped when a
queue in the network node overflows. The amount of packet loss during the steady state is
another important property of a congestion control scheme. The larger the value of packet
loss, the more difficult it is for transport layer protocols to maintain high bandwidths, the
sensitivity to loss of individual packets, as well as to frequency and patterns of loss among
longer packet sequences is strongly dependent on the application itself.

Throughput:
This is the main performance measure characteristic, and most widely used. In
communication networks, such as Ethernet or packet radio, throughput or network throughput
is the average rate of successful message delivery over a communication channel. The
throughput is usually measured in bits per second (bit/s or bps), and sometimes in data
packets per second or data packets per time slot This measure how soon the receiver is able to
get a certain amount of data send by the sender. It is determined as the ratio of the total data
received to the end to end delay. Throughput is an important factor which directly impacts the
network performance.

Delay:
Delay is the time elapsed while a packet travels from one point e.g., source premise or
network ingress to destination premise or network degrees. The larger the valueof delay, the
more difficult it is for transport layer protocols to maintain high bandwidths. We will
calculate end to end delay.

Queue length:
A queuing system in networks can be described as packets arriving for service,
waiting for service if it is not immediate, and if having waited for service, leaving thesystem
after being served. Thus queue length is very important characteristic to determine that how
well the active queue management of the congestion control algorithm has been working.

RESULT:

Thus the study of Network simulator (NS2) was modified successfully .

50
Ex. No. : 9 a)
WRITE A SOCKET PROGRAM FOR PING
Date :

AIM:

To write a socket program for PING in Java.

APPARATUS REQUIRED:

1. PENTIUM – PC

2. Jdk 1.7.

3. Java software

ALGORITHM:

1. Start the program.

2. Import Javautil and all necessary packages.

3. Initialize the ping server with socket as null value.

4. Get the IP address of the server using Scanner class.

5. Using get run time () method, executes the specified command in a separate process.

6. Stop the program.

PING Program:
import java.util.*;
public class PingDemo
{
public void Ping(String host)
{
try
{
Process p=Runtime.getRuntime().exec("Ping "+host);
Scanner scan=new Scanner(p.getInputStream());
while(scan.hasNextLine())
{
System.out.println(scan.nextLine());
}
}

52
catch(Exception ex)
{
System.out.println("error"+ex);
}
}
public static void main(String args[])
{
PingDemo P1=new PingDemo();
P1.Ping(args[0]);
}
}

RESULT:
Thus the socket programming for Ping using Java was written and executed
successfully.

54
Ex. No. : 9 b)
WRITE A SOCKET PROGRAM FOR TRACE ROUTE
Date :

AIM:

To write a socket program for TRACE ROUTE in Java.

TRACEROUTE Command

1. The trace route command is used to discover the routes that packets actually take
when traveling to their destination. The device (for example, a router or a PC) sends
out a sequence of User Datagram Protocol (UDP) data grams to an invalid port
address at the remote host.

2. Three data grams are sent, each with a Time-To-Live (TTL) field value set to one.
The TTL value of 1 causes the datagram to "timeout" as soon as it hits the first router
in the path; this router then responds with an ICMP Time Exceeded Message (TEM)
indicating that the datagram has expired.

3. Another three UDP messages are now sent, each with the TTL value set to 2, which
causes the second router to return ICMP TEMs. This process continues until the
packets actually reach the other destination.

4. Since these data grams are trying to access an invalid port at the destination host,
ICMP Port Unreachable Messages are returned, indicating an unreachable port; this
event signals the Trace route program that it is finished.

ALGORITHM
Ping Server

1. Start the program.

2. Import necessary packages.

3. Initialize the ping server with both sockets as null value.

4. Start the server socket.

5. At the client give the IP address of the server.

6. The client program is then started by starting socket.

7. At the receiver end, the client is pinged.

8. Stop the program.

56
Ping Client

1. Start the program.

2. Import necessary packages.

3. Initialize the ping client with both sockets as null value.

4. Start the socket.

5. Get the IP address of the server.

6. Ping the server.

7. At the receiver end, the server is pinged.

8. Stop the program.

SOURCE CODE

//pingclient.java
import java.io.*;
import java.net.*;
import java.util.Calendar;
class pingclient
{
public static void main(String args[])throws Exception
{
String str;
int c=0;
long t1,t2;
Socket s=new Socket("127.0.0.1",5555);
DataInputStream dis=new DataInputStream(s.getInputStream());
PrintStream out=new PrintStream(s.getOutputStream());
while(c<4)
{
t1=System.currentTimeMillis();
str="Welcome to network programming world";
out.println(str);
System.out.println(dis.readLine());
t2=System.currentTimeMillis();
System.out.println(";TTL="+(t2-t1)+"ms"); c++;
}
s.close();
}

58
//pingserver.java
import java.io.*;
import java.net.*;
import java.util.*;
import java.text.*;
class pingserver
{
public static void main(String args[])throws Exception
{
ServerSocket ss=new ServerSocket(5555); Socket
s=ss.accept();
int c=0;
while(c<4)

{
DataInputStream dis=new DataInputStream(s.getInputStream());
PrintStream out=new PrintStream(s.getOutputStream());
String str=dis.readLine();
out.println("Reply from"+InetAddress.getLocalHost()+";Length"+str.length()); c++;
}
s.close();}}

RESULT
Thus the socket programming for Trace route using Java was written and executed
successfully.

60
Ex. No. : 9 c)
WRITE A SOCKET PROGRAM FOR
Date :
NSLOOKUP COMMAND

AIM:
To write a program in java to demonstrate the usage of nslookup command.

ALGORITHM:
1. Import the net, input output packages.
2. Use the method exec with the nslookup command and store the result of the
command in a stream.
3. Process the stream and print the output.
4. End the process.
SOURCE CODE
import java.io.*;
import java.net.*;

class Server
{
public static void main(String args[])
{
try
{
String str;
BufferedReader buf1=new BufferedReader(new
InputStreamReader(System.in));
String ip=buf1.readLine();
Runtime H=Runtime.getRuntime();
Process p=H.exec("nslookup" + ip);
InputStream in=p.getInputStream();
BufferedReader buf2=new BufferedReader(new
InputStreamReader(in));
while((str=buf2.readLine())!=null)
{
System.out.println(" " + str);
}
}
catch(Exception e)

62
System.out.println(e.getMessage());
}
}
}

RESULT
Thus the socket programming for Nslookup using Java was written and executed
successfully.

64
Ex. No. : 10
IMPLEMENTATION OF IP ADDRESS CONFIGURATION
Date :

AIM:

To write a program in java to implement IP address configuration.

ALGORITHM:

1. Import the net, input output packages.

2. Use the method exec with the ipaddress command and store the result of the
command in a stream.

3. Process the stream and print the output.

4. End the process

SOURCE CODE:
import java.io.*;
import java.net.*;

class Server
{
public static void main(String args[])
{
try
{
String str;
BufferedReader buf1=new BufferedReader(new
InputStreamReader(System.in));
String ip=buf1.readLine();
Runtime H=Runtime.getRuntime();
Process p=H.exec("ipconfig " + ip);
InputStream in=p.getInputStream();
BufferedReader buf2=new BufferedReader(new
InputStreamReader(in));
while((str=buf2.readLine())!=null)
{
System.out.println(" " + str);
}
}

66
catch(Exception e)
{
System.out.println(e.getMessage());
}
}
}

RESULT:
Thus the program for IP Address Configuration using Java was written and executed
successfully.

68
Ex. No. : 11
STUDY OF HIGH LEVEL DATA LINK PROTOCOL
Date :

AIM:
To study about (HDLC) High Level Data Link Protocol.
Introduction:
HDLC - Short for High-level Data Link Control, a transmission protocol used at
the data link layer (layer 2) of the OSI seven layer model for data communications. The
HDLC protocol embeds information in a data frame that allows devices to control data flow
and correct errors. HDLC is an ISO standard developed from the Synchronous Data Link
Control (SDLC) standard proposed by IBM in the 1970's. HDLC NRM (also known as
SDLC) .HDLC is a bit oriented protocol that supports both half-duplex and full-duplex
communication over point to point & multipoint link.
For any HDLC communications session, one station is designated
primary and the other secondary. A session can use one of the following connection modes,
which determine how the primary and secondary stations interact.

• Normal unbalanced: The secondary station responds only to the primary station.
• Asynchronous: The secondary station can initiate a message.
• Asynchronous balanced: Both stations send and receive over its part of a duplex
line.

This mode is used for X.25 packet-switching network

The Link Access Procedure-Balanced (LAP-B) and Link Access Procedure D-


channel (LAP-D) protocols are subsets of HDLC.

LAPB is a bit-oriented synchronous protocol that provides complete data transparency in a


full-duplex point-to-point operation. It supports a peer-to-peer link in that neither end of the
link plays the role of the permanent master station. HDLC NRM, on the other hand, has a
permanent primary station with one or more secondary stations.

The concept of a frame window is used to send multiple frames before


receiving confirmation that the first frame has been correctly been received. This means that
data can continue to flow in situations where there may be long "turn-around" time
lagswithout stopping to wait for an acknowledgement. This kind of situation occurs, for
instance in satellite communication.

HDLC defines three types of frames:

1. Information frames (I-frame)


2. Supervisory frame (S-frame)

70
3. Unnumbered frame (U-frame)

1. Information frames (I-frame)


• I-frames carry user's data and control information about user's data.
• I-frame carries user data in the information field.
C:/images/Information-frames.jpg •The first bit of control field is always zero, i.e. the
presence of zero at this place indicates that it is I-frame.
• Bit number 2, 3 & 4 in control field is called N(S) that specifies the sequence number
of the frame. Thus it specifies the number of the frame that is currently being sent.
Since it is a 3.bit field, only eight sequence numbers are possible 0, 1,2,3,4,5,6, 7 (000
to 111).
• Bit number 5 in control field is P/F i.e. Poll/Final and is used for these two purposes.
It has, meaning only when it is set i.e. when P/F=1.

It can represent the following two cases:


(i) It means poll when frame is sent by a primary station to secondary (when address
field contains the address of receiver).
(ii) It means final when frame is sent by secondary to a primary (when the address field
contains the address of the sender).

• Bit number 6, 7, and 8 in control field specifies N(R) i.e. the sequence number of the
frame expected in return in two-way communication.

2. Supervisory frame
• S-frame carries control information, primarily data link layer flow and error controls.

C:\images\Supervisory-frame.jpg•The first two bits in the control field of S-frame are always
10.

C:\images\Types-of-S-Frame.jpg 1. RR, Receive Ready-used to acknowledge frames when


no I-frames are availab1e to piggyback the acknowledgement.

2. REJ Reject-used by the receiver to send a NAK when error has occurred.

3.RNR Receive Not Ready-used for flow control.

4.SREJ Selective Reject-indicates to the transmitter that it should retransmit the frame
indicated in the N(R) subfield.

• There is no N(S) field in control field of S-frame as S-frames do not transmit data.

• Last three bits in control field indicates N(R) i.e. they correspond to the ACK or NAK
value.

3. Unnumbered frame

72
• U-frames are reserved for system management and information carried by them is
used for managing the link.

• U-frames are used to exchange session management and control information between
the two connected devices.

• Information field in U-frame does not carry user information rather, it carries system
management information.

• The frame format of U-frame is shown in diagram.

• U-frame is identified by the presence of 11 in the first and second bit position in
control field.

• These frames do not contain N(S) or N(R) in control field.

C:\images\Unnumbered-frame.jpg• U-frame contains two code fields, one two hit and other three
bit.

• These five bits can create upto 32 different U-frames.

Protocol Structure - HDLC: High Level Data Link Control

Flag - The value of the flag is always (0x7E).

Address field - Defines the address of the secondary station which is sending the frame or
the destination of the frame sent by the primary station. It contains Service Access Point
(6bits), a Command/Response bit to indicate whether the frame relates to information frames
(I-frames) being sent from the node or received by the node, and an address extension bit
which is usually set to true to indicate that the address is of length one byte. When set to false
it indicates an additional byte follows.

Extended address - HDLC provides another type of extension to the basic format. The
address field may be extended to more than one byte by agreement between the involved
parties.

Control field - Serves to identify the type of the frame. In addition, it includes sequence
numbers, control features and error tracking according to the frame type.

FCS - The Frame Check Sequence (FCS) enables a high level of physical error control by
allowing the integrity of the transmitted frame data to be checked.

Related Protocols : LAPB , ISDN , X.25 , Frame Relay , SDLC

RESULT:

Thus the High level data link control protocol was studied.

74

You might also like