NETWORKS LAB EXPERIMENTS
NETWORKS LAB EXPERIMENTS
0042
COURSE OBJECTIVES:
The student should be made to:
● To learn and use network commands.
● To learn socket programming.
● To implement and analyze various network protocols.
● To learn and use simulation tools.
● To use simulation tools to analyze the performance of various network protocols.
● To learn error detection and correction techniques
EXPERIMENTS
1. Learn to use commands like tcpdump, netstat, ifconfig, nslookup and traceroute. Capture
ping and traceroute PDUs using a network protocol analyzer and examine.
2. Write a HTTP web client program to download a web page using TCP sockets.
3. Applications using TCP sockets like:
Echo client and echo server, Chat , File Transfer
4. Simulation of DNS using UDP sockets.
5. Write a code simulating ARP /RARP protocols.
6. Study of Network simulator (NS) and Simulation of Congestion Control Algorithms
7. Study of TCP/UDP performance using Simulation tool.
8. Simulation of Distance Vector/ Link State Routing algorithm.
9. Performance evaluation of Routing protocols using Simulation tool.
10. Simulation of error correction code (like CRC).
11. Configuring Network Operating Systems and network devices
1
IT1503 NETWORKS LEBORATORY III YEAR IT / V SEMESTER
Ex:No: 1a Learn to use commands like tcpdump, netstat, ifconfig, nslookup and trace
route
Date:
CONCEPT
Netstat command:
1. netstat is a utility to display TCP/IP statistics and details about TCP/IP components and
connections to a host.
2. Netstat is useful to check what ports are open on your computer, to see which network
connections are currently established, to see how many packets have been handled by a
network interface since it was activated, etc.
3. Netstat -a – provides a list of all available TCP and UDP connections
Netstat -e – displays details of packets that have been sent
Netstat -n – lists currently connected hosts
Netstat -p – allow to specify what type of protocol you want to check
Netstat -r – provides a list of routing tables
Netstat -s – gives statistics on IPv4, IPv6, ICMP, TCP, etc.
ALGORITHM:
1. Start the Program
2. Open command prompt and type netstat commands.
3. Execute the netstat Command
4. Stop the program
2
IT1503 NETWORKS LEBORATORY III YEAR IT / V SEMESTER
Output:
(i) netstat –a command
3
IT1503 NETWORKS LEBORATORY III YEAR IT / V SEMESTER
(iii) netstat –n command
Nslookup command:
nslookup is a utility to query DNS tables, using this utility you can find what your DNS server
is or any DNS server you specify, for example, nslookup google.com
ALGORITHM:
1. Start the Program
2. Open command prompt and type nslookup commands.
3. Execute the netstat Command
4. Stop the program
output:
4
IT1503 NETWORKS LEBORATORY III YEAR IT / V SEMESTER
Tracert command:
tracert is a utility to check connectivity from one computer to another. It gives you the details
on each router as it hops from one router to another.
ALGORITHM:
1. Start the Program
2. Open command prompt and type tracert commands.
3.Execute the netstat Command
4.Stop the program
Output:
Ipconfig command:
Ipconfig provides TCP/IP settings info, IP address, DNS server, DHCP server, default gateway
etc. It is very useful when you need to troubleshoot networking problems.
ALGORITHM:
1. Start the Program
2. Open command prompt and type ipconfig commands.
3.Execute the netstat Command
4.Stop the program
5
IT1503 NETWORKS LEBORATORY III YEAR IT / V SEMESTER
Output:
TCPDUMP :
Tcpdump command is a famous network packet analysing tool that is used to display TCP\IP &
other network packets being transmitted over the network attached to the system on which
tcpdump has been installed. Tcpdump uses libpcap library to capture the network packets & is
available on almost all Linux/Unix flavors.
Tcpdump command can read the contents from a network interface or from a previously created
packet file or we can also write the packets to a file to be used for later. One must use the
tcpdump command as root or as a user with sudo privileges.
6
IT1503 NETWORKS LEBORATORY III YEAR IT / V SEMESTER
Using AND
We can use ‗and‘ or symbol ‗&&‘ to combine two conditions or mote with tcpdump. An
example would be,
$ tcpdumpsrc 192.168.1.100 && port 22 -w ssh_packets
Using OR
OR will check the command agtcpdump -i eth0 src port not 22ainst one the mentioned conditions
in the command, like
$ tcpdumpsrc 192.168.1.100 or dst 192.168.1.50 && port 22 -w ssh_packets
$ tcpdump port 443 or 80 -w http_packets
Using EXCEPT
EXCEPT will be used when we want not fulfill a condition, like
$ tcpdump -i eth0 src port not 22
This will monitor all the traffic on eth0 but will not capture port 22.
This was our tutorial on how to install & use tcpdump command to capture the network packets.
Please feel free to send in any queries or suggestions using the comment box below.
Result:
Thus the commands like tcpdump, netstat, ifconfig, nslookup and trace route have been written
and executed successfully.
7
IT1503 NETWORKS LEBORATORY III YEAR IT / V SEMESTER
EX.NO:1b Capture ping and trace route PDUs using a network protocol analyzer
DATE : and examine.
CONCEPT
PING Command
1. The ping command is a very common method for troubleshooting the accessibility of devices.
It uses a series of Internet Control Message Protocol (ICMP) Echo messages to determine:
Whether a remote host is active or inactive.
The round-trip delay in communicating with the host.
Packet loss.
2. The ping command first sends an echo request packet to an address, and then waits for a reply.
The ping is successful only if:
the echo request gets to the destination, and
the destination is able to get an echo reply back to the source within a predetermined time
called a timeout.
The default value of this timeout is two seconds on Cisco routers.
ALGORITHM:
1. Start the Program
2. Open command prompt and type ping command with IP address.
3.Execute the Ping Command
4.Stop the program
Output:
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.
8
IT1503 NETWORKS LEBORATORY III YEAR IT / V SEMESTER
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:
1. Start the Program
2. Open command prompt and type tracert commands.
3.Execute the netstat Command
4.Stop the program
Output:
Result:
Thus the command for Ping and Traceroute have been written and executed successfully.
9
IT1503 NETWORKS LEBORATORY III YEAR IT / V SEMESTER
EX:NO: 2 Write a HTTP web client program to download a web page using TCP sockets
DATE:
AIM:
To write a java program for socket for HTTP for web page upload and download .
ALGORITHM:
1. Start the program.
2. Get the frame size from the user
3. To create the frame based on the user request.
4.To send frames to server from the client side.
5. If your frames reach the server it will send ACK signal to client otherwise it will
send NACK signal to client.
6. Stop the program
PROGRAM :
Client
import javax.swing.*;
import java.net.*;
import java.awt.image.*;
import javax.imageio.*;
import java.io.*;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
public class Client{
public static void main(String args[]) throws Exception
{
Socket soc;
BufferedImage img = null;
soc=new Socket("localhost",4000);
System.out.println("Client is running. ");
try {
System.out.println("Reading image from disk. ");
img = ImageIO.read(new File("D:/jdk141_03/Sunset.jpg"));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(img, "jpg", baos);
baos.flush();
byte[] bytes = baos.toByteArray();
baos.close();
System.out.println("Sending image to
server. ");
OutputStream out = soc.getOutputStream();
DataOutputStream dos = new DataOutputStream(out);
dos.writeInt(bytes.length);
dos.write(bytes, 0, bytes.length);
System.out.println("Image sent to server. ");
dos.close();
out.close();
10
IT1503 NETWORKS LEBORATORY III YEAR IT / V SEMESTER
Server:
import java.net.*;
import java.io.*;
import java.awt.image.*;
import javax.imageio.*;
import javax.swing.*;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException; import
javax.imageio.ImageIO;
public class Server {
public static void main(String args[]) throws Exception{
ServerSocket server=null;
Socket socket;
server=new ServerSocket(4000);
System.out.println("Server Waiting for image");
socket=server.accept(); System.out.println("Client connected.");
InputStream in = socket.getInputStream();
DataInputStream dis = new DataInputStream(in);
int len = dis.readInt();
System.out.println("Image Size: " + len/1024 + "KB"); byte[] data = new byte[len];
dis.readFully(data);
dis.close();
in.close();
InputStream ian = new ByteArrayInputStream(data);
BufferedImage bImage = ImageIO.read(ian);
JFrame f = new JFrame("Server");
ImageIcon icon = new ImageIcon(bImage);
JLabel l = new JLabel();
l.setIcon(icon);
f.add(l);
f.pack();
f.setVisible(true);
}
}
11
IT1503 NETWORKS LEBORATORY III YEAR IT / V SEMESTER
Output:
Result:
Thus the program of HTTP web client program to download a web page using TCP sockets have
been written and executed successfully.
12
IT1503 NETWORKS LEBORATORY III YEAR IT / V SEMESTER
AIM:
To write a java program for Echo client and echo server using TCP Sockets.
CONCEPT:
1. The Echo server simply receives data from its client and echoes it back.
2. The Echo server is a well-known service that clients can rendezvous with on port 7.
3. Echo Client creates a socket thereby getting a connection to the Echo server.
4. It reads input from the user on the standard input stream, and then forwards that text to the
Echo server by writing the text to the socket.
5. The server echoes the input back through the socket to the client.
6. The client program reads and displays the data passed back to it from the server.
HARDWARE REQUIREMENT:
P- 11400 MHZ speed
20GB Hard disk
64 MB RAM
SOFTWARE REQUIREMENT:
C Compiler/Java Compiler
ALGORITHM:
1. Create two programs one for the server side and one for the client side
2. In the server side, create a server socket.
3. The return value of the accept () method is assigned to a new socket created.
4. Send the input received from the client at the server side back to the client.
5. In the client side, create a socket to connect to the server.
6. Create the object of DataInputStream to accept input from the server
7. Display the input received from the server.
8. Stop the program
PROGRAM :
EchoServer.java :
import java.io.*;
import java.net.*;
public class EchoServer
{
public EchoServer(int portnum)
{
try
{
server = new ServerSocket(portnum);
}
catch (Exception err)
{
System.out.println(err);
13
IT1503 NETWORKS LEBORATORY III YEAR IT / V SEMESTER
}
}
14
IT1503 NETWORKS LEBORATORY III YEAR IT / V SEMESTER
do
{
line = r.readLine();
if ( line != null )
System.out.println(line);
line = con.readLine();
w.println(line);
}
while ( !line.trim().equals("bye") );
}
catch (Exception err)
{
System.err.println(err);
}
}
}
RESULT:
Thus the java program for Echo client and echo server using TCP Sockets was created.
15
IT1503 NETWORKS LEBORATORY III YEAR IT / V SEMESTER
AIM:
To write a java program for chat using TCP Sockets.
CONCEPT:
1. It uses TCP socket communication .We have a server as well as a client.
2. Both can be run in the same machine or different machines. If both are running in themachine,
the address to be given at the client side is local host address.
3. If both are running in different machines, then in the client side we need to specify the
ipaddress of machine in which server application is running.
ALGORITHM:
Server
1. Start the program
2. Create server and client sockets.
3. Use input streams to get the message from user.
4. Use output streams to send message to the client.
5. Wait for client to display this message and write a new one to be displayed by theserver.
6. Display message given at client using input streams read from socket.
7. Stop the program.
Client
1. Start the program
2. Create a client socket that connects to the required host and port.
3. Use input streams read message given by server and print it.
4. Use input streams; get the message from user to be given to the server.
5. Use output streams to write message to the server.
6. Stop the program.
PROGRAM:
TCP CLIENT
//tcpclient.java
importjava.io.*;
importjava.net.*;
public class tcpclient
{
public static void main(String[] args) throws IOException
{
System.out.println(―TCP CLIENT‖);
System.out.println(―Enter the host name to connect‖);
DataInputStream inp=new DataInputStream(System.in);
String str=inp.readLine();
Socket clientsoc = new Socket(str, 9);
PrintWriter out = new PrintWriter(clientsoc.getOutputStream(), true);
BufferedReader in = new BufferedReader(new InputStreamReader(clientsoc.getInputStream()));
BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
String userinput;
try
16
IT1503 NETWORKS LEBORATORY III YEAR IT / V SEMESTER
{
while (true)
{
System.out.println(―Sever Says : ‖ + in.readLine());
userinput = stdin.readLine();
out.println(userinput);
}
}
catch(Exception e)
{
System.exit(0);
}}}
TCP SERVER
//tcpserver.java
importjava.io.*;
importjava.net.*;
public class tcpserver
{
public static void main(String a[]) throws Exception
{
System.out.println(―TCP SERVER‖);
System.out.println(―Server is ready to connect…‖);
ServerSocket serversoc=new ServerSocket(9);
Socket clientsoc = serversoc.accept();
PrintWriter out = new PrintWriter(clientsoc.getOutputStream(), true);
BufferedReader in = new BufferedReader(new
InputStreamReader(clientsoc.getInputStream()));
String inputline;
BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
try
{
while (true)
{
inputline = stdin.readLine();
out.println(inputline);
System.out.println(―Client Says : ―+in.readLine());
}
}
catch(Exception e)
{
System.exit(0);
}
}
}
17
IT1503 NETWORKS LEBORATORY III YEAR IT / V SEMESTER
Sample Output:
CLIENT-SERVER CHATTING USING TCP
*************************************
TCP SERVER
************
Server is ready to connect…
hello
Client Says : hello
How are you
Client Says : I‘m doing programs
What programs
Client Says : networking
ok.Go ahead
Client Says :ok.Bye
Bye
TCP CLIENT
***********
Enter the host name to connect
p4-221
Sever Says : hello
hello
Sever Says : how are you
I‘m doing programs
Sever Says : What programs
networking
Sever Says :ok.Go ahead
ok.Bye
Sever Says : Bye
RESULT:
Thus the java program for chat using TCP Sockets was executed.
18
IT1503 NETWORKS LEBORATORY III YEAR IT / V SEMESTER
AIM:
To write a java program for file transfer using TCP Sockets.
CONCEPT:
Our application has a client and a server. Our aim is to send a file from the client machine to the
server machine.
ALGORITHM:
Server
1. Import java packages and create class file server.
2. Create a new server socket and bind it to the port.
3. Accept the client connection
4. Get the file name and stored into the Buffered Reader.
5. Create a new object class file and read line.
6. If file is exists then File Reader read the content until EOF is reached.
7. Stop the program.
Client
1. Import java packages and create class file server.
2. Create a new server socket and bind it to the port.
3. Now connection is established.
4. The object of a Buffer Reader class is used for storing data content which has been retrieved
from socket object.
5. The content of file is displayed in the client window and the connection is closed.
6. Stop the program.
PROGRAM:
FileTransferServer.java
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
//Initialize Sockets
ServerSocket ssock = new ServerSocket(5000);
Socket socket = ssock.accept();
19
IT1503 NETWORKS LEBORATORY III YEAR IT / V SEMESTER
byte[] contents;
long fileLength = file.length();
long current = 0;
os.flush();
//File transfer done. Close the socket connection!
socket.close();
ssock.close();
System.out.println("File sent succesfully!");
}
}
FileTransferClient.java
import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.net.InetAddress;
import java.net.Socket;
public class FileTransferClient {
public static void main(String[] args) throws Exception{
//Initialize socket
Socket socket = new Socket(InetAddress.getByName("localhost"), 5000);
byte[] contents = new byte[10000];
20
IT1503 NETWORKS LEBORATORY III YEAR IT / V SEMESTER
while((bytesRead=is.read(contents))!=-1)
bos.write(contents, 0, bytesRead);
bos.flush();
socket.close();
System.out.println("File saved successfully!");
}
}
OUTPUT:
SERVER
D:\Java\jdk1.6\bin>java FileTransferServer
Sending file ... 100% complete!File sent succesfully!
CLIENT
D:\Java\jdk1.6\bin>java FileTransferClient
File saved successfully!
RESULT:
Thus the java program for file transfer using TCP Sockets.
21
IT1503 NETWORKS LEBORATORY III YEAR IT / V SEMESTER
Aim
Algorithm
1. The DNS client program sends a request to a DNS server to map the e-mail address to the
corresponding IP address.
2. When the Internet was small, mapping was done by using a host file. The host file had only
two columns: name and address.
3. The host that needs mapping can contact the closest computer holding the needed information.
This method is used by the Domain Name System (DNS).
PROBLEM DEFINITION :
To construct a Domain Name System(DNS) using a UDP sockets which associates various
information with domain names. Here the client requests for information from a specific domain
and the DNS server translates human-readable computer hostnames, e.g. www.example.com,
into IP addresses, e.g. 208.77.188.166, which networking equipment needs to deliver information
TERMINOLOGIES:
Domain Name System -The Domain Name System (DNS) associates various information with
domain names; most importantly, it serves as the "phone book" for the Internet by translating
human-readable computer hostnames, e.g. www.example.com, into IP addresses, e.g.
208.77.188.166, which networking equipment needs to deliver information. It also stores other
information such as the list of mail servers that accept email for a given domain.
Program:
import java.io.*;
import java.net.*;
public class udpdnsclient
{
public static void main(String args[])throws IOException
22
IT1503 NETWORKS LEBORATORY III YEAR IT / V SEMESTER
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
DatagramSocket clientsocket = new DatagramSocket();
InetAddress ipaddress;
if (args.length == 0)
ipaddress = InetAddress.getLocalHost();
else
ipaddress = InetAddress.getByName(args[0]);
byte[] senddata = new byte[1024];
byte[] receivedata = new byte[1024];
int portaddr = 1362;
System.out.print("Enter the hostname : ");
String sentence = br.readLine();
senddata = sentence.getBytes();
DatagramPacket pack = new DatagramPacket(senddata,senddata.length, ipaddress,portaddr);
clientsocket.send(pack);
import java.io.*;
import java.net.*;
public class udpdnsserver
{
private static int indexOf(String[] array, String str)
{
str = str.trim();
for (int i=0; i < array.length; i++)
{
if (array[i].equals(str)) return i;
}
return -1;
}
public static void main(String arg[])throws IOException
{
String[] hosts = {"yahoo.com", "gmail.com","cricinfo.com", "facebook.com"};
String[] ip = {"68.180.206.184", "209.85.148.19","80.168.92.140", "69.63.189.16"};
System.out.println("Press Ctrl + C to Quit");
while (true)
{
DatagramSocket serversocket=new DatagramSocket(1362);
byte[] senddata = new byte[1021];
byte[] receivedata = new byte[1021];
DatagramPacket recvpack = new DatagramPacket(receivedata, receivedata.length);
serversocket.receive(recvpack);
String sen = new String(recvpack.getData());
23
IT1503 NETWORKS LEBORATORY III YEAR IT / V SEMESTER
OUTPUT Server
javac udpdnsserver.java
java udpdnsserver
Press Ctrl + C to Quit Request for host yahoo.com
Request for host cricinfo.com
Request for host youtube.com
Client
javac udpdnsclient.java
java udpdnsclient
Enter the hostname : yahoo.com
IP Address: 68.180.206.184
java udpdnsclient
Enter the hostname : cricinfo.com
IP Address: 80.168.92.140
java udpdnsclient
Enter the hostname : youtube.com
IP Address: Host Not Found
Result:
Thus the program for simulation of DNS using UDP sockets have been written and executed
successfully.
24
IT1503 NETWORKS LEBORATORY III YEAR IT / V SEMESTER
Date:
AIM
CONCEPT
The logical (IP) address is obtained from the DNS if the sender is the host or it is found
in a routing table if the sender is a router. But the IP datagram must be encapsulated in a
frame to be able to pass through the physical network.
The host or the router sends an ARP query packet. The packet includes the physical and
IP addresses of the sender and the IP address of the receiver.
Because the sender does not know the physical address of the receiver, the query is
broadcast over the network.
Every host or router on the network receives and processes the ARP query packet, but
only the intended recipient recognizes its IP address and sends back an ARP response
packet.
The response packet contains the recipient's IP and physical addresses.
RARP finds the logical address for a machine that knows only its physical address.
Each host or router is assigned one or more logical (IP) addresses, which are unique and
independent of the physical (hardware) address of the machine.
To create an IP datagram, a host or a router needs to know its own IP address or
addresses.
HARDWARE REQUIREMENT:
SOFTWARE REQUIREMENT:
C Compiler/Java Compiler
ALGORITHM:
Server:
2. Listen for new connection and when a connection arrives, accept it.
9. Stop.
Client :
7. Stop.
Client:
import java.io.*;
import java.net.*;
import java.util.*;
class Clientarp
try
DataOutputStreamdout=new DataOutputStream(clsct.getOutputStream());
String str1=in.readLine();
26
IT1503 NETWORKS LEBORATORY III YEAR IT / V SEMESTER
dout.writeBytes(str1+'\n');
String str=din.readLine();
clsct.close();
catch (Exception e)
System.out.println(e);
}}}
Server:
import java.io.*;
import java.net.*;
import java.util.*;
class Serverarp
try
ServerSocketobj=new ServerSocket(139);
Socket obj1=obj.accept();
while(true)
DataOutputStreamdout=new DataOutputStream(obj1.getOutputStream());
String str=din.readLine();
String ip[]={"165.165.80.80","165.165.79.1"};
String mac[]={"6A:08:AA:C2","8A:BC:E3:FA"};
for(int i=0;i<ip.length;i++)
{
27
IT1503 NETWORKS LEBORATORY III YEAR IT / V SEMESTER
if(str.equals(ip[i]))
dout.writeBytes(mac[i]+'\n');
break;
}}
obj.close();
}}
catch(Exception e)
System.out.println(e);
}}}
Output:
E:\networks>java Serverarp
E:\networks>java Clientarp
165.165.80.80
Client:
import java.io.*;
import java.net.*;
import java.util.*;
class Clientrarp12
try
InetAddressaddr=InetAddress.getByName("127.0.0.1");
String str=in.readLine();
sendbyte=str.getBytes();
DatagramPacket sender=new
DatagramPacket(sendbyte,sendbyte.length,addr,1309);
client.send(sender);
client.receive(receiver);
client.close();
catch(Exception e)
System.out.println(e);
}}}
Server:
import java.io.*;
import java.net.*;
import java.util.*;
class Serverrarp12
try
{
29
IT1503 NETWORKS LEBORATORY III YEAR IT / V SEMESTER
while(true)
DatagramPacket receiver=new
DatagramPacket(receivebyte,receivebyte.length);
server.receive(receiver);
String s=str.trim();
//System.out.println(s);
InetAddressaddr=receiver.getAddress();
int port=receiver.getPort();
String ip[]={"165.165.80.80","165.165.79.1"};
String mac[]={"6A:08:AA:C2","8A:BC:E3:FA"};
for(int i=0;i<ip.length;i++)
if(s.equals(mac[i]))
sendbyte=ip[i].getBytes();
DatagramPacket sender=new
DatagramPacket(sendbyte,sendbyte.length,addr,port);
server.send(sender);
break;
}}
break;
}}
catch(Exception e)
System.out.println(e);
30
IT1503 NETWORKS LEBORATORY III YEAR IT / V SEMESTER
}} }
Output:
I:\ex>java Serverrarp12
I:\ex>java Clientrarp12
6A:08:AA:C2
Result :
Thus the program for implementing to display simulating ARP /RARP protocols was executed
successfully.
31
IT1503 NETWORKS LEBORATORY III YEAR IT / V SEMESTER
Aim:
To Study of Network simulator (NS) and Simulation of Congestion Control Algorithms using
NS.
Network simulator
A network simulator is software that predicts the behavior of a computer network. Since
communication networks have become too complex for traditional analytical methods to provide
an accurate understanding of system behavior, network simulators are used. In simulators, the
computer network is modeled with devices, links, applications etc. and the network performance
is reported. Simulators come with support for the most popular technologies and networks in use
today such as 5G, Internet of Things (IoT), Wireless LANs, mobile ad hoc networks, wireless
sensor networks, vehicular ad hoc networks, cognitive radio networks, LTE etc.
Simulations
Most of the commercial simulators are GUI driven, while some network simulators
are CLI driven. The network model / configuration describes the network (nodes, routers,
switches, links) and the events (data transmissions, packet error etc.). Output results would
include network level metrics, link metrics, device metrics etc. Further, drill down in terms of
simulations trace files would also be available. Trace files log every packet, every event that
occurred in the simulation and are used for analysis. Most network simulators use discrete event
simulation, in which a list of pending "events" is stored, and those events are processed in order,
with some events triggering future events—such as the event of the arrival of a packet at one
node triggering the event of the arrival of that packet at a downstream node.
Network emulation
Network emulation allows users to introduce real devices and applications into a test network
(simulated) that alters packet flow in such a way as to mimic the behavior of a live network. Live
traffic can pass through the simulator and be affected by objects within the simulation.
The typical methodology is that real packets from a live application are sent to the emulation
server (where the virtual network is simulated). The real packet gets 'modulated' into a
simulation packet. The simulation packet gets demodulated into a real packet after experiencing
effects of loss, errors, delay, jitter etc., thereby transferring these network effects into the real
packet. Thus it is as-if the real packet flowed through a real network but in reality it flowed
through the simulated network.
Emulation is widely used in the design stage for validating communication networks prior to
deployment.
List of network simulator
There are both free/open-source and proprietary network simulators available. Examples of
notable network simulators / emulators include:
OPNET
Tetcos NetSim
NS2
32
IT1503 NETWORKS LEBORATORY III YEAR IT / V SEMESTER
OPNET
OPNET Technologies, Inc. was a software business that provided performance
management for computer networks and applications.
Tetcos NetSim
TETCOS develops NetSim - a leading network simulation & emulation software.
Network Simulator 2 (NS2) : Features & Basic Architecture Of NS2
What is NS2
NS2 stands for Network Simulator Version 2. It is an open-source event-driven simulator
designed specifically for research in computer communication networks.
Features of NS2
1. It is a discrete event simulator for networking research.
2. It provides substantial support to simulate bunch of protocols like TCP, FTP, UDP, https and
DSR.
3. It simulates wired and wireless network.
4. It is primarily Unix based.
5. Uses TCL as its scripting language.
6. Otcl: Object oriented support
7. Tclcl: C++ and otcl linkage
8. Discrete event scheduler
Basic Architecture
NS2 consists of two key languages: C++ and Object-oriented Tool Command Language (OTcl).
While the C++ defines the internal mechanism (i.e., a backend) of the simulation objects, the
OTcl sets up simulation by assembling and configuring the objects as well as scheduling discrete
events. The C++ and the OTcl are linked together using TclCL.
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.
33
IT1503 NETWORKS LEBORATORY III YEAR IT / V SEMESTER
Various types of Wide Area Network (WAN) technologies like TCP, ATM, IP etc. and Local
Area Network (LAN) technologies like 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
There are a wide variety of network simulators, ranging from the very simple to the very
complex. Minimally, a network simulator must enable a user to represent a network topology,
specifying the nodes on the network, the links between those nodes and the traffic between the
nodes. More complicated systems may allow the user to specify everything about the protocols
used to handle traffic in a network. Graphical applications allow users to easily visualize the
workings of their simulated environment. Text-based applications may provide a less intuitive
interface, but may permit more advanced forms of customization.
Packet loss
occurs 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 value of 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 the system 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 (NS) and Simulation of Congestion Control Algorithms
using NS have been studied successfully.
34
IT1503 NETWORKS LEBORATORY III YEAR IT / V SEMESTER
Date:
Simulation Tool:
Network design validation for enterprises / data centers / sensor networks etc.
Network R & D (More than 70% of all Network Research paper reference a network
simulator.
Defense applications such as HF / UHF / VHF Radio based MANET Radios, Naval
communications, Tactical data links etc.
LTE, LTE Advanced, IOT, VANET simulations
Education - Lab experimentation and R & D. Most universities use a network simulator
for teaching / R & D since it‘s too expensive to buy hardware equipment
There are a wide variety of network simulators, ranging from the very simple to the very
complex. Minimally, a network simulator must enable a user to
Model the network topology specifying the nodes on the network and the links between
those nodes
Model the application flow (traffic) between the nodes
Providing network performance metrics as output
Visualization of the packet flow
Technology / protocol evaluation and device designs
Logging of packet/events for drill down analyses / debugging\
Networking is the well- defined system of hardware connected together to facilitate resource
sharing and communication internally or globally, as networks has various characteristics and
numerous mediums wherein, information can be channelized.
There are some networking tools which each and every network engineer is expected to be aware
of. These tools will help you become master of networking.
1. GNS3- Design and Configure: GNS3 (Graphical Network System 3) is an emulation software
that let‘s you see the interaction of network devices in a network topology. It is mainly used for
training in International Network Certifications and it is the Open source alternative to the Cisco
Packet Tracer Software and it has some additional functions like interacting with Virtual
Machines, Docker emulation, etc.
35
IT1503 NETWORKS LEBORATORY III YEAR IT / V SEMESTER
Packet Tracer is the cross platform visual simulation tool especially designed by CISCO Systems
that not only allows users to create network topologies but also imitate those in modern computer
networks. Cisco Routers and Switches by using the simulated command interface allows the
software users to simulate the configuration.
3. Putty Configure: PUTTY is a free and open-source terminal emulator, serial console and
network file transfer application. It supports several network protocols, including SCP, SSH,
Telnet, rlogin, and raw socket connection.
4. Secure CRT- Configure: Secure CRT provides the ability to create an SSH connection with
a dynamic port forwarding configuration that can then be used as a SOCKS proxy to reach all
machines within a remote network (behind the gateway).
5. Microsoft Visio- Design Only: Visio 2016 is a powerful diagramming application that lets
you work visually to create all sorts of diagrams and is industry-leading with over 12 million
users.
User Datagram Protocol (UDP) and Transmission Control Protocol (TCP) are a transportation
layer routing protocols which are considered of the core protocols of the internet protocol suite.
The behaviour of these routing protocols with different network metrics and scenarios is still not
very clear. Therefore,here we discuss s a comparison of the performance of both TCP and UDP
to precisely determine which of these protocols is better. Network Simulator (Packet Tracer) is
utilized to analyse and evaluate the performance for both TCP and UDP protocols varying in the
packet size and the bandwidth. In the first scenario the bandwidth has been changed with fixed
packet size and in the second scenario the packet size has been changed with fixed bandwidth to
precisely verify the performance of these protocols. These protocols were examined in terms of
the rate end-to-end delay, rate throughput, packet delivery ratio, and packet loss ratio.
Procedure:
The following Steps to be followed to study the TCP/UDP performance using the Packet Tracer.
Step2: Config all the PC and Server as usual PCDesktopType IP addressType Default
Step 3: Creation of Index Page using HTTP with HTML Scripts Multi-ServerServices->HTTP
File nameindex.html
DNSTypenameType RecordAddress
36
IT1503 NETWORKS LEBORATORY III YEAR IT / V SEMESTER
Step6: Make one client as administrator of FTP give all the permission Write, read, delete,
rename ,list
Step7: Go to simulation mode and open web browser in HTTP client then type the ftp address:
192.168.0.2 in URL.
Step9: Open the cmd prompt in DNS client type nslookup cmd. you can see connected ip address
Step10: open email info in EMAIL Client and compose a mail to any added client.
Step11: Open web browser in HTTP client and type ftp address you can see index page of your
website
Experimentation:
37
IT1503 NETWORKS LEBORATORY III YEAR IT / V SEMESTER
Step2: Config all the PC and Server as usual PC Desktop Type IP address Type
Default
38
IT1503 NETWORKS LEBORATORY III YEAR IT / V SEMESTER
39
IT1503 NETWORKS LEBORATORY III YEAR IT / V SEMESTER
Step 3: Creation of Index Page using HTTP with HTML Scripts Multi-ServerServicesHTTP
Filenameindex.html
40
IT1503 NETWORKS LEBORATORY III YEAR IT / V SEMESTER
41
IT1503 NETWORKS LEBORATORY III YEAR IT / V SEMESTER
Step6: Make one client as administrator of FTP give all the permission Write, read, delete, rename ,list
Step7: Go to simulation mode and open web browser in HTTP client then type the ftp address:
192.168.0.2 in url
42
IT1503 NETWORKS LEBORATORY III YEAR IT / V SEMESTER
Step9: Open the cmd prompt in DNS client type nslookup cmd. you can see connected ip address
43
IT1503 NETWORKS LEBORATORY III YEAR IT / V SEMESTER
Step10: open email info in EMAIL Client and compose a mail to any added client.
Step11: Open web browser in HTTP client and type ftp address you can see index page of
your website
Result: Thus the study of TCP/UDP Performance using Simulation tool(Packet tracer)have been
Studied and executed Successfully.
44
IT1503 NETWORKS LEBORATORY III YEAR IT / V SEMESTER
Date:
Aim:
To Simulate the distance vector Routing /Link State Routing Algorithm using Cisco packet
tracer.
It is a dynamic routing algorithm in which each router computes distance between itself
and each possible destination i.e. its immediate neighbors.
The router share its knowledge about the whole network to its neighbors and accordingly
updates table based on its neighbors.
The sharing of information with the neighbors takes place at regular intervals.
It makes use of Bellman Ford Algorithm for making routing tables.
Problems – Count to infinity problem which can be solved by splitting horizon.
– Good news spread fast and bad news spread slowly.
– Persistent looping problem i.e. loop will be there forever.
Step1: create the connection using end devices, switch and router
45
IT1503 NETWORKS LEBORATORY III YEAR IT / V SEMESTER
Router0:
Router1:
Fastethernet0/0: IP - 192.168.20.1(port status = on)
Router2:
Step4: Place the packets in PC0 device,PC1 devices and also in Router 0 ,Router 1 and simulate
the network as (Auto capture / play)
3.send a packet from pc0 to pc1 check the packet sent successfully like this..
Link-state routing protocols are one of the two main classes of routing protocols used in packet
switching networks for computer communications, the other being distance-vector routing
protocols. Examples of link-state routing protocols include Open Shortest Path First (OSPF) and
Intermediate System to Intermediate System (IS-IS).
The link-state protocol is performed by every switching node in the network (i.e., nodes that are
prepared to forward packets; in the Internet, these are called routers). The basic concept of link-
state routing is that every node constructs a map of the connectivity to the network, in the form
of a graph, showing which nodes are connected to which other nodes. Each node then
independently calculates the next best logical path from it to every possible destination in the
network. Each collection of best paths will then form each node's routing table.
This contrasts with distance-vector routing protocols, which work by having each node share its
routing table with its neighbours, in a link-state protocol the only information passed between
nodes is connectivity related. Link-state algorithms are sometimes characterized informally as
each router, "telling the world about its neighbours."
47
IT1503 NETWORKS LEBORATORY III YEAR IT / V SEMESTER
48
IT1503 NETWORKS LEBORATORY III YEAR IT / V SEMESTER
49
IT1503 NETWORKS LEBORATORY III YEAR IT / V SEMESTER
50
IT1503 NETWORKS LEBORATORY III YEAR IT / V SEMESTER
Result:
Thus the simulation of Distance vector and Link state routing algorithm using cisco packet
tracer has been executed successfully.
51
IT1503 NETWORKS LEBORATORY III YEAR IT / V SEMESTER
Date :
Aim :
To analyze the Performance evaluation of Routing protocols using Simulation tool.
PROCEDURE:
1. Open Packet Tracer simulator
2. Take a HUB and few PCs for demonstration
3. Assign IP address to all the PCs with its subnet mask using the addressing table.
4. Do data transfer which always floods the network unlike switches
ADDRESSING TABLE
255.0.0.0
PC0 10.10.10.1 PORT 0
52
IT1503 NETWORKS LEBORATORY III YEAR IT / V SEMESTER
Advantages:
If a packet can be delivered, it will (probably multiple times).
Since flooding naturally utilizes every path through the network, it will also use the
shortest path.
This algorithm is very simple to implement.
Disadvantages:
Flooding can be costly in terms of wasted bandwidth. While a message may only have
one destination it has to be sent to every host. In the case of a ping flood or a denial of
service attack, it can be harmful to the reliability of a computer network.
Messages can become duplicated in the network further increasing the load on the
networks bandwidth as well as requiring an increase in processing complexity to disregard
duplicate messages.
Duplicate packets may circulate forever, unless certain precautions are taken: Use a hop
count or a time to live (TTL) count and include it with each packet. This value should take
into account the number of nodes that a packet may have to pass through on the way to its
destination.
RESULT: Thus the Performance evaluation of Routing protocols was analyzed using
Simulation tool.
53
IT1503 NETWORKS LEBORATORY III YEAR IT / V SEMESTER
Date :
AIM:
To implement error detection and error correction techniques.
THEORY:
The upper layers work on some generalized view of network architecture and are not aware of
actual hardware data processing. Hence, the upper layers expect error-free transmission between
the systems. Most of the applications would not function expectedly if they receive erroneous
data. Applications such as voice and video may not be that affected and with some errors they
may still function well. Data-link layer uses some error control mechanism to ensure that frames
(data bit streams) are transmitted with certain level of accuracy. But to understand how errors is
controlled, it is essential to know what types of errors may occur. CRC is a different approach to
detect if the received frame contains valid data. This technique involves binary division of the
data bits being sent. The divisor is generated using polynomials. The sender performs a division
operation on the bits being sent and calculates the remainder. Before sending the actual bits, the
sender adds the remainder at the end of the actual bits. Actual data bits plus the remainder is
called a code word. The sender transmits data bits as code words.
ALGORITHM:
1. Open Turbo c++ software and type the program for error detection
2. Get the input in the form of bits.
3. Append 16 zeros as redundancy bits.
4. Divide the appended data using a divisor polynomial.
5. The resulting data should be transmitted to the receiver.
6. At the receiver the received data is entered.
7. The same process is repeated at the receiver.
8. If the remainder is zero there is no error otherwise there is some error in the received bits
9. Run the program.
C PROGRAM
#include<stdio.h>
char m[50],g[50],r[50],q[50],temp[50];
void caltrans(int);
void crc(int);
void calram();
void shiftl();
int main()
{
int n,i=0;
char ch,flag=0;
printf("Enter the frame bits:");
while((ch=getc(stdin))!='\n')
m[i++]=ch;
n=i;
for(i=0;i<16;i++)
54
IT1503 NETWORKS LEBORATORY III YEAR IT / V SEMESTER
m[n++]='0';
m[n]='\0';
printf("Message after appending 16 zeros:%s",m);
for(i=0;i<=16;i++)
g[i]='0';
g[0]=g[4]=g[11]=g[16]='1';g[17]='\0';
printf("\ngenerator:%s\n",g);
crc(n);
printf("\n\nquotient:%s",q);
caltrans(n);
printf("\ntransmitted frame:%s",m);
printf("\nEnter transmitted frame:");
scanf("\n%s",m);
printf("CRC checking\n");
crc(n);
printf("\n\nlast remainder:%s",r);
for(i=0;i<16;i++)
if(r[i]!='0')
flag=1;
else
continue;
if(flag==1)
printf("Error during transmission");
else
printf("\n\nReceived freme is correct");
}
void crc(int n)
{
int i,j;
for(i=0;i<n;i++)
temp[i]=m[i];
for(i=0;i<16;i++)
r[i]=m[i];
printf("\nintermediate remainder\n");
for(i=0;i<n-16;i++)
{
if(r[0]=='1')
{
q[i]='1';
calram();
}
else
{
q[i]='0';
shiftl();
}
r[16]=m[17+i];
r[17]='\0';
printf("\nremainder %d:%s",i+1,r);
for(j=0;j<=17;j++)
temp[j]=r[j];
}
55
IT1503 NETWORKS LEBORATORY III YEAR IT / V SEMESTER
q[n-16]='\0';
}
void calram()
{
int i,j;
for(i=1;i<=16;i++)
r[i-1]=((int)temp[i]-48)^((int)g[i]-48)+48;
}
void shiftl()
{
int i;
for(i=1;i<=16;i++)
r[i-1]=r[i];
}
void caltrans(int n)
{
int i,k=0;
for(i=n-16;i<n;i++)
m[i]=((int)m[i]-48)^((int)r[k++]-48)+48;
m[i]='\0';
}
OUTPUT:
Enter the Frame Bits:
1011
The msg after appending 16 zeros:
10110000000000000000
The Transmitted frame is:10111011000101101011
Enter the transmitted Frame
10111011000101101011
Received msg:10111011000101101011
The Remainder is:0000000000000000
Received frame is correct.
RESULT:
Thus the error detection and error correction is implemented successfully.
56
IT1503 NETWORKS LEBORATORY III YEAR IT / V SEMESTER
Expt No: 11
Upon completion of this content beyond syllabi - the student will be able to:
57
IT1503 NETWORKS LEBORATORY III YEAR IT / V SEMESTER
Cisco IOS Location of the Cisco IOS
Console
Telnet or SSH
AUX port
58
IT1503 NETWORKS LEBORATORY III YEAR IT / V SEMESTER
Accessing a Cisco IOS Device - Telnet, SSH, and AUX Access Methods
Telnet
Out-of-band connection
Uses telephone line
Can be used like console port
Accessing a Cisco IOS Device - Terminal Emulation Programs
PuTTY
Tera Term
SecureCRT
HyperTerminal
OS X Terminal
59
IT1503 NETWORKS LEBORATORY III YEAR IT / V SEMESTER
Navigating the IOS -Primary Modes
60
IT1503 NETWORKS LEBORATORY III YEAR IT / V SEMESTER
Submodes
61
IT1503 NETWORKS LEBORATORY III YEAR IT / V SEMESTER
The Command Structure - IOS Command Structure
62
IT1503 NETWORKS LEBORATORY III YEAR IT / V SEMESTER
Banner Messages
63