Professional Documents
Culture Documents
List of Experiments
List of Experiments
9.
PERFORMANCE EVALUATION OF ROUTING PROTOCOLS USING
SIMULATION TOOL
80GB HDD
512MB DDR
SOFTWARE REQUIREMENT
ORACLE 8i,9i.
MY SQL,
DB2.
2
EXP NO1
NETWORKING COMMANDS
AIM
To study the basic networking commands.
C:\>arp –a: ARP is short form of address resolution protocol, It will show the IP address of
your computer along with the IP address and MAC address of your router.
C:\>hostname: This is the simplest of all TCP/IP commands. It simply displays the name of
your computer.
C:\>ipconfig: The ipconfig command displays information about the host (the computer
your sitting at)computer TCP/IP configuration.
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.
C:\>Ipconfig /renew: Using this command will renew all your IP addresses that you are
currently (leasing) borrowing from the DHCP server. This command is a quick problem
solver if you are having connection issues, but does not work if you have been configured
with a static IP address.
C:\>Ipconifg /release: This command allows you to drop the IP lease from the DHCP
server.
C:\>ipconfig /flushdns: This command is only needed if you’re having trouble with your
networks DNS configuration. The best time to use this command is after network
configuration frustration sets in, and you really need the computer to reply with flushed.
C:\>nbtstat –a: This command helps solve problems with NetBIOS name resolution.
(Nbt stands for NetBIOS over TCP/IP)
C:\>netdiag: Netdiag is a network testing utility that performs a variety of network diagnostic
tests, allowing you to pinpoint problems in your network. Netdiag isn’t installed by default,
but can be installed from the Windows XP CD after saying no to the install. Navigate to the
CD ROM drive letter and open the support\tools folder on the XP
CD and click the setup.exe icon in the support\tools folder.
C:\>nslookup: Nslookup is used for diagnosing DNS problems. If you can access a
resource by specifying an IP address but not it’s DNS you have a DNS problem.
C:\>pathping: Pathping is unique to Window’s, and is basically a combination of the Ping
and Tracert commands. Pathping traces the route to the destination address then launches a
25 second test of each router along the way, gathering statistics on the rate of data loss along
each hop.
C:\>ping: Ping is the most basic TCP/IP command, and it’s the same as placing a phone call
to your best friend. You pick up your telephone and dial a number, expecting your best friend
to reply with “Hello” on the other end. Computers make phone calls to each other over a
network by using a Ping command. The Ping commands main purpose is to place a phone
call to another computer on the network, and request an answer. Ping has 2 options it can use
to place a phone call to another computer on the network. It can use the computers name or
IP address.
C:\>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. But if you’re having trouble
accessing other computers on your network, you can use the route command to make sure the
entries in the routing table are correct.
C:\>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.
C:\>tcpdump: It is a most powerful and widely used command-line packets sniffer or package
analyzer tool which is used to capture or filter TCP/IP packets that received or transferred
over a network on a specific interface.
RESULT
Thus the above list of primitive has been studied.
EXP: 2
WEB PAGE DOWNLOADING
AIM
To download a webpage using Java
ALGORITHM:
CLIENT SIDE:
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 the url to server.
4) Open a file and store the received data into the file.
5) Close the socket.
6) End the program.
SERVER SIDE
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 url from client.
5) Download the content of the url received and send the data to client.
6) Close the socket.
7) End the program.
PROGRAM
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("digital_image_processing.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();
}catch (Exception e) {
System.out.println("Exception: " + e.getMessage());
soc.close();
}
soc.close();
}
}
SERVER PROGRAM
import java.net.*;
import java.io.*;
import java.awt.image.*;
import javax.imageio.*;
import javax.swing.*;
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); }}
OUTPUT
RESULT
The webpage is successfully downloaded and the contents are displayed and verified.
EXP: 3A
SOCKET PROGRAM FOR ECHO.
AIM
To write a socket program for implementation of echo.
ALGORITHM
CLIENT SIDE
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.
SERVER SIDE
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.
PROGRAM
ECHO CLIENT
import java.io.*;
import java.net.*;
public class eclient
{
public static void main(String args[])
{
Socket c=null;
String line;
DataInputStream is,is1;
PrintStream os;
try
{
c=new Socket("localhost",8080);
}
catch(IOException e)
{
System.out.println(e);
}
try
{
os=new PrintStream(c.getOutputStream());
is=new DataInputStream(System.in);
is1=new DataInputStream(c.getInputStream());
do
{
System.out.println("client");
line=is.readLine();
os.println(line);
if(!line.equals("exit"))
System.out.println("server:"+is1.readLine());
}while(!line.equals("exit"));
}
catch(IOException e)
{
System.out.println("socket closed");
}}}
Echo Server:
import java.io.*;
import java.net.*;
import java.lang.*;
public class eserver
{
public static void main(String args[])throws IOException
{
ServerSocket s=null;
String line;
DataInputStream is;
PrintStream ps;
Socket c=null;
try
{
s=new ServerSocket(8080);
}
catch(IOException e)
{
System.out.println(e);
}
try
{
c=s.accept();
is=new DataInputStream(c.getInputStream());
ps=new PrintStream(c.getOutputStream());
while(true)
{
line=is.readLine();
System.out.println("msg received and sent back to client");
ps.println(line);
}
}
catch(IOException e)
{
System.out.println(e);
}
}
}
OUTPUT
CLIENT
Enter the IP address 127.0.0.1
CONNECTION ESTABLISHED
Enter the data SRM
Client received SRM
SERVER
CONNECTION ACCEPTED
Server received SRM
RESULT
Thus the program for simulation of echo server was written & executed
EXP: 3B
CLIENT- SERVER APPLICATION FOR CHAT
AIM
To write a client-server application for chat using TCP
ALGORITHM
CLIENT
1. Start the program
2. Include necessary package in java
3. To create a socket in client to server.
4. The client establishes a connection to the server.
5. The client accept the connection and to send the data from client to server.
6. The client communicates the server to send the end of the message
7. Stop the program.
SERVER
1. Start the program
2. Include necessary package in java
3. To create a socket in server to client
4. The server establishes a connection to the client.
5. The server accept the connection and to send the data from server to client and
6. vice versa
7. The server communicate the client to send the end of the message.
8. Stop the program.
PROGRAM
TCPserver1.java
import java.net.*;
import java.io.*;
TCPclient1.java
import java.net.*;
import java.io.*;
public class TCPclient1
{
public static void main(String arg[])
{
Socket c=null;
String line;
DataInputStream is,is1;
PrintStream os;
try
{
c=new Socket("10.0.200.36",9999);
}
catch(IOException e)
{
System.out.println(e);
}
try
{
os=new PrintStream(c.getOutputStream());
is=new DataInputStream(System.in);
is1=new DataInputStream(c.getInputStream());
do
{
System.out.println("Client:");
line=is.readLine();
os.println(line);
System.out.println("Server:" + is1.readLine());
}
while(line.equalsIgnoreCase("quit")==false);
is1.close();
os.close();
}
catch(IOException e)
{
System.out.println("Socket Closed!Message Passing is over");
}}
OUTPUT:
SERVER
Client:Hai Server
Server: Hai Client
Client:How are you
Server: Fine
Client:quit
Server: quit
RESULT
Thus the above program a client-server application for chat using TCP / IP was
executed and successfully.
EXP: 3C
FILE TRANSFER IN CLIENT & SERVER
AIM
To Perform File Transfer in Client & Server Using TCP/IP.
ALGORITHM
CLIENT SIDE
1. Start.
2. Establish a connection between the Client and Server.
3. Socket ss=new Socket(InetAddress.getLocalHost(),1100);
4. Implement a client that can send two requests.
i) To get a file from the server.
ii) To put or send a file to the server.
5. After getting approval from the server ,the client either get file from the server or send
6. file to the server.
SERVER SIDE
1. Start.
2. Implement a server socket that listens to a particular port number.
3. Server reads the filename and sends the data stored in the file for the‘get’ request.
4. It reads the data from the input stream and writes it to a file in theserver for the
‘put’ instruction.
5. Exit upon client’s request.
6. Stop.
PROGRAM
CLIENT SIDE
import java.net.*;
import java.io.*;
bos.write(mybytearray, 0 , current);
bos.flush();
long end =
System.currentTimeMillis();
System.out.println(end-start);
bos.close();
sock.close();
}}
SERVER SIDE
import java.net.*;
import java.io.*;
SERVER OUTPUT
Connection Established
Client wants file:network.txt
CLIENT OUTPUT
RESULT
Thus the File transfer Operation is done & executed successfully.
EXP: 4
SIMULATION OF DNS USING UDP SOCKETS
AIM
To establish a link between UDP Server and UDP client.
ALGORITHM
CLIENT SIDE
1. Create UDP socket.
2. Send message to server.
3. Wait until response from server is recieved.
4. Process reply and go back to step 2, if necessary.
5. Close socket descriptor and exit.
SERVER SIDE
1. Create UDP socket.
2. Bind the socket to server address.
3. Wait until datagram packet arrives from client.
4. Process the datagram packet and send a reply to client.
5. Go back to Step 3.
UDP SERVER:
import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.SocketException;
System.out.println("Client:-" + data(receive));
// Exit the server if the client sends "bye"
if (data(receive).toString().equals("bye"))
{
System.out.println("Client sent bye.....EXITING");
break;
}
UDP CLIENT:
import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.util.Scanner;
InetAddress ip = InetAddress.getLocalHost();
byte buf[] = null;
OUTPUT:
$ ./server
Client : Hello from client
Hello message sent.
$ ./client
Hello message sent.
Server : Hello from server
RESULT
Thus the link was created between UDP Server and UDP client.
EXP: 5
SIMULATION OF ARP/RARP PROTOCOLS
Aim:
ALGORITHM:
Client
Server
Program
Client:
Server:
{
try
{
ServerSocket obj=new ServerSocket(139); Socket obj1=obj.accept();
while(true)
{
DataInputStream din=new DataInputStream(obj1.getInputStream()); DataOutputStream
dout=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++)
{
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
Enter the Logical address(IP): 165.165.80.80
RESULT
Thus the simulations of ARP/RARP protocols are executed successfully.
EXP: 6
STUDY OF NETWORK SIMULATOR AND CONGESTION CONTROL
ALGORITHM
Aim:
Ns functionalities
Wireless
Most of the commercial simulators are GUI driven, while some network simulators are
CLI driven. The network model / configuration describes the state of the network
(nodes,routers, switches, links) and the events (data transmissions, packet error etc.). An
important output of simulations are the trace files. Trace files log every packet, every event that
occurred in the simulation and are used for analysis. Network simulators can also provide other
tools to facilitate visual analysis of trends and potential trouble spots.
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.
Simulation of networks is a very complex task. For example, if congestion is high, then
estimation of the average occupancy is challenging because of high variance. To estimate the
likelihood of a buffer overflow in a network, the time required for an accurate answer can be
extremely large. Specialized techniques such as "control variates" and "importance sampling"
have been developed to speed simulation.
Examples of network simulators
There are many both free/open-source and proprietary network simulators. Examples of
notable network simulation software are, ordered after how often they are mentioned in research
papers:
1. ns (open source)
2. OPNET (proprietary software)
3. NetSim (proprietary software)
Network simulators serve a variety of needs. Compared to the cost and time involved in setting
up an entire test bed containing multiple networked computers, routers and data links, network
simulators are relatively fast and inexpensive. They allow engineers, researchers to test
scenarios that might be particularly difficult or expensive to emulate using real hardware - for
instance, simulating a scenario with several nodes or experimenting with a new protocol in the
network. Network simulators are particularly useful in allowing researchers to test new
networking protocols or changes to existing protocols in a controlled and reproducible
environment. A typical network simulator encompasses a wide range of networking
technologies and can help the users to build complex networks from basic building blocks such
as a variety of nodes and links. With the help of simulators, one can design hierarchical
networks using various types of nodes like computers, hubs, bridges, routers, switches, links,
mobile units etc.
Various types of Wide Area Network (WAN) technologies like TCP, ATM, IP etc. and Local
Area Network (LAN) technologies like 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 morepacketsof data travelling across a computer networkfail to reachtheir
destination. Packet loss is distinguished as one of the three main error types encountered in
digital communications; the other two being bit errorand 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
transportlayer 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.
Incommunicationnetworks, such asEthernetorpacket radio, throughputor network throughputis
the average rate of successfulmessage delivery over a communication channel. The throughput
is usually measured inbitsper second (bit/s orbps), andsometimes indata packetsper second or
data packets pertime slotThis measure how soon the receiver is able to get a certain amount of
data send by the sender. It is determined as the ratio of the total data received to the end to end
delay. Throughput is an important factor which directly impacts the network performance
Delay
Delay is the time elapsed while a packet travels from one point e.g., source premise or network
ingress to destination premise or network degrees. The larger the valueof delay, the more
difficult it is for transport layer protocols to maintain highbandwidths. We will calculate end to
end delay
Queue Length
A queuing system in networks can be described as packets arriving for service, waiting for
service if it is not immediate, and if having waited for service, leaving thesystem after being
served. Thus queue length is very important characteristic to determine that how well the active
queue management of the congestion control algorithm has been working.
RESULT:
Aim:
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, this paper presents a comparison of the performance of both TCP and
UDP to precisely determine which of these protocols is better. 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
The UDP and TCP are various on the basic operations and applications. The differences in the
data transmission, the TCP presents ordered and reliable delivery of data from the user to the
server and vice versa. UDP considered as a connectionless protocol and does not provide the
reliable delivery for the data. UDP and TCP are various from each other in terms of the basic
features for the data transmission [13]. However, TCP is more reliable comparing to the UDP,
where TCP uses the retransmissions and the message acknowledgment if there is some loss in
the packets. Therefore, there is no losing data in the network. While in the case of UDP does
not guarantee that the data has arrived to the receiver or not. Also, in UDP there is no
retransmission, timeout and message acknowledgment. TCP transmits the messages in an order
and these messages are received in the same order at the destination. If the packets of the data
reach in the wrong order, TCP can reorder the data packets. Whilst in UDP, the sequence of the
message is not maintained over the transmission. TCP records the data as a stream of bytes and
sending the message as segments. The messages in UDP are sending as datagrams in the
network. So, both of TCP and UDP have various approaches of sending and receiving the data
Figure 2 shows a comparative among TCP and UDP.
RESULT:
Thus the Performance of TCP and UDP were studied..
EXP: 8
SIMULATION OF DISTANCE VECTOR/LINK STATE ROUTING
ALGORITHM
AIM
To study the link state routing
Routing, in a more narrow sense of the term, is often contrasted with bridging in its
assumption that network addresses are structured and that similar addresses imply
proximity within the network. Structured addresses allow a single routing table entry to
represent the route to a group of devices. In large networks, structured addressing (routing,
in the narrow sense) outperforms unstructured addressing (bridging). Routing has become
the dominant form of addressing on the Internet. Bridging is still widely used within
localized environments.
ALGORITHM
There are several variants of flooding algorithm. Most work roughly as follows:
1. Each node acts as both a transmitter and a receiver.
2. Each node tries to forward every message to every one of its neighbours except the
source node.
This results in every message eventually being delivered to all reachable parts of the
network.
Algorithms may need to be more complex than this, since, in some case, precautions have
to be taken to avoid wasted duplicate deliveries and infinite loops, and to allow messages to
eventually Exp. No.ire from the system. A variant of flooding called selective flooding
partially addresses these issues by only sending packets to routers in the same direction. In
selective flooding the routers don't send every incoming packet on every line but only on
those lines which are going approximately in the right direction.
DISTANCE VECTOR
In computer communication theory relating to packet-switched networks, a distance-
vector routing protocol is one of the two major classes of routing protocols, the other major
class being the link-state protocol. Distance-vector routing protocols use the Bellman–Ford
algorithm, Ford–Fulkerson algorithm, or DUAL FSM (in the case of Cisco Systems's
protocols) to calculate paths.
A distance-vector routing protocol requires that a router informs its neighbors of topology
changes periodically. Compared to link-state protocols, which require a router to inform all
the nodes in a network of topology changes, distance-vector routing protocols have less
computational complexity and message overhead.
The term distance vector refers to the fact that the protocol manipulates vectors
(arrays) of distances to other nodes in the network. The vector distance algorithm was the
original ARPANET routing algorithm and was also used in the internet under the name of
RIP (Routing Information Protocol).
Examples of distance-vector routing protocols include RIPv1 and RIPv2 and IGRP.
Method
Routers using distance-vector protocol do not have knowledge of the entire path to
a destination. Instead they use two methods:
1. Direction in which router or exit interface a packet should be forwarded.
2. Distance from its destination
Distance-vector protocols are based on calculating the direction and distance to any
link in a network. "Direction" usually means the next hop address and the exit interface.
"Distance" is a measure of the cost to reach a certain node. The least cost route between any
two nodes is the route with minimum distance. Each node maintains a vector (table) of
minimum distance to every node. The cost of reaching a destination is calculated using
various route metrics. RIP uses the hop count of the destination whereas IGRP takes into
account other information such as node delay and available bandwidth.
Updates are performed periodically in a distance-vector protocol where all or part of a
router's routing table is sent to all its neighbors that are configured to use the same distance-
vector routing protocol. RIP supports cross-platform distance vector routing whereas IGRP
is a Cisco Systems proprietary distance vector routing protocol. Once a router has this
information it is able to amend its own routing table to reflect the changes and then inform
its neighbors of the changes. This process has been described as ‗routing by rumor‘
because routers are relying on the information they receive from other routers and cannot
determine if the information is actually valid and true. There are a number of features which
can be used to help with instability and inaccurate routing information.
Method
Routers using distance-vector protocol do not have knowledge of the entire path to
a destination. Instead they use two methods:
1. Direction in which router or exit interface a packet should be forwarded.
2. Distance from its destination
Distance-vector protocols are based on calculating the direction and distance to any link in a
network. "Direction" usually means the next hop address and the exit interface. "Distance"
is a measure of the cost to reach a certain node. The least cost route between any two
nodes is the route with minimum distance. Each node maintains a vector (table) of
minimum distance to every
node. The cost of reaching a destination is calculated using various route metrics. RIP
uses the hop count of the destination whereas IGRP takes into account other information
such as node delay and available bandwidth. Updates are performed periodically in a
distance-vector protocol where all or part of a router's routing table is sent to all its
neighbors that are configured to use the same distance-vector routing protocol. RIP supports
cross-platform distance vector routing whereas IGRP is a Cisco Systems proprietary
distance vector routing protocol. Once a router has this information it is able to amend its
own routing table to reflect the changes and then inform its neighbors of the changes. This
process has been described as routing by rumor‘ because routers are relying on the
information they receive from other routers and cannot determine if the information is
actually valid and true. There are a number of features which can be used to help with
instability and inaccurate routing information.
EGP and BGP are not pure distance-vector routing protocols because a distance-vector
protocol calculates routes based only on link costs whereas in BGP, for example, the local
route preference value takes priorityover the link cost.
Count-to-infinity problem
The Bellman–Ford algorithm does not prevent routing loops from happening and suffers
from the count to infinity problem. The core of the count-to-infinity problem is that if A
tells B that it has a path somewhere, there is no way for B to know if the path has B as a part
of it. To see the problem clearly, imagine a subnet connected like A–B–C–D–E–F, and let
the metric between the routers be "number of jumps". Now suppose that A is taken offline.
In the vector-update-process B notices that the route to A, which was distance 1, is down –
B does not receive the vector update from A. The problem is, B also gets an update from
C, and C is still not aware of the fact that A is down – so it tells B that A is only two jumps
from C (C to B to A), which is false. This slowly propagates through the network until it
reaches infinity (in which case the algorithm corrects itself, due to the relaxation property of
Bellman–Ford).
Sample program:
set ns [new
Simulator] set
nr [open
thro.tr w]
$ns trace-all $nr
setnf [open thro.nam w]
$ns namtrace-
all $nf proc
finish { }
{global ns nr nf
$ns
flush-
trace
close
$nf
close
$nr
execnamthro.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 }
RESULT:
Thus the simulation of Distance vector/Link State Routing algorithm was performed.
EXP: 9
PERFORMANCE EVALUATION OF ROUTING PROTOCOLS USING
SIMULATION TOOL
AIM
To learn the performance evaluation of Routing Protocols using Simulation tool.
ROUTING PROTOCOL:
Routing Protocol is used to find valid routes between communicating nodes. They do not use
any access points to connect to other nodes .It must be able to handle high mobility of the
nodes. Routing protocols can be mainly classified into 3 categories.
In centralized algorithms, all route choices are made by central node, while in distributed
algorithms, the computation of routes is shared among the network nodes. In static algorithms
the route used by source destination pairs is fixed regardless of traffic condition. It can only
change in response to a node or link failure. This type of algorithm cannot achieve high
throughput under a broad variety of traffic input patterns. In adaptive routing, the routes used
to route between source destination pairs may change in response to congestion.
Routing is the process of finding a path from a source to destination among randomly
distributed routers. MANET routing protocols are classified as follows on the basis of the
way the network information is obtained in these routing protocols.
The Proactive routing protocols, consistent and up-to-date routing information to all nodes is
maintained at each node. For example
1.Optimized Link state Routing Protocols (OLSR)
2.Destination Sequenced Distance Vector Routing (DSDV)
ii. Reactive or On-demand routing protocol The reactive routing protocols look for the
routes and are created as and when required. When a source wants to send to a destination, it
invokes the route discovery mechanisms to find the path to the destination. It does not need
to search for and maintain the routes on which there is no route request. Reactive routing
protocols are very pleasing in the resource-limited environment. However the source node
should wait until a route to the destination is discovered. This approach is best suitable when
the network is static and traffic is very light. For example, 1. Ad-Hoc On-demand Distance
Vector (AODV) [9] 2. Dynamic Source Routing (DSR) iii. Hybrid Protocols These protocols
are using the best features of both the ondemand and table driven routing protocols. The Ad
Hoc network can use the hybrid routing protocols that have the advantage of both proactive
and reactive routing protocols to balance the delay and control overhead (in terms of control
packages). The difficulty of all hybrid routing protocols is the complexity of organizing the
network according to network parameters. The common disadvantage of hybrid routing
protocols is that the nodes that have high level topological information maintains more
routing information, which leads to more memory and power consumption. For example 1.
Temporally ordered routing algorithm (TORA) 2. Zone Routing Protocol (ZRP) There are
two approaches to evaluate routing protocols: Network Environment Parameters like
network size, connectivity, mobility, link capacity etc. General Performance Metrics of
Routing Protocols like message delivery ratio, control overhead, hop count, end to end delay,
etc. In this paper packet delivery ratio and average end to end delay performance parameters
are considered.
Overview of AODV:
Ad-hoc On Demand Distance Vector Routing Protocol (AODV) is one of the reactive protocol
in which source node initiates data packet to destination node only when requires the route
discovery is occur. there are no periodical exchanges of routing information.[9] The Protocol
consist of two phases: i) Route Discovery ii) Route Maintenance. i. Route Discovery AODV
routing protocol uses a broadcast route discovery mechanism and it depends on dynamically
established route. AODV builds routes by using a route request (RREQ)/ route reply (RREP)
query cycle. When a source node requires a destination route for which it does not have a route
already, it broadcasts RREQ packet across the network The nodes receiving this packet update
the information for the source node and sets up backward pointer information for the source
node in the routing table. A lifetime is associated with each reverse route entry, i.e. if the route
entry is not used within the lifetime it will be removed. AODV route discovery process ii. Route
Maintenance The second phase of the protocol is called route maintenance. It is performed by
the source node and can be subdivided into: i) source node moves: source node initiates a new
route discovery process, ii) destination or an intermediate node moves: a route error message
(RERR) is sent to the source node. Intermediate nodes receiving a RERR update their routing
table by setting the distance of the destination to infinity. If the source node receives a RERR it
will initiate a new route discovery. To prevent global broadcast messages AODV introduces a
local connectivity management. This is done by periodical exchanges of so called HELLO
messages which are small RREP packets containing a node's address and additional
information.
RESULT:
AIM:
import java.io.*;
class crc_gen
{
public static void main(String args[]) throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int[] data;
int[] div;
int[] divisor;
int[] rem;
int[] crc;
int data_bits, divisor_bits, tot_length;
*/ tot_length=data_bits+divisor_bits-1;
div=new int[tot_length];
rem=new int[tot_length];
crc=new int[tot_length];
/*------------------ CRC GENERATION-----------------------*/
for(int i=0;i<data.length;i++)
div[i]=data[i];
/*-------------------ERROR DETECTION---------------------*/
System.out.println();
System.out.println("Enter CRC code of "+tot_length+" bits : ");
for(int i=0; i<crc.length; i++)
crc[i]=Integer.parseInt(br.readLine());
if((rem.length-cur)<divisor.length)
break;
}
return rem;
}
}
OUTPUT :
Enter number of data bits :
7
Enter data bits :
1
0
1
1
0
0
1
Enter number of bits in divisor :
3
Enter Divisor bits :
1
0
1
Data bits are : 1011001
divisor bits are : 101
Dividend (after appending 0's) are : 101100100
CRC code :
101100111
Enter CRC code of 9 bits :
1
0
1
1
0
0
1
0
1
crc bits are : 101100101
Error
THANK YOU.... :)
Press any key to continue...
RESULT:
AIM:
TCP is relegated to rely mostly upon implicit signals it learns from the network and
remote host. TCP must make an educated guess as to the state of network and trust the
information from the remote host in order to control the rate of data flow.
A sender's implicit knowledge of network conditions may be achieved through the use of a
timer. For each TCP segment sent the sender expects to receive an acknowledgement
within some period of time otherwise an error in the form of a timer expiring signals that
something is wrong.
Whenever the TCP transmits a segment the sender starts a timer which keeps track how
long it takes for an acknowledgement for that segment to return.
This timer is known as re-transmission timer.
If acknowledgement is returned before the timer expires the timer is reset with no
consequence.
If an acknowledgement for the segment does not return with in the timeout period,
the sender re-transmit the segment and double the re-transmission timeout period.
TCP keeps track of when data is sent and at what time acknowledgements covering those
sent bytes are returned. TCP uses this information to calculate an estimate of round trip
time.
As packets are sent and acknowledged, TCP adjusts its round trip time estimate and uses
this information to come up with a reasonable timeout value for packets sent.
For example: The first successful transmission and acknowledgement of TCP segment
increases the window to two segments. After successful transmission of two segments and
acknowledgement completes, the window is increased to four segments. doubling from
there on out up to the maximum window size is advertised by the receiver or until the
congestion finally does occur.
At some point the congestion window may become too large for the network or network
conditions may change such that packets may be dropped.Packet lost will trigger a time
out at the sender. When this happens, the sender goes into congestion mode.
Congestion Avoidance
A re-transmission timer expiring or the reception of duplicate acknowledgements can
implicitly signal the sender that a network congestion situation is occurring.
The sender immediately sets its transmission window to one half of the current window
size (the minimum of the congestion window and the receiver advertised windows), but to
at least two segments.
Fast Re-transmit
RESULT
Thus the Congestion control algorithm was studied.
EXP: 12
BIT STUFFING
AIM:
ALGORITHM:
1. Start
2. Initialize the array for transmitted stream with the special bit pattern 0111 1110 which
indicates the beginning of the frame.
3. Get the bit stream to be transmitted in to the array.
4. Check for five consecutive ones and if they occur, stuff a bit 0
5. Display the data transmitted as it appears on the data line after appending 0111 1110 at
the end
6. For de−stuffing, copy the transmitted data to another array after detecting the stuffed bits
7. Display the received bit stream
8. Stop
PROGRAM
#include<stdio.H>
#include<conio.H>
#include<string.h>
void main()
{
int a[20],b[30],i,j,k,count,n;
clrscr();
printf("enter frame length:");
scanf("%d",&n);
pritf("enter input frame(0's&1's
only):");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
i=0;count=1;j=0;
while(i<n)
{
if(a[i]==1)
{
b[j]=a[i];
for(k=i+1;a[k]==1&&k<n&&count<5;k++)
{
j++;
b[j]=a[k];
count++;
if(count==5)
{
j++;
b[j]=0;
}
i=k;
}
}
else
{
b[j]=a[i];
}
i++;
j++;
}
printf("After stuffing the frame is:");
for(i=0;i<j;i++)
printf("%d",b[i]);
getch();
}
OUTPUT
RESULT
Thus the Bit Stuffing was executed successfully.
EXP: 13
CHARACTER STUFFING.
AIM:
Write a C program to Implement the data link layer framing method such as character stuffing.
ALGORITHM
1. Start
2. Append DLE STX at the beginning of the string
3. Check the data if character is present; if character DLE is present in the string (example
DOODLE) insert another DLE in the string (ex: DOODLEDLE)
4. Transmit DLE ETXat the end of the string
5. Display the string
6. Stop
PROGRAM
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<process.h>
void main()
{
int i=0,j=0,n,pos;
char a[20],b[50],ch;
clrscr();
printf("enter string:\n");
scanf("%s",&a);
n=strlen(a);
printf("enter position\n");
scanf("%d",&pos);
if(pos>n)
{
printf("invalid position,Enter again:");
scanf("%d",&pos);
}
printf("enter the character\n");
ch=getche();
b[0]='d';
b[1]='l';
b[2]='e';
b[3]='s';
b[4]='t';
b[5]='x';
j=6;
while(i<n)
{
if(i==pos-1)
{
b[j]='d';
b[j+1]='l';
b[j+2]='e';
b[j+3]=ch;
b[j+4]='d';
b[j+5]='l';
b[j+6]='e';
j=j+7;
}
if(a[i]=='d'&&a[i+1]=='l'&& a[i+2]=='e')
{
b[j]='d';
b[j+1]='l';
b[j+2]='e;
j=j+3;
}
b[j]=a[i];
i++;
j++;
}
b[j]='d';
b[j+1]='l';
b[j+2]='e';
b[j+3]='e';
b[j+4]='t';
b[j+5]='x';
b[j+6]='\0';
printf("\n frame after stuffing: \n");
printf("%s",b);
getch();
}
OUTPUT:
RESULT
Thus the Bit Stuffing was executed successfully.
EXP: 14
IMPLEMENTATION OF REMOTE COMMAND EXECUTION
AIM
RESULT
Thus the implementation RCE is done & executed successfully.
EXP: 15
TCP MODULE IMPLEMENTATION
AIM
To write a socket program for implementation of TCP module.
ALGORITHM
CLIENT SIDE
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) Close the socket.
5) End the program.
SERVER SIDE
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 the data.
6) Close the socket.
7) End the program.
CLIENT PROGRAM
import java.io.*;
import java.net.*;
RESULT
Thus the program for tcp module implementation was written & executed successfully.