College of Engineering &technology: Mahatma Gandhi Mission's
College of Engineering &technology: Mahatma Gandhi Mission's
S. No. TITLE
5. Socket programming using UDP and TCP (e.g., simple DNS, data &
time client/server, echo client/server, iterative & concurrent servers.
10. To perform case study for different routing algorithms to select the
network path using LINK STATE ROUTING b) FLOODING c)
DISTANCE VECTOR.
11. Implementation of Stop and Wait Protocol and Sliding Window Protocol
13. To implement socket programming date and time display from client to server
using TCP and UDP Sockets.
15. Applications using TCP Sockets like a. Echo client and echo server
b. Chat c. File Transfer.
16. Applications using TCP and UDP Sockets like DNS, SNMP, File Transfer
EXPERIMENT NO.-01
Aim: To learn handling and configuration of networking hardware like RJ-
45 connector, CAT-6 cable, crimping tool, etc.
Description:
RJ-45 (Registered Jack): The acronym for Registered Jack-45 is RJ-45. The RJ-45 connector
is an eight-wire connector that is commonly used to connect computers to a local area network
(LAN), particularly Ethernet LANs. Although they are slightly larger than the more commonly
used RJ-11 connectors, RJ-45s can be used to connect some types of telephone equipment.
RJ-45 can be easily crimped to a cable with or without a crimping tool. If you have a crimping
tool, strip away a portion of the sheath, untangle and arrange the wires in the correct order, fit
them into the connector, and use the crimping part of your tool to squeeze the small pins into
the wires and secure the connector. If you don’t have a crimping tool, no problem! Use a pair
of scissors or a utility knife to cut away a section of the sheathing at the end of the cable, untwist
and arrange the small cables in the right order, put them into the RJ-45 connector, and use a
small, flathead screwdriver to press down each of the pins.
Pre-Experiment:
(i) What is the use of RJ-45 connector and CAT cables in computer
networking?
(ii) How is crimping tool used to connect devices like RJ-45, CAT- cable-6 etc?
Method:
Using a crimping tool: Strip the cable back 1 inch (25 mm) from the end. Insert the cable
into the stripper section of the tool and squeeze it tight. Then, rotate the crimping tool around
the cable in a smooth and even motion to create a clean cut. Keep the tool clamped and pull
away towards the end of the wire to remove the sheathing.[1]
The stripping section is a round hole near the handle of the tool.
The sheathing should come off cleanly, leaving the wires exposed
2. Untwist and straighten the wires inside of the cable. Inside of the cable you’ll see a bunch
of smaller wires twisted together. Separate the twisted wires and straighten them out so they’re
easier to sort into the right order.[2]
Cut off the small plastic wire separator or core so it’s out of the way.
Don’t cut off or remove any of the wires or you won’t be able to crimp them into the connector.
3. Arrange the wires into the right order. Use your fingers to put the wires in the correct
order so they can be properly crimped. The proper sequence is as follows from left to right:
Orange/White, Orange, Green/White, Blue, Blue/White, Green, Brown/White, Brown.[3]
• There are 8 wires in total that need to be arranged in the right sequence.
• Note that the wires labeled Orange/White or Brown/White indicate the small wires that have 2
colors.
4. Cut the wires into an even line 1⁄2 inch (13 mm) from sheathing. Hold the wires with your
thumb and index finger to keep them in order. Then, use the cutting section of the crimping
tool to cut them into an even line.[4]
The cutting section of the tool will resemble wire cutters.
The wires must be in an even line to be crimped into the RJ-45 connector properly. If you cut
them in an uneven line, move further down the wires and cut them again.
5. Insert the wires into the RJ-45 connector. Hold the RJ-45 connector so the clip is on the
underside and the small metal pins are facing up. Insert the cable into the connector so that
each of the small wires fits into the small grooves in the connector.
• The sheathing of the cable should fit just inside of the connector so it’s past the base.
If any of the small wires bend or don’t fit into a groove correctly, take the cable out and
straighten the wires with your fingers before trying again.
The wires must be inserted in the correct order and each wire must fit into a groove before you
crimp the connector.
6. Stick the connector into the crimping part of the tool and squeeze twice. Insert the
connector in the crimping section of the tool until it can’t fit any further. Squeeze the handles
to crimp the connector and secure the wires. Release the handles, then squeeze the tool again
to make sure all of the pins are pushed down.
The crimping tool pushes small pins in the grooves down onto the wires to hold and connect
them to the RJ-45 connector.
7. Remove the cable from the tool and check that all of the pins are down. Take the
connector out of the tool and look at the pins to see that they’re all pushed down in an even
line. Lightly tug at the connector to make sure it’s attached to the cable.[7]
If any of the pins aren’t pushed down, put the wire back into the crimping tool and crimp it
again.
EXPERIMENT NO.-02
Aim: Configuration of router, hub, switch etc. (using real devices or
simulators)
Pre-Experiment Questions:
(i) What is the functionality of basic physical layer devices like
repeater, hub, switch etc.?
(ii) What are the pre-requisites for the connection of basic physical
layer devices?
Description:
1. Repeater: Functioning at Physical Layer: A repeater is an electronic device that receives a
signal and retransmits it at a higher level and/or higher power, or onto the other side of an
obstruction, so that the signal can cover longer distances. Repeater have two ports ,so cannot
be use to connect for more than two devices
2. Hub: An Ethernet hub, active hub, network hub, repeater hub, hub or concentrator is a device
for connecting multiple twisted pair or fiber optic Ethernet devices together and making them
act as a single network segment. Hubs work at the physical layer (layer 1) of the OSI model.
The device is a form of multiport repeater. Repeater hubs also participate in collision detection,
forwarding a jam signal to all ports if it detects a collision.
3. Switch: A network switch or switching hub is a computer networking device that connects
network segments.The term commonly refers to a network bridge that processes and routes
data at the data link layer (layer 2) of the OSI model. Switches that additionally process data at
the network layer (layer 3 and above) ar often referred to as Layer 3 switches or multilayer
switches.
4. Bridge: A network bridge connects multiple network segments at the data link layer (Layer
2) of the OSI model. In Ethernet networks, the term bridge formally means a device that
behaves according to the IEEE 802.1D standard. A bridge and switch are very much alike; a
switch being a bridge with numerous ports. Switch or Layer 2 switch is often used
interchangeably with bridge. Bridges can analyze incoming data packets to determine if the
bridge is able to send the given packet to another segment of the network.
5. Router: A router is an electronic device that interconnects two or more computer networks,
and selectively interchanges packets of data between them. Each data packet contains address
information that a router can use to determine if the source and destination are on the same
network, or if the data packet must be transferred from one network to another. Where multiple
routers are used in a large collection of interconnected networks, the routers exchange
information about target system addresses, so that each router can build up a table showing the
preferred paths between any two systems on the interconnected networks.
5. Gate Way: In a communications network, a network node equipped for interfacing with
another network that uses different protocols.
• A gateway may contain devices such as protocol translators, impedance matching devices,
rate converters, fault isolators, or signal translators as necessary to provide system
interoperability. It also requires the establishment of mutually acceptable administrative
procedures between both networks.
• A protocol translation/mapping gateway interconnects networks with different network
protocol technologies by performing the required protocol conversions.
EXPERIMENT NO.-03
Aim: Running and using services/commands like ping, trace route, ns lookup, arp, telnet,
ftp, etc.
Description:
1. Scripting Language (Tcl - Tool Command Language and pronounced tickle)
2. System Programming Language (C/C++)
5) C++ defines the internal mechanism (a backend) of the Simulation objects also the
simulation kernel is implemented using C++.
6) OTcl sets up simulation by assembling and configuring the objects as well as scheduling
discrete events (i.e., a frontend). The Tcl scripting language is used to express the definition,
configuration and the control of the simulation.
7) The C++ and the OTcl are linked together using TclCL.
Simple Network Topology and Simulation Scenario
Algorithm/Syntax:
proc finish { } {
global ns nf tf
$ns flush-trace # clears trace file contents
close $tf
exec nam PA1.nam &
exit 0
}
set n0 [$ns node] # creates 3 nodes
set n2 [$ns node]
set n3 [$ns node]
$ns duplex-link $n0 $n2 200Mb 10ms DropTail # establishing links
$ns duplex-link $n2 $n3 1Mb 1000ms DropTail
$ns queue-limit $n0 $n2 10
AWK file: (Open a new editor using “vi command” and write awk file and save with “.awk”
extension) #immediately after BEGIN should open braces „{„
BEGIN{ c=0;}
{
if($1= ="d")
{ c++;
printf(
"%s\t
%s\n",
$5,$11)
;
}
}
END{ printf("The number of packets dropped =%d\n",c); }
Steps for execution:
Open vi editor and type program. Program name should have the extension “ .tcl ”
[root@localhost ~]# vi lab1.tcl
Save the program by pressing “ESC key” first, followed by “Shift and :” keys
simultaneously and type “wq” and press Enter key.
Open vi editor and type awk program. Program name should have the extension “.awk
”
Save the program by pressing “ESC key” first, followed by “Shift and :” keys
[root@localhost~]# ns lab1.tcl
System requirement
The following configuration is recommended by Cisco to successfully install and run Packet
Tracer 7.0 :
System Requirements
Summary
Packet Tracer is a cross-platform visual simulation tool designed by Cisco Systems that
allows users to create network topologies and imitate modern computer networks. The
software allows users to simulate the configuration of Cisco routers and switches using
a simulated command line interface.
Packet Tracer is a cross-platform visual simulation tool designed by Cisco Systems that
allows users to create network topologies and imitate modern computer networks. The
software allows users to simulate the configuration of Cisco routers and switches using
a simulated command line interface. Packet Tracer makes use of a drag and drop user
interface, allowing users to add and remove simulated network devices as they see fit.
The software is mainly focused towards Certified Cisco Network Associate Academy
students as an educational tool for helping them learn fundamental CCNA concepts.
2. Note: If you are using RHEL or Centos, you will likely need to install a more up-
to- date compiler than the default; search for how to enable 'software collections' or
4. FreeBSD and Linux (x86_64): clang/LLVM version 3.9 and above (older versions
Summary
Ns3
ns-3 has been developed to provide an open, extensible network simulation platform, for
networking research and education. In brief, ns-3 provides models of how packet data
networks work and perform, and provides a simulation engine for users to conduct
simulation experiments. Some of the reasons to use ns-3 include to perform studies that are
more difficult or not possible to perform with real systems, to study system behavior in a
highly controlled, reproducible environment, and to learn about how networks work.
Ns2
It is not possible to run a simulation in ns-2 purely from C++ (i.e., as a main() program
without any OTcl). Moreover, some components of ns-2 are written in C++ and others in
OTcl. In ns-3, the simulator is written entirely in C++, with optional Python bindings.
Simulation scripts can therefore be written in C++ or in Python. New animators and
visualizers are available and under current development. Since ns-3 generates pcap packet
trace files, other utilities can be used to analyze traces as well.
WIRESHARK
1. Wireshark is a network packet analyzer. A network packet analyzer will try to capture
network packets and tries to display that packet data as detailed as possible.
2. You could think of a network packet analyzer as a measuring device used to examine
what’s going on inside a network cable, just like a voltmeter is used by an electrician
to examine what’s going on inside an electric cable (but at a higher level, of course).
3. Wireshark is perhaps one of the best open source packet analyzers available today.
System Requirements
The amount of resources Wireshark needs depends on your environment and on the size of the
capture file you are analyzing. The values below should be fine for small to medium-sized
capture files no more than a few hundred MB. Larger capture files will require more memory
and disk space.If Wireshark runs out of memory it will crash.
1. Microsoft Windows
2. Unix/Linux
OmNet++
System Requirements
Summary
Research tool- OverSim provides a convenient platform for simulating large-scale complex
overlay protocols and applications. Though it can be overwhelming at first, you will realize its
power when you develop a better understanding of the tool.
Introduction
Wireshark captures network packets in real time and display them in human-readable format.
It provides many advanced features including live capture and offline analysis, three-pane
packet browser, coloring rules for analysis.
Packet Sniffer
Packet sniffer is a basic tool for observing network packet exchanges in a computer. As the
name suggests, a packet sniffer captures (“sniffs”) packets being sent/received from/by your
computer; it will also typically store and/or display the contents of the various protocol fields
in these captured packets. A packet sniffer itself is passive. It observes messages being sent
and received by applications and protocols running on your computer, but never sends packets
itself.
STEPS FOR CAPTURING THE PACKETS
1. Start up the Wireshark program (select an interface and press start to capture packets).
2. After the browser has been displayed click stop button through the capture link in the
Wireshark capture window.
3. Now , the Wireshark capture window disappears and the main Wireshark window displays
all packets captured since the time we began packet capture
Color Coding: After implementing the steps 1, 2, 3 mentioned above we’ll see packets
highlighted in green, blue, and black. Wireshark uses colors to help identify the types of traffic
at a glance. By default, green is TCP traffic, dark blue is DNS traffic, light blue is UDP traffic,
and black identifies TCP packets with problems — for example, they could have been delivered
out-of-order.
Simulation of LAN topologies using CISCO Packet Tracer
Steps for creating a topology
1. Open your Network Topology. Once you've opened your Network Topology on Cisco
Packet Tracer, access your network and identify the components of your network, for
example; Servers, Routers, End Devices, etc.
2. Complete the cabling. Access the cables section and connect completely and correctly
the cables between the network in order to ensure connectivity between the devices in
the network using the connections table given.
3. Using the address table still, correctly and completely configure the IP addresses on all
end devices. This can be done by accessing the desktop platform on each device and
locating the IP configuration section. The reason for doing this is to enable the devices
be on the right network.
4. After configuring the addresses, you will have to test connectivity by opening a
command prompt window on the end devices and try pinging the address which the
network operates on. If it gives you a reply, it means your network was configured
correctly.
SERVER
INPUT: Insert a client request
1. Start the program
2. Include necessary package in java
3. To create a socket in server to client.
4. To display the current date and time to client
5. Stop the program
OUTPUT:
CLIENTSIDE:
C:\Program Files\Java\jdk1.5.0\bin>javac dateclient.java
Note: dateclient.java uses or overrides a deprecated API.
Note: Recompile with -deprecation for details. C:\Program
Files\Java\jdk1.5.0\bin>java dateclient
THE date in the server is:Sat Jul 19 13:01:16 GMT+05:30 2008
C:\Program Files\Java\jdk1.5.0\bin>
SERVERSIDE:
C:\Program Files\Java\jdk1.5.0\bin>javac dateserver.java
Note: dateserver.java uses or overrides a deprecated API. Note:
Recompile with -deprecation for details.
C:\Program Files\Java\jdk1.5.0\bin>java dateserver
THE CLIENT SYSTEM ADDRESS IS: com17/192.168.21.17
EXPERIMENT NO.-06
Description: There are two types of Internet Protocol (IP) traffic. They are
TCP or Transmission Control Protocol and UDP or User Datagram Protocol. TCP is
connection oriented – once a connection is established, data can be sent bidirectional. UDP is
a simpler, connectionless Internet protocol. Multiple messages are sent as packets in chunks
using UDP.
Algorithm/Syntax:
set ns [new Simulator] set nf [open
lab2.nam w] $ns namtrace-all $nf
}
set n0 [$ns node] set n1 [$ns node]
set n2 [$ns node] set n3 [$ns node]
$ns duplex-link $n0 $n2
10Mb 1ms DropTail $ns
duplex-link $n1 $n2
10Mb 1ms DropTail $ns
duplex-link $n2 $n3
10Mb 1ms DropTail
AWK file: (Open a new editor using “vi command” and write awk file and save with “.awk”
extension)
BEGIN{
udp=0;
tcp=0;
}
{
if($1= = “r” && $5 = = “cbr”)
udp++;
}
else if($1 = = “r” && $5 = = “tcp”)
{ tcp++;
}
}
END{
printf(“Number of packets sent by
TCP = %d\n”, tcp);
printf(“Number of packets sent by
UDP=%d\n”,udp);
}
Steps for execution:
Open vi editor and type program. Program name should have the extension “ .tcl ”
[root@localhost ~]# vi lab2.tcl
Save the program by pressing “ESC key” first, followed by “Shift and :” keys simultaneously
and type “wq” and press Enter key.
Open vi editor and type awk program. Program name should have the extension “.awk ”
[root@localhost ~]# vi lab2.awk
Save the program by pressing “ESC key” first, followed by “Shift and :” keys
simultaneously and type “wq” and press Enter key.
Run the simulation program :
[root@localhost~]# ns lab2.tcl
o Here “ns” indicates network simulator. We get the topology shown in the
snapshot.
o Now press the play button in the simulation window and the simulation will
begins.
After simulation is completed run awk file to see the output ,
[root@localhost~]# awk –f lab2.awk lab2.tr
To see the trace file contents open the file as ,
[root@localhost~]# vi lab2.tr
Topology Output
EXPERIMENT NO.-07
AIM: To implement the program using RPC/RMI
Description: RPC (Remote Procedure Call) and RMI (Remote Method Invocation)
are two mechanisms that allow the user to invoke or call processes that will run on a
different computer from the one the user is using. The main difference between the two
is the approach or paradigm used. RMI uses an object-oriented paradigm where the user
needs to know the object and the method of the object he needs to invoke.
Pre-experiment Question:
Q.1W hat is the method that is used by the RMI client to connect to remote RMI servers?
Algorithm/Syntax:
1. Start the program and to include necessary packages
2. Using Add client to get the two values
3. Using Add server() to implement and Call the Add server impl
4.Usingpublic interface to call the program in remotely
5.Finally to call and compile all the sub program
6.To Execute Start RMI registry
7.Stop the program
INPUT :
Insert the client request for RPC.
OUTPUT :
EXPERIMENT NO.-08
Aim: Write a code simulating Ping and Trace-route commands
Description:
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 of1 causes the datagram to "timeout" as soon as it hits the first router in the
path; this router then responds with an ICMP Time Exceeded Message (TEM)
indicating that the datagram has expired.
3. Another three UDP messages are now sent, each with the TTL value set to 2, which
causes the second router to return ICMP TEMs. This process continues until the packets
actually reach the other destination.
4. Since these data grams are trying to access an invalid port at the destination host, ICMP
Port Unreachable Messages are returned, indicating an unreachable port; this event
signals the Trace route program that it is finished.
Pre-experiment Questions:
1. Dose ping can measure round trip time?
5.What utility is used to find the number of routers between a source and destination?
Algorithm:
Server
Step1: Start the program.
Step2: Import necessary packages.
Step3: Initialize the ping server with both sockets as null value.
Step4: Start the server socket.
Step5: At the client give the IP address of the server(by using ifconfig command in
command prompt).
Step6: The client program is then started by
starting socket.Step7: At the receiver end, the
client is pinged and traced. Step8: Stop the
program.
Client
Step1: Start the program.
Step2: Import necessary packages.
Step3: Initialize the ping client with both sockets as null value.
Step4: Start the socket.
Step5: Get the IP address of the server.
Step6: Ping the server.
Step7: At the receiver end, the server is pinged and traced.
Step8: Stop the program.
Sample code:
pingclient.java
/*… Get an input file handle from the socket and read
the input…*/DataInputStream dis=new
DataInputStream(s.getInputStream()); PrintStream out=new
PrintStream(s.getOutputStream()); while(c<4)
{
pingserver.java
/*… Get an input file handle from the socket and read
the input…*/DataInputStream dis=new
Sample Output:
Output:
Thus program for implementing ping and trace route command was executed
successfully.
EXPERIMENT NO.-09
Aim: Create a Socket for HTTP for webpage upload and download.
Objective:
To write a java program for creating socket for HTTP web page upload and
download.
Description:
HTTP
1. The Hypertext Transfer Protocol (HTTP) is a protocol used mainly to access data on
the www.
2. HTTP functions as a combination of FTP and SMTP.
3. SMTP messages are stored and forwarded, but HTTP messages are delivered
immediately.
4. The commands from the client to the server are embedded in a request message.
The contents of therequested file or other information are embedded in a response
message.
Pre-Experiment questions:
Algorithm:
Sample
Program:
Client.java
/* …create file
object…*/
importjava.io.File;
importjava.io.IOExc
eption;
/*…write image
file…*/
ImageIO.write(img,
"jpg", baos);
baos.flush();
Server.java
//…Create Server
Socket…//
ServerSocket
server=null; Socket
socket;
//…Register Service port to
4000…// 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);intlen =
dis.readInt();
System.out.println("Image Size: " + len/1024
+ "KB");byte[] data = new byte[len];
dis.readFully(data);
//…method is used to request for closing or terminating an object…//
dis.close();
in.close();
InputStreamian = new
ByteArrayInputStream(data);
BufferedImagebImage =
ImageIO.read(ian);
//…create a frame window entitled “server”…//
JFrame f = new
JFrame("Server"); ImageIcon
icon = new
ImageIcon(bImage);
Sample Output:
Output:
Thus program for creating sockets for HTTP web page upload and
download was implemented.
EXPERIMENT NO.-10
Aim: To perform case study for different routing algorithms to select the network path using
LINK STATE ROUTING b) FLOODING c) DISTANCE VECTOR.
Description:
Routing is the process of selecting best paths in a network. In the past, the term
routing was also used to mean forwarding network traffic among networks. However, this
latter function is muchbetter described as simply forwarding. Routing is performed for
many kinds of networks, including the telephone network (circuit switching), electronic
data networks (such as the Internet), and transportation networks. This article is concerned
primarily with routing in electronic data networks using packet switching technology. In
packet switching networks, routing directs packet forwarding (the transit of logically
addressed network packets from their source toward their ultimate destination) through
intermediate nodes. Intermediate nodes are typically network hardware devices such as
routers, bridges, gateways, firewalls, or switches. General-purpose computers can also
forward packets and perform routing, though they are not specialized hardware and may
suffer from limited performance. The routing process usually directs forwarding on the
basis of routing tables which maintain a record of the routes to various network
destinations. Thus, constructing routing tables, which are held in the router's memory, is
very important for efficient routing. Most routing algorithms use only one network path at
a time. Multipath routing techniques enable the use of multiple alternative paths. In case of
overlapping/equal routes, the following elements are considered in order to decide which
routes get installed into the routing table (sorted by priority):
1. Prefix-Length: where longer subnet masks are preferred (independent of whether it is
within a routing protocol or over different routing protocol)
2. Metric: where a lower metric/cost is preferred (only valid within one and the same routing
protocol)
3. Administrative distance: where a lower distance is preferred (only valid between
different routing protocols) Routing, in a narrower 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.
a) FLOODING
Flooding is a simple routing algorithm in which every incoming packet is sent
through every outgoing link except the one it arrived on Flooding is used in bridging and
in systems such as Usenet and peer-to-peer file sharing and as part of some routing
protocols, including OSPF, DVMRP, and those used in ad-hoc wireless networks. There
are generally two types of flooding available, Uncontrolled Flooding and Controlled
Flooding. Uncontrolled Flooding is the fatal law of flooding. All nodes have neighbours
and route packets indefinitely. More than two neighbours create a broadcast storm.
Controlled Flooding has its own two algorithms to make it reliable, SNCF (Sequence
Number Controlled Flooding) and RPF (Reverse Path Flooding). In SNCF, the node
attaches its own address and sequence number to the packet, since every node has a
memory of addresses and sequence numbers. If it receives a packet in memory, it drops it
immediately while in RPF, the node will only send the packet forward. If it is received
from the next node, it sends it back to the sender.
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 expire 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.
Advantages
packet can be delivered, it will (probably multiple times).
Department of Computer Science & Engineering
Since flooding naturally utilizes every path through the network, it will also use the
shortest path. Thisalgorithm 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 denial of service
attack, it can be harmful tothe 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 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. Have
each node keep track of every packet seen and only forward each packet once enforce a
network topology without loops.
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. 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 priority over the link
cost.
Count-to-infinity problem
The Bellman–Ford algorithm does not prevent routing loops from happening and suffers
from the countto 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
execnamth
ro.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 DropTailset 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 DV
$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
Sample Output:
EXPERIMENT NO.-11
AIM: . Implementation of Stop and Wait Protocol and Sliding Window Protocol
Description:
A sliding window protocol is a feature of packet-based data transmission protocols. Sliding
window protocols are used where reliable in-order delivery of packets is required, such as in
the Data Link Layer (OSI model) as well as in the Transmission Control Protocol (TCP).
Pre-Experiment Questions:
Q.1 What is Sliding Window?
Q.2 What is usage of Sequence Number in Reliable Transmission?
Algorithm/Syntax:
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
Input:
Data frame based on sender window
Output:
ENTER THE WINDOWS SIZE : 10
SENDER WINDOW IS EXPANDED TO STORE MESSAGE OR WINDOW
ENTER THE DATA TO BE SENT:
MESSAGE SEND BY THE SENDER:
WINDOW SIZE OF RECEIVER IS EXPANDED
ACKNOWLEDGEMENT FROM RECEIVER
ACK:5
MESSAGE RECEIVED BY RECEIVER IS :
WINDOW SIZE OF RECEIVER IS SHRINKED
EXPERIMENT NO.-12
Aim: Implement Subnetting to generate Range of IP Addresses.
Description: IP (Internet Protocol) addresses are used to identify hosts on the campus Internet,
a network that ties into the Internet, a global network. If the computer is attached to the network,
it needs an IP address to be recognized as part of the campus Internet. IP addresses are
constructed according to a set of specific rules so that hosts on any part of the Internet can
communicate with each other. An IP address consists of a 32-bit binary number, which is
typically presented as four decimal numbers (one for each 8-bit byte) separated by decimal
points. For example, 128.253.21.58.
HostAddress
The host address is the address given to the workstation, other computer, or device that is
connected to the LAN.
Subnetting
Subnetting is the process of dividing an IP network in to sub divisions called subnets.
Computers belonging to a sub network have a common group of most-significant bits in their
IP addresses. So, this would break the IP address in to two parts (logically), as the network
prefix and the rest field. Dividing an IP network in to sub divisions is subnetting. It divides an
IP address in to two parts as the network (or routing prefix) and the rest field (which is used to
identify a specific host). CIDR notation is used for writing a routing prefix. This notation uses
a slash (/) to separate the network starting address and the length of the network prefix (in bits).
For example, in IPv4, 192.60.128.0/22 indicates that 22 bits are allocated for the network prefix
and the remaining 10 bits are reserved for the host address. In addition, routing prefix can also
be represented using the subnet mask. 255.255.252.0
(11111111.11111111.11111100.00000000) is the subnet mask for 192.60.128.0/22. Separating
the network portion and the subnet portion of an IP address is done by performing a bitwise
AND operation between the IP address and the subnet mask. This would result in identifying
the network prefix and the host identifier.
Supernetting
Supernetting combines several sub networks, having a Classless Inter-Domain Routing (CIDR)
routing prefix. Supernetting is also called route aggregation or route summarization.
Supernetting is the practice of combining several IP networks with a common network prefix.
Supernetting was introduced to tackle the problem of increasing size in routing tables.
Supernetting also simplifies the routing process. For example, the subnetworks 192.60.2.0/24
and 192.60.3.0/24 can be merged with the supernetwork denoted by 192.60.2.0/23. In the
supernet, the first 23 bits are the network part of the address and the other 9 bits are used as the
host identifier. So, one address will represent several small networks and this would reduce the
number of entries that should be integrated in the routing table.
A Supernetted Network
Pre-Experiment Questions:
Q.1Input should be binary form or in the form of an IP address?
Q.2 IP-v 4 or IP-V-6 version? Does it affects the subnetting process??
Pseudo-code: Subnetting process itself described above
Input:
In order to define the range of IP addresses we need the following:
In subnetting:
The first address of the subnet + subnet mask
In supernetting:
The first address of the supernet + supernet mask
Output: Subnets for a given network.
EXPERIMENT NO.-13
Aim: To implement socket programming date and time display from client to server using
TCP and UDPSockets.
Description:
Socket Programming
Client–server model
➢ The client–server model of computing is a distributed application structure that
partitions tasks or workloads between the providers of a resource or service, called
servers, and service requesters, called clients.
➢ Often clients and servers communicate over a computer network on separate
hardware, but both client and server may reside in the same system.
➢ A server host runs one or more server programs which share their resources with
clients. A client does not share any of its resources, but requests a server's content or
service function.
➢ Clients therefore initiate communication sessions with servers which await incoming
requests. Examples of computer applications that use the client–server model are
Email, network printing, and the World Wide Web.
Pre-Experiment Questions:
1. Define Socket.
2. What is Socket address?
3. What is port number?
4. Give the differences between connection oriented and connectionless service
5. What is UDP?
Algorithm:
Server:
Step1:Create a server socket and bind it to port.
Step 2:Listen for new connection and when a connection arrives, accept it.
Step 3:Send server’s date and time to
the client. Step 4:Read client’s IP
address sent by the client.Step 5:Display
the client details.
Step 6:Repeat steps 2-5 until the server is terminated.
Step 7:Close the server socket.
Client
Step1:Create a client socket and connect it to the server’s port number.
Step2:Retrieve its own IP address using built-in function.
Step3:Send its address to the server.
Step4:Display the date & time sent by
the server.Step5:Close the client socket
TCP Program:
dateserver.java
//import java packages
import java.net.*; import java.io.*; importjava.util.*;
Department of Computer Science & Engineering
dateclient.java
/* …Socket class is having a constructor through this Client program can request to
server to getconnection…*/
Socket soc;
DataInputSt
ream dis;
String
sdate;
PrintStream
ps;
/*… Get an input file handle from the socket and read the input…*/
Output:
UDP Program:
Server.java
/*…import java packages…*/
import java.net.*; import java.io.*; importjava.util.*;
Clientnew.java
Output:
Test cases:
1. Check for the successful connection establishment
2. Retrieve the time and date of the system
3. Change the port number in both server and client programs. Recompile
4. Run client and server on separate computers and try to retrieve the date
and time usingTCP and UDP.
Output:
Thus, the program for implementing to display date and time from client to server
using TCPSockets was executed successfully and output verified using various samples.
EXPERIMENT NO.-14
Aim:To Study of Network simulator and Simulation of Congestion Control Algorithms
using NS.
Description:
Ns overview
•Ns programming: A Quick start
•Case study I: A simple Wireless network
•Case study II: Create a new agent in Ns
•Ns Status
•Periodical release (ns-2.26, Feb 2003)
•Platform support
• FreeBSD, Linux, Solaris, Windows and Mac
Ns Functionalities
Routing, Transportation, Traffic sources, queuing disciplines, QoS
Wireless
Ad hoc routing, mobile IP, sensor-MAC Tracing, visualization and various
utilitiesNS(Network Simulators) Most of the commercial simulators are GUI driven, while
some network simulators are CLI driven. The network model / configuration describe the
state of the network (nodes, routers, switchesand links) and the events (data transmissions,
packet error etc.). The important outputs 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 variants" 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:
•ns (open source)
•OPNET (proprietary software)
• NetSim (proprietary software)
Uses of network simulators
Network simulators serve a variety of needs. Compared to the cost and time involved in setting up
an entire test bed containing multiple networked computers, routers and data links, network
simulators are relatively fast and inexpensive. They allow engineers, researchers to test scenarios
that might be particularly difficult or expensive to emulate using real hardware - for
instance,simulating a scenario with several nodes or experimenting with a new protocol in the
network. Network simulators are particularly useful in allowing researchers to test new networking
protocols or changes to existing protocols in a controlled and reproducible environment. A typical
network simulator encompasses a wide range of networking technologies and can help the users to
build complex networks from basic building blocks such as a variety of nodes and links. With the
help of simulators, one can design hierarchical networks using various types of nodes like
computers, hubs, bridges, routers, switches, links, mobile units etc. Various types of Wide Area
Network (WAN) technologies like TCP, ATM, IPetc. and Local Area Network (LAN) technologies
like Ethernet, token rings etc., can all be simulated with a typical simulator and the user can test,
analyse 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 andpatterns 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 thetotal 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.
EXPERIMENT NO: -15
Aim: Applications using TCP Sockets like a. Echo client and echo server b. Chat c. File
Transfer.
Description
Our aim is to send a file from the client machine to the server machine using TCP
Communication.
Algorithm
Server
Client
Sample
code:
Se.java
{/*… Register service on port 15123…*/
ServerSocketserverSocket = new ServerSocket(15123);
Cl.java
Sample Output:
Testcase:
Description:
1. The DNS client program sends a request to a DNS server to map the e-mail
address to thecorresponding IP address.
2. When the Internet was small, mapping was done by using a host file. The host
file had only twocolumns: 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).
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: Receive the IP address from the client to be resolved.
Step6: Get the domain name for the client.
Step7: Check the existence of the domain in the server.
Step8: If domain matches then send the corresponding address to the client.
Step9: 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
Sample Program:
Clientdns12.java
/*... datagram socket is the sending or receiving point for a packet delivery
service.
DatagramSocket client=new DatagramSocket();
Serverdns12.java
DatagramSocket server=new
DatagramSocket(1309);while(true)
{byte[] sendbyte=new byte[1024];
byte[] receivebyte=new byte[1024];
/*domain name...*/
{if(s.equals(ip[i]))
{sendbyte=name[i].getBytes();
DatagramPacket sender=new
DatagramPacket(sendbyte,sendbyte.length,addr,port); server.send(sender);
break;}
else if(s.equals(name[i])){
sendbyte=ip[i].getBytes();
DatagramPacket sender=new
DatagramPacket(sendbyte,sendbyte.length,addr,port); server.send(sender);
Sample Output:
Test cases:
1 Give the domain name as google.com
Output: