CS8581-Networks Lab Manual (2020-2024)
CS8581-Networks Lab Manual (2020-2024)
Kovilvenni-614 403
Department of Computer Science and Engineering
LAB MANUAL
LIST OF 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
using NS.
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).
TOTAL: 30 PERIODS
− Explain the networking concepts of HTTP, TCP, UDP, DNS, ARP, RARP, CRC and study
the simulation of congestion control and routing algorithms using simulation tools.
4. The upper three layers of OSI model are combined into a single layer called the application.
This is the Web Client (Browser), Telnet client, Web Server, FTP server or whatever
application we are using.
5. The transport layer comprises of TCP and UDP.
6. There is a gap between TCP and UDP in figure to indicate that it is possible for an
application to bypass the transport layer and use IPv4 and IPv6 directly. This is called raw
socket.
7. The two programming interfaces are sockets and XTI(X/Open Transport Interface). It is
intended to study: how to write applications using either Sockets that use either TCP or UDP.
8. Upper three layers handle all the details of the application (FTP, Telnet or HTTP etc) and
know little about the communication details. Whereas the lower four layers know little about
the application but handle all communication details: sending data, waiting for an
acknowledgements, sequencing data that arrives out of order , calculating and verifying the
checksums and so on.
9. Upper three layers often form what is called a user process while the lower 4 layers are
normally provided as part of the operating system kernel.
Port Number
1. Port is an application-specific or process-specific software construct serving as a
communications endpoint in a computer's host operating system.
2. A port is associated with an IP address of the host, as well as the type of protocol used for
communication.
3. A port is identified for each address and protocol by a 16-bit number, commonly known
as the port number.
4. Port Numbers: At any given time multiple processes can use either UDP or TCP. Both
use 16 bit integer port numbers to differentiate between these processes.
5. TCP and UDP define a group of well-known ports that to identity well known services.
FTP assigns the well-known ports of 21 to the FTP server .Trivial FTP servers are
assigned the UDP port of 69.
6. Clients use ephemeral ports that are short lived ports. These port numbers are manually
assigned by TCP or UDP to the client.
7. The port numbers are divided into three categories
− Well known ports: 0 through 1023 .These port numbers are controlled and
assigned by the IANA. When possible same port number is assigned to a given
service of both TCP and UDP.
− The Registered Ports: 1024 through 49151.These are not controlled by the IANA,
(Internet Assigned Numbers Authority) but the IANA registers and lists the uses
of these ports as a convenience to the community.
− Dynamic private ports: 49152 through 65535. These are what we call as
ephemeral ports. It is also called Short lived transport protocol port that is created
by OS when a program requests any available user ports.
Allocation of Port Numbers
Socket Pair
1. Socket is a method for communication between a client program & a server program in a
network. A socket is defined as “the endpoint in a connection”.
2. The two values that identify each endpoint, an IP address and a port number, are called a
socket.
3. The socket pair for a TCP connection is the 4-tuple that defined the two end points of the
connection:
i) The local IP address ii) local TCP port,
ii) Foreign IP address iv) foreign TCP port.
Types of Sockets
There are 3 types of sockets
1. Stream Socket (designed to be used with a connection-oriented protocol such as TCP)
2. Datagram Socket (designed to be used with a connectionless protocol such as UDP)
3. Raw Socket (provide access to ICMP to move esoteric (secret) facilities of an existing
protocol)
Hardware
Standalone desktops: 30 Nos
Software
C / C++ / Java / Python / Equivalent Compile 30
Network simulator like NS2/Glomosim/OPNET/ Packet Tracer / Equivalent
HOW TO EXECUTE
AIM
To study the basic networking commands
LINUX COMMANDS
1. tcpdump
tcpdump command is also called as packet analyzer. A packet analyzer is a computer
application used to track, intercept and log network traffic that passes over a digital network. It
analyzes network traffic and generates a customized report to assist organizations in managing
their networks.
a. $ sudo tcpdump -i any
In this example, tcpdump captured all the packets flows in the interface any and displays
in the standard output.
b. $ sudo tcpdump –c2 –i any
This command captured only 2 packets from interface any.
c. $ sudo tcpdump –A –i any
It displays captured packets in ASCII using tcpdump -A
d. $ sudo tcpdump –XX –i any
Some users might want to analyse the packets in hex values. tcpdump provides a way to
print packets in both ASCII and HEX format. It display captured packets in HEX and ASCII
using tcpdump -XX
e. $ sudo tcpdump –w my.pcap –i any
tcpdump allows you to save the packets to a file, and later you can use the packet file for
further analysis. -w option writes the packets into a given file. The file extension should be .pcap,
which can be read by any network protocol analyzer.
f. $ sudo tcpdump –r my.pcap
We can read the captured pcap file and view the packets for analysis. It reads the packets
from a saved file using tcpdump –r
g. $ sudo tcpdump –n –i any
In all the above examples, it prints packets with the DNS address, but not the ip address.
This captures the packets and it will display the IP address of the machines involved.
h. $ sudo tcpdump –n –tttt –i any
It captures packet with proper readable timestamp using tcpdump -tttt
i. $ sudo tcpdump -i any arp
We can receive the packets based on the protocol type. We can specify one of these
protocols - fddi, tr, wlan, ip, ip6, arp, rarp, decnet, tcp and udp. This command captures only arp
packets flowing through the any interface.
j. $ sudo tcpdump -i any port 22
If we want to know all the packets received by a particular port on a machine, we can use
tcpdump command as shown above. It receives packet flows on a particular port using tcpdump
port.
WINDOWS COMMANDS
2. netstat
Netstat is a useful tool for checking network and Internet connections. Some useful
applications for the average PC user are considered, including checking for malware
connections.
The command syntax is
netstat [-a] [-b] [-e] [-f] [-n] [-o] [-p proto] [-r] [-s] [-t] [-v] [interval]
Command: C:/netstat -a
3. ipconfig
The ipconfig command displays information about the host (the computer your sitting at)
computer TCP/IP configuration.
a) ipconfig /all
Command: C:/ipconfig /all
This command displays detailed configuration information about your TCP/IP connection
including Router, Gateway, DNS, DHCP, and type of Ethernet adapter in your system.
b) ipconfig /renew
Command: C:/ipconfig /renew
It will renew all your IP addresses that you are currently (leasing) borrowing from the
DHCP server.
4. nslookup
nslookup, which stands for "name server lookup", finds information about a named
domain. nslookup is a great utility for diagnosing DNS name resolution problems. By
default, nslookup will translate a domain name to an IP address (or vice versa).
Command: C:/nslookup Microsoft.com
It will display the name and IP address of the device’s default DNS server. The following
commands can be used within NSlookup.
Command Description
name Displays information about the host/domain name using the default server.
name name2 As above, but uses the value entered for name2 as the server to query.
Displays information on common commands and their syntax. You can also type ?
help
to view the same list.
set option Set an option. See the table below for a list of options.
server name Set the default server to name using the current details server.
root Set the current default server to root.
-a List canonical names and addresses.
-d List all records.
-t type Displays information about the host/domain name using the default server
exit Exit NSLookup.
5. arp
ARP is short form of address resolution protocol.
Command: C: / arp –a
It will show the IP address of your computer along with the IP address and MAC address
of your router.
6. hostname
This is the simplest of all TCP/IP commands.
Command: C:\hostname
It simply displays the name of your computer.
7. pathping
pathping sends multiple echo Request messages to each router between a source and
destination over a period of time and then computes results based on the packets returned from
each router. pathping performs the equivalent of the tracert command by identifying which
routers are on the path. It then sends pings periodically to all of the routers over a specified time
period and computes statistics based on the number returned from each.
Command: C:\ pathping /n corp1
Syntax:
pathping [/n] [/h] [/g <Hostlist>] [/p <Period>] [/q <NumQueries> [/w <timeout>] [/i
<IPaddress>] [/4 <IPv4>] [/6 <IPv6>][<TargetName>]
8. ping
The ping command is a command prompt command used to test the ability of the source
computer to reach a specified destination computer.
Command: C:\ ping google.com
The ping command is usually used as a simple way to verify that a computer can
communicate over the network with another computer or network device.
9. route
The route command displays the computers routing table. A typical computer, with a
single network interface, connected to a LAN, with a router is fairly simple and generally doesn’t
pose any network problems.
Command: C:\ route print
If we are having trouble accessing other computers on your network, we can use the route
command to make sure the entries in the routing table are correct.
10.tracert
The tracert command displays a list of all the routers that a packet has to go through to
get from the computer where tracert is run to any other computer on the internet.
Command: C:\ tracert google.com
RESULT
Thus the basic networking commands were studied.
RESULT
Thus the simulation of ping and trace route commands were implemented.
EX.NO: 02 Creation of sockets for HTTP web page upload and download
AIM
To create a socket for HTTP web page upload and download.
CONCEPT
HTTP
1. HTTP functions as a request-response protocol in the client-server computing model.
2. A web browser, for example, may be the client and an application running on a
computer hosting a web site may be the server.
3. The client submits an HTTP request message to the server. The server, which
provides resources such as HTML files and other content, or performs other functions on
behalf of the client, returns a response message to the client.
4. The response contains completion status information about the request and may also
contain requested content in its message body.
5. A web browser is an example of a user agent (UA).
6. HTTP is an application layer protocol designed within the framework of the Internet
Protocol Suite.
7. HTTP resources are identified and located on the network by Uniform Resource
Identifiers (URIs)—or, more specifically, Uniform Resource Locators (URLs)—using
the http or https URI schemes.
8. HTTP is designed to permit intermediate network elements to improve or enable
communications between clients and servers.
ALGORITHM
Client
1. Create a client socket with specified port.
2. Reading image from the disk.
3. Send the image to the server.
4. Close the client socket connection.
Server
1. Create a server socket with specified port.
2. Get the image from the client.
3. Display the image.
4. Close the server socket connection.
RESULT
Thus the socket for HTTP web page upload and download was created and implemented.
EX.NO: 3a Echo client and echo server application using TCP sockets
AIM
To implement and study the application 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. Echoclient creates a socket thereby getting a connection to the Echo server.
3. 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.
4. The server echoes the input back through the socket to the client. The client program reads and
displays the data passed back to it from the server.
ALGORITHM
Server
1. Start the program.
2. Create a socket which binds the Ip address of server and the port address to acquire
service.
3. After establishing connection send a data to server.
4. Receive and print the same data from server.
5. Close the socket.
6. End the program.
Client
1. Start the program.
2. Create a server socket to activate the port address.
3. Create a socket for the server socket which accepts the connection.
4. After establishing connection receive the data from client.
5. Print and send the same data to client.
6. Close the socket.
7. End the program.
RESULT
Thus the application for Echo client and echo server using TCP Sockets was implemented
and studied.
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 the machine,
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 ip
address 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 the server.
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.
RESULT
Thus the application for chat using TCP Sockets was implemented and studied.
CONCEPT
1. Transferring file from one computer to another is one of the most tasks expected from a
networking or internetworking environment.
2. File transfer protocol (FTP) is the standard mechanism provided by TCP/IP for copying
a file from one host to another.
3. FTP differs from other client/server application in that it establishes two connections
between the hosts. One connection is used for data transfer the other for control
information.
4. When a user starts a FTP session, the control connection opens. While the control
connection is open, the data connection can be opened and closed multiple times of
several files are transferred.
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 BufferedReader.
5. Create a new object class file and realine.
6. If file is exists then FileReader 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 BufferReader 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.
RESULT
Thus the application for file transfer using TCP Sockets was implemented.
EX. NO: 4 Simulation of DNS using UDP sockets
AIM
To implement and study the application for DNS using TCP and UDP Sockets.
CONCEPT
1. DNS is a supporting program that is used by other program like e-mail.
2. The DNS client program sends a request to a DNS server to map the e-mail address to
corresponding IP address.
3. When the Internet was small, mapping are done by using a host file. The host file had
only two columns: name & address.
4. Each host could store host file the disk and update it periodically master host file.
5. This is impossible to have one host file to relate every address with name.
6. The solution is to divide this large amount of information into small parts and store parts
on different computer.
7. The host that needs trapping an contact closest computer hiding needed information.
This is done by DNS.
ALGORITHM
Server
Step1: Start the program.
Step2: Create the socket for the server.
Step3: Bind the socket to the port.
Step4: Listen for the incoming client connection.
Step5: Get the domain name for the client.
Step6: Check the existence of the domain in the server.
Step7: If domain matches then send the corresponding address to the client.
Step8: Stop the program execution.
Client
Step1: Start the Program.
Step2: Create the socket for the client.
Step3: Connect the socket to the Server.
Step4: Send the host name to the server to be resolved.
Step5: If the server corresponds then print the address and terminate the process.
RESULT
Thus the DNS application was simulated using UDP sockets.
EX. NO: 5a Simulation of ARP protocol
AIM
To simulate the concept of ARP protocol.
CONCEPT
ARP (Address Resolution Protocol)
1. In Ethernet network, the Ethernet controller card can send and receive using 48 bit
Ethernet address.
2. The 32 bit IP address is known to these cards. This requires a mapping of IP address to
the corresponding Ethernet address.
3. The destination node responds with its Ethernet address after hearing the request. This
protocol of asking question in getting reply is Address Resolution Protocol
4. ARP is a dynamic mapping approach for finding a physical address for known IP
address.
− An ARP request is broadcast to all station in the network
− An ARP reply is a unicast to the host requesting the mapping.
ALGORITHM
Server
1. Create a server socket and client socket.
2. Create a process.
3. Get request from client.
4. Send the physical address to the client.
5. Close server socket and client socket connection.
Client
1. Create a client socket connection with specified port.
2. Read the message from the client.
3. Send the System name to the server.
4. Read the message from the server. Print the message.
5. Close the client connection.
RESULT
Thus the concept of ARP protocol was simulated.
EX. NO: 5b Simulation of RARP protocol
AIM
To simulate the concept of RARP protocol.
CONCEPT
RARP (Reverse Address Resolution Protocol
− 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.
ALGORITHM
Server
1. Create a server socket connection with specified port.
2. Get the request from client.
3. Send the IP address to the client.
4. Close server socket
Client
1. Create a client socket connection with specified port.
2. Get the MAC address from the client.
3. Read the corresponding IP address from the server.
4. Print the IP address.
5. Close the client connection.
RESULT
Thus the concept of RARP protocol was simulated.
THEORY
Network Simulator (Version 2), widely known as NS2, is simply an event driven
simulation tool that has proved useful in studying the dynamic nature of communication
networks. Simulation of wired as well as wireless network functions and protocols (e.g., routing
algorithms, TCP, UDP) can be done using NS2.
In general, NS2 provides users with a way of specifying such network protocols and
simulating their corresponding behaviours. Due to its flexibility and modular nature, NS2 has
gained constant popularity in the networking research community since its birth in 1989. Since
1995 the Defense Advanced Research Projects Agency (DARPA) supported development of NS
through the Virtual Inter Network Testbed (VINT) project. Currently the National Science
Foundation (NSF) has joined the ride in development.
Version 1 of NS was developed in 1995 and with version 2 released in 1996. Version 2
included a scripting language called Object oriented Tcl (OTcl). It is an open source software
package available for both Windows 32 and Linux platforms.
BASIC ARCHITECTURE
In most cases, a simulation trace file is created, and is used to plot graph and/or to create
animation. NS2 consists of two key languages: C++ and Object-oriented Tool Command
Language (OTcl). While the C++ defines the internal mechanism (i.e., a backend) of the
simulation objects, the OTcl sets up simulation by assembling and configuring the objects as well
as scheduling discrete events (i.e., a frontend).
NS2 provides a large number of built-in C++ objects. It is advisable to use these C++
objects to set up a simulation using a Tcl simulation script. However, advance users may find
these objects insufficient. They need to develop their own C++ objects, and use a OTcl
configuration interface to put together these objects. After simulation, NS2 outputs either
text-based or animation-based simulation results. To interpret these results graphically and
interactively, tools such as NAM (Network AniMator) and XGraph are used. To analyze a
particular behaviour of the network, users can extract a relevant subset of text-based data and
transform it to a more conceivable presentation.
Tcl scripting
Tcl is a general purpose scripting language. [Interpreter]
− Tcl runs on most of the platforms such as Unix, Windows, and Mac.
− The strength of Tcl is its simplicity.
− It is not necessary to declare a data type for variable prior to the usage.
Uses of NS-2
− To evaluate the performance of existing network protocols.
− To evaluate new network protocols before use.
− To run large scale experiments not possible in real experiments.
− To simulate a variety of ip networks
To run NS-2 in Linux
Ensure that the location of ns is added to the environmental variable PATH and then type:
‘ns <Tclscript>’
To run NAM
Change directory to the directory where ns is installed (bin directory) e.g.
“C:\PROJECT\BIN”. To run the NAM executable type ‘nam <tracefile>’ where tracefile is the
name of the trace file produced i.e. file.tr
OTcl Scripting with NS-2
Node Creation
In NS-2, the network is constructed using nodes which are connected using links. Events
are scheduled to pass between nodes through the links. Nodes and links can have various
properties associated with them. Agents can be associated with nodes and they are responsible
for generating different packets (e.g. TCP agent or UDP agent). The traffic source is an
application which is associated with a particular agent (e.g. ping application). This is illustrated
in Figure 2. This diagram shows two nodes, a link, an agent and an application.
SOURCE CODE
# Create a simulator object
set ns [new Simulator]
# Open the nam trace file, associated with nf, log
everything as nam output in nf
set nf [open out.nam w]
$ns namtrace-all $nf
# Define a 'finish' procedure
proc finish {} {
global ns nf
$ns flush-trace
#Close the trace file
close $nf
#Execute nam on the trace file
exec nam out.nam &
exit 0
}
#Create two nodes
set n0 [$ns node]
set n1 [$ns node]
#Create a duplex link between the nodes
$ns duplex-link $n0 $n1 1Mb 10ms DropTail
#Create a UDP agent and attach it to node n0
set udp0 [new Agent/UDP]
$ns attach-agent $n0 $udp0
# Create a CBR traffic source and attach it to udp0
set cbr0 [new Application/Traffic/CBR]
$cbr0 set packetSize_ 500
$cbr0 set interval_ 0.1
$cbr0 attach-agent $udp0
#Create a Null agent (a traffic sink) and attach it to node
n1
set null0 [new Agent/Null]
$ns attach-agent $n1 $null0
#Connect the traffic source with the traffic sink
$ns connect $udp0 $null0
# Schedule events for the CBR agent
$ns at 0.5 "$cbr0 start"
$ns at 4.5 "$cbr0 stop"
#Call the finish procedure after 5 seconds of simulation
time
$ns at 5.0 "finish"
# Run the s
RESULT
Thus the Network simulator (NS2) was studied.
OUTPUT
RESULT
Thus the congestion control algorithm was simulated.
EX.NO: 7 Study of TCP/UDP Performance
AIM
To study the performance of TCP/UDP using Simulation Tool.
THEORY
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.
Network Simulator version 2.35 (NS2) is utilized to analyse and evaluate the
performance for both TCP and UDP protocols varying in the packet size and the bandwidth. In
this study, we have used two scenarios, 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.
INTRODUCTION
TCP and UDP protocols are approved to work on transport layer of a network. TCP uses
a connection oriented way to handle the data thus provides a very reliable way of handling
messaging or information where it guarantees the delivery of the message. If there is some error
in the transmission, the packet will be automatically re-sent over the network.
UDP utilizes a simple transport model with a minimum of protocol technique. Computer
applications with the UDP can transmit messages, in this situation, indicated as a datagrams, and
also can send voices and videos. There is a comparison among UDP and TCP in MANET to
evaluate the conduct of DSDV, DSR, and AODV protocols.
Comparison between TCP and UDP
RESULT
Thus the performance of TCP/UDP using Simulation Tool was studied.
EX.NO: 8a Simulation of Distance Vector Routing Algorithm
AIM
To simulate and study the Distance Vector routing algorithm using simulation.
CONCEPT
Distance Vector Routing is one of the routing algorithms in a Wide Area Network for
computing shortest path between source and destination. The Router is one main devices used in
a wide area network. The main task of the router is Routing. It forms the routing table and
delivers the packets depending upon the routes in the table-either directly or via an intermediate
devices. Each router initially has information about its all neighbors. Then this information will
be shared among nodes.
ALGORITHM
1. Create a simulator object
2. Define different colors for different data flows
3. Open a nam trace file and define finish procedure then close the trace file, and execute nam on
trace file.
4. Create n number of nodes using for loop
5. Create duplex links between the nodes
6. Setup UDP Connection between n(0) and n(5)
7. Setup another UDP connection between n(1) and n(5)
8. Apply CBR Traffic over both UDP connections
9. Choose distance vector routing protocol to transmit data from sender to receiver.
10. Schedule events and run the program.
SOURCECODE
set ns [new Simulator]
set nr [open thro.tr w]
$ns trace-all $nr
set nf [open thro.nam w]
$ns namtrace-all $nf
proc finish { } {
global ns nr nf$
ns flush-trace
close $nf
close $nr
exec nam thro.nam &
exit 0
}
for { set i 0 } { $i < 12} { incr i 1 } {
set n($i) [$ns node]}
for {set i 0} {$i < 8} {incr i} {
$ns duplex-link $n($i) $n([expr $i+1]) 1Mb 10ms DropTail }
$ns duplex-link $n(0) $n(8) 1Mb 10ms DropTail
$ns duplex-link $n(1) $n(10) 1Mb 10ms DropTail
RESULT
Thus the Distance vector Routing Algorithm was Simulated and studied.
EX.NO: 8b Simulation of Link State Routing Algorithm
AIM
To simulate and study the link state routing algorithm using simulation.
CONCEPT
In link state routing, each router shares its knowledge of its neighborhood with every
other router in the internet work. (i) Knowledge about Neighborhood: Instead of sending its
entire routing table a router sends info about its neighborhood only. (ii) To all Routers: each
router sends this information to every other router on the internet work not just to its neighbor .It
does so by a process called flooding. (iii)Information sharing when there is a change: Each router
sends out information about the neighbors when there is change.
PROCEDURE
The Dijkstra algorithm follows four steps to discover what is called the shortest path
tree(routing table) for each router:The algorithm begins to build the tree by identifying its roots.
The root router’s trees the router itself. The algorithm then attaches all nodes that can be reached
from the root. The algorithm compares the tree’s temporary arcs and identifies the arc with the
lowest cumulative cost. This arc and the node to which it connects are now a permanent part of
the shortest path tree. The algorithm examines the database and identifies every node that can be
reached from its chosen node. These nodes and their arcs are added temporarily to the tree. The
last two steps are repeated until every node in the network has become a permanent part of the
tree.
ALGORITHM
1. Create a simulator object
2. Define different colors for different data flows
3. Open a nam trace file and define finish procedure then close the trace file, and execute nam on
trace file.
4. Create n number of nodes using for loop
5. Create duplex links between the nodes
6. Setup UDP Connection between n(0) and n(5)
7. Setup another UDP connection between n(1) and n(5)
8. Apply CBR Traffic over both UDP connections
9. Choose Link state routing protocol to transmit data from sender to receiver.
10. Schedule events and run the program.
SOURCECODE
set ns [new Simulator]
set nr [open thro.tr w]
$ns trace-all $nr
set nf [open thro.nam w]
$ns namtrace-all $nf
proc finish { } {
global ns nr nf
$ns flush-trace
close $nf
close $nr
exec nam thro.nam &
exit 0
}
for { set i 0 } { $i < 12} { incr i 1 } {
set n($i) [$ns node]}
for {set i 0} {$i < 8} {incr i} {
$ns duplex-link $n($i) $n([expr $i+1]) 1Mb 10ms DropTail }
$ns duplex-link $n(0) $n(8) 1Mb 10ms DropTail
$ns duplex-link $n(1) $n(10) 1Mb 10ms DropTail
$ns duplex-link $n(0) $n(9) 1Mb 10ms DropTail
$ns duplex-link $n(9) $n(11) 1Mb 10ms DropTail
$ns duplex-link $n(10) $n(11) 1Mb 10ms DropTail
$ns duplex-link $n(11) $n(5) 1Mb 10ms DropTail
set udp0 [new Agent/UDP]
$ns attach-agent $n(0) $udp0
set cbr0 [new Application/Traffic/CBR]
$cbr0 set packetSize_ 500
$cbr0 set interval_ 0.005
$cbr0 attach-agent $udp0
set null0 [new Agent/Null]
$ns attach-agent $n(5) $null0
$ns connect $udp0 $null0
set udp1 [new Agent/UDP]
$ns attach-agent $n(1) $udp1
set cbr1 [new Application/Traffic/CBR]
$cbr1 set packetSize_ 500
$cbr1 set interval_ 0.005
$cbr1 attach-agent $udp1
set null0 [new Agent/Null]
$ns attach-agent $n(5) $null0
$ns connect $udp1 $null0
$ns rtproto LS
$ns rtmodel-at 10.0 down $n(11) $n(5)
$ns rtmodel-at 15.0 down $n(7) $n(6)
$ns rtmodel-at 30.0 up $n(11) $n(5)
$ns rtmodel-at 20.0 up $n(7) $n(6)
$udp0 set fid_ 1
$udp1 set fid_ 2
$ns color 1 Red
$ns color 2 Green
$ns at 1.0 "$cbr0 start"
$ns at 2.0 "$cbr1 start"
$ns at 45 "finish"
$ns run
OUTPUT
RESULT
Thus the Link State Routing Algorithm was Simulated and studied.
EX.NO: 9 Performance evaluation of routing protocols
AIM
To evaluate the different routing protocols using Simulation tool.
THEORY
There are two main classes of adaptive routing protocols in the internet: distance vector
and link state. Here there is a comparison between distance vector and link state. It also outlines
the pros and cons of RIP and OSPF protocols and a performance analysis with some possible
enhancement is presented.
Network Simulator (NS2) is used to obtain the performance results of the two classes
using different metrics such as throughput, packet delay and packet loss. Results of the
simulation show that OSPF has a better performance than RIP in terms of average throughput
and packet delay in different network sizes, while RIP is better than OSPF in terms of number of
packet loss in large networks.
INTRODUCTION
Networks rely on routing protocols to keep the routing tables updated. Routing is used in
networks to control and forward data. For a router to be efficient and effective, the critical factor
is the choice of the routing protocol. Routing protocols find a path between network nodes; if
multiple paths exist for a given node then the shortest path is selected by protocol. Each protocol
has a cost metric that it applies to each path. The path with lowest metric is selected by protocol.
Metrics to compare one routing protocol with another are based on convergence time to adapt to
topology changes, optimality is to choose the best path, not necessarily at minimum cost but to
ensure a minimum delay or to minimize overhead and space requirements to store the routing
table.
ROUTING PROTOCOLS
There are two types of routing protocols: static or dynamic routing protocols. Dynamic
routing protocols are superior over static routing protocols because of its scalability and
adaptability features. Dynamic routes are learned by communicating each router with another,
when a new router is added or an old router is removed, the router learns about changes, updates
its routing tables, and informs the other router about the modification. The classification of a
routing protocol is either as an interior or exterior gateway protocol. The interior gateway
protocol runs an algorithm within an Autonomous System (AS) and the exterior gateway
protocol runs an algorithm outside an AS. The interior gateway protocol is classified into two
groups: either distance vector (DV) or link state (LS). The distance vector selects the best routing
path based on a distance metric, while link state selects the best routing path by calculating the
state of each link in a path and finding the path that has the lowest total metric to reach the
destination.
The parameters used in order to evaluate the algorithm’s performance are:
Instantaneous Packet Delay: This is the average delay of all data packets routed successfully
from source to destination for a given period during an algorithm simulation.
Instantaneous Throughput: This is the number of packets successfully routed for a given time
during an algorithm simulation.
Packet Loss: This refers to the number of packets that are lost.
To save bandwidth resources and balance the load in the network, it uses a suppression
failure technique to handle link failure, so when a link fails, an adjacent node suppresses the
update message and sets a timer for a suppression interval, but other nodes are not explicitly
notified of the failure. When router R1 detects that router R2 is unreachable, R1 starts a timer,
the timer must be less than 60 seconds, if R1 receives a route from R2 before the timer expires,
the link recovers so that the suppression is successful and no notification is propagated for this
failure, otherwise a failure is propagated at the end of suppression interval and new routing tables
are computed. So RIP has fewer packets dropped than OSPF.
OPEN SHORTEST PATH FIRST (OSPF)
OSPF is an interior routing protocol that is based on link state routing. OSPF is faster
than RIP but is complex. RIP keeps track of the closest router for each destination, while OSPF
keeps track of the complete topology of all connections in the local network [5]. In OSPF each
node broadcasts the linkcost information about its adjacent links to all other nodes in the
network. Each node has a complete view of the network using link-cost information from other
nodes. It applies Dijkstra’s shortest path algorithm to get the shortest route to all nodes in the
network. A node broadcasts link-cost information whenever the link’s state is changed. Every 30
seconds it also broadcasts link-cost information.
Table 2: Advantages and Disadvantages of OSPF
OSPF’s cost metric is cost given by the administrator. The cost reflects monetary cost and
is a static value. The cost metric can be either bandwidth or link delay. In the cost metric of
OSPF is based on bandwidth. Cost is inversely proportional to bandwidth. The higher bandwidth
means a lower cost (cost = 108 /bandwidth in bps). In OSPF is extended to use a link delay as
QoS metric in order to compute routes. When packets are routed based on the shortest static cost
route, this may increase the link’s delay. In the delay-based routing algorithm, the link delay is
the sum of the link propagation delay and its mean queuing delay over the sampling interval of
the link. The delay algorithm uses threshold and incremental factors in order to return to the
computation algorithm. The threshold and incremental factors are tuned to improve the stability
of flow of traffic with an acceptable trade off of delay. The cost metric based on bandwidth or
delay is suitable for its use in multimedia and Ecommerce.
SIMULATION
A network consists of senders and receivers. The sender sends packets to the receiver by
passing intermediate nodes. To choose the path from the source to the destination, the source
runs a routing protocol such as DV or LS.
The network simulation model has the following characteristic: This model uses a
connectionless oriented UDP protocol and constant data rate. Also this model uses a connection
oriented TCP protocol and FTP.
There are several parameters to evaluate network performance such as throughput, delay
and packet loss. The environment of the simulation experiments was Ubuntu and NS-2. We used
three different sizes of networks. The smallest network had five nodes and five links. Node0 sent
a UDP protocol with constant packet rate to node3. A TCP protocol was used to send FTP from
node0 to node3. Node0 connected to node1, node1 to node3, node3 to node4, node3 to node4,
node4 to node2, and node2 to node0. Connection from node0 to node1 and connection from
node1 to node3 had a bandwidth of 1 Mbps and delay of 5 ms but other connections had a
bandwidth of 2 Mbps and delay of 2 ms.
The Network Simulator-2 (NS2) has an implementation of the OSPF protocol with static
cost is called Link State Routing. Also it has an implementation of the RIP is called Distance
Vector. The simulation study was done under Network Simulator (NS2). We first built the
network with RIP as the routing protocol and then used the same model with OSPF to evaluate
and analyze the results. To calculate packet loss we down linked and uplinked the connection
between node0 and node1 in DV, and repeated this between node0 and node2 in LS. The
topology is indicated in Figure 1. The same experiment was repeated with a larger network by
using 11 nodes and 21 nodes.
CONCLUSION
In this evaluation, we can conclude that OSPF outperforms RIP in terms of average
throughput and instant packet delay in different sizes of network. In terms of number of packets
lost,
RESULT
Thus the different routing algorithm to select the network path with its optimum and
economical during data transfer was evaluated.
AIM
To implement and study Cyclic Redundancy Check for detecting an error.
CONCEPT
1. Cyclic Redundancy Check (CRC) is a method or checking for errors in data that had been
transmitted on a communication link. A sending device applies a 8 or 16 bit polynomial
to a block of data that is to be transmitted and appends the resulting CRC to the block.
2. The receiving end applies the same polynomial to the data and compares its result with
the result appended by the sender.
3. If they agree, the data has been received successfully. If not, the sender can be notified to
resend the block of data.
ALGORITHM
Client
1. Import necessary packages
2. Create a client socket connection.
3. Get the dividend from the user.
4. Perform the binary division.
5. Store the remainder as CRC.
6. Close the connection.
Server
1. Import necessary packages
2. Create a server socket connection.
3. Get the dividend from the client.
4. Replace the zeros in the dividend as CRC.
5. Perform the binary division.
6. If the remainder is zero, then the data received successfully without error, otherwise there
is an error in data.
7. Close the server connection.
RESULT
Thus the Cyclic Redundancy Check for detecting an error was implemented and studied.
BEYOND THE SYLLABUS
AIM
To implement the performance of stop & wait protocol.
CONCEPT
1. Stop-and-Wait Protocol means that the sender sends one frame, stops until it receives
confirmation from the receiver (okay to go ahead), and then sends the next frame.
2. If data frames arrive at the receiver site faster than they can be processed, the frames must be
stored until their use.
3. Normally, the receiver does not have enough storage space, especially if it is receiving data
from many sources. This may result in either the discarding of frames or denial of service.
4. To prevent the receiver from becoming over-whelmed with frames, we need to tell the sender
to slow down.
ALGORITHM
1. Start the program.
2. Create the socket by specifying the address and establishes the connection
3. Send and receive information.
4. The sender sends one frame, stops until it receives confirmation from the receiver and
then sends the next frame.
5. Stop the program.
RESULT
Thus the concept of Stop and Wait Protocol was implemented successfully and the
inference about this protocol was studied.
AIM
To implement the performance of sliding window protocol.
CONCEPT
1. A sliding window protocol is a feature of packet-based data transmission protocols.
conceptually, each portion of the transmission is assigned a unique consecutive sequence
number, and the receiver uses the numbers to place received packets in the correct order.
2. Sliding window protocol allows an unlimited number of packets to be communicated
using fixed-size sequence numbers.
3. The term "window" on transmitter side represents the logical boundary of the total
number of packets yet to be acknowledged by the receiver.
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
NAK signal to client.
6. Stop the program
RESULT
Thus the concept of Sliding Window Protocol was implemented successfully and the
inference about this protocol was studied.
AIM
To implement and study the concept of RPC (remote procedure call)
CONCEPT
1. RPC is a powerful technique for constructing distributed, client-server based applications,
based on extending the notion of conventional or local procedure calling.
2. When a process on machine 1 calls a procedure on machine 2, the calling process on 1 is
suspended and execution of the called procedure takes place on 2.
3. Information can be transported from the caller to the call in the procedure result. No message
passing is visible to the programmer. This technique is known as RPC.
4. To call a remote procedure the client program must be bound with a small library procedure
called the client stub, that represents the sever procedure in the client address space.
ALGORITHM
1. Start the program.
2. Create a server socket at the server side.
3. Create a socket at the client side and the connection is set to accept by the server socket using
the accept () method.
4. In the client side the command to be executed is given as input.
5. The command is obtained using the readLine () method of Buffer Reader.
6. Get the runtime object of the runtime class using getruntime ().
7. Execute the command using the exec () method of runtime.
8. Stop the program.
RESULT
Thus the concept of Remote Procedure Call was implemented.
AIM
To implement and study the concept of sub netting.
CONCEPT
1. To filter packets for a particular network, a router uses a concept known as masking which
filters out the net id part by removing the host id part.
2. The net id part is then comparing with the network address. All the hosts in a network must
have the same network number. This property of IP addressing causes problem as the network
grows.
3. To overcome this problem, a concept known as subnets is used, which splits a network into
several parts for internal use, but still acts like a single network to the outside world.
4. Sub netting reduces router table space by creating a three-level hierarchy; net id, subnet id
followed by hostid.
ALGORITHM
1. Start the program.
2. Get an IP address and split as binary.
3. Given string will be converted into integer for calculating number of addresses.
4. To calculate mask for the Ip address.
5. To calculate first and last address for the subnet.
6. Stop the program.
RESULT
Thus the concept for sub netting has been implemented.
LAB PLAN
Cumul
No. of
Hour Ex. ative
Topic Name period
No. No. No. of
s
periods
1. 1a Basic Network Commands
6 6
2. 1b Simulation of Ping &Trace Route Command
2 Creation of sockets for HTTP web page upload and
3. 6 12
download
4. 3 Echo client and echo server application using TCP sockets 6 18
5. 4 Chat application using TCP sockets 3 21
References:
https://www.tecmint.com/12-tcpdump-commands-a-network-sniffer-tool/
https://www.linuxtechi.com/capture-analyze-packets-tcpdump-command-linux/
https://www.thegeekstuff.com/2010/08/tcpdump-command-examples