0% found this document useful (0 votes)
28 views41 pages

CN - Lab Manual - Experiments - July 2024

Cn lab manual

Uploaded by

kalulalu144
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views41 pages

CN - Lab Manual - Experiments - July 2024

Cn lab manual

Uploaded by

kalulalu144
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 41

Shivajirao S Jondhale College of Engineering,

Dombivli (E)
Department of Computer Engineering

EXPERIMENT NO - 1

AIM: Use of Crimping Tool for RJ45


THEORY:
Crimping an RJ45 Connector Correctly Proper Wiring for Ethernet
Cat5/Cat5e/Cat 6 Cables. Cables can transmit information along their length.
To actually get that information where it needs to go, you need to make the
right connections to an RJ45 connector.

Your cable run needs to terminate into a connector, and that connector needs a
jack to plug into. Registered Jack 45 (RJ45) is a standard type of physical
connector for network cables. RJ45 connectors are commonly seen with
Ethernet cables and networks.
Modern Ethernet cables feature a small plastic plug on each end of the cable.
That plug is inserted into RJ45 jacks of Ethernet devices. The term “plug”
refers to the cable or “male” end of the connection while the term “jack” refers
to the port or “female” end.
T568A or T568B Wiring Standard:

CN Lab/ V 1
Shivajirao S Jondhale College of Engineering,
Dombivli (E)
Department of Computer Engineering
T568A and T568B are the two colour codes used
for wiring eight-position modular plugs. Both are allowed under the
ANSI/TIA/EIA wiring standards. The only difference between the two color
codes is that the orange and green pairs are interchanged.

There is no transmission differences between T568A and T568B cabling


schemes. North America’s preference is for T568B. Both ends must use the
same standard. It makes no difference to the transmission characteristics of
data.

T568B wiring pattern is recognized as the preferred wiring pattern.


STEP 1:

Using a Crimping Tool, trim the end of the cable you're terminating, to
ensure that the ends of the conducting wires are even

STEP 2:
Being careful not to damage the inner conducting wires, strip off
approximately 1 inch of the cable jacket, using a modular crimping tool or a
UTP cable stripper.

CN Lab/ V 2
Shivajirao S Jondhale College of Engineering,
Dombivli (E)
Department of Computer Engineering

STEP 3:

Separate the 4 twisted wire pairs from each other, and then unwind each
pair, so that you end up with 8 individual wires. Flatten the wires out as much
as possible, since they'll need to be very straight for proper insertion into the
connector.

STEP 4:

Holding the cable with the wire ends facing away from you. Moving from
left to right, arrange the wires in a flat, side-by-side ribbon formation, placing
them in the following order: white/orange, solid orange, white/green, solid
blue, white/blue, solid green, white/brown, solid brown.

STEP 5:
Holding the RJ45 connector so that its pins are facing away from you and the
plug-clip side is facing down, carefully insert the flattened, arranged wires into
the connector, pushing through until the wire ends emerge from the pins. For
strength of connection, also push as much of the cable jacket as possible into
the connector.

CN Lab/ V 3
Shivajirao S Jondhale College of Engineering,
Dombivli (E)
Department of Computer Engineering

STEP 6:
Check to make sure that the wire ends coming out of the connector's pin
side are in the correct order; if not, remove them from the connector, rearrange
into proper formation, and re-insert. Remember, once the connector is crimped
onto the cable, it's permanent. If you realize that a mistake has been made in
wire order after termination, you'll have to cut the connector off and start all
over again!

STEP 7:
Insert the prepared connector/cable assembly into the RJ45 slot in your
crimping tool. Firmly squeeze the crimper's handles together until you can't go
any further. Release the handles and repeat this step to ensure a proper crimp.

CN Lab/ V 4
Shivajirao S Jondhale College of Engineering,
Dombivli (E)
Department of Computer Engineering

STEP 8:
If your crimper doesn't automatically trim the wire ends upon termination,
carefully cut wire ends to make them as flush with the connector's surface as
possible. The closer the wire ends are trimmed, the better your final plug-in
connection will be.

STEP 9:
After the first termination is complete, repeat process on the opposite end of
your cable.

CONCLUSION : Thus, we have studied the use of crimping tool for RJ-45.

CN Lab/ V 5
Shivajirao S Jondhale College of Engineering,
Dombivli (E)
Department of Computer Engineering

CN Lab/ V 6
Shivajirao S Jondhale College of Engineering,
Dombivli (E)
Department of Computer Engineering

EXPERIMENT NO - 2

AIM: Use basic networking commands in Linux(ping, tracert, nslookup,


netstat, ARP,RARP, ip, ifconfig, dig, route )

THEORY:
1.ifconfig
ifconfig(interface configuration) command is used to configure the
kernel-resident network interfaces. It is used at the boot time to set up the
interfaces as necessary. After that, it is usually used when needed during
debugging or when you need system tuning. Also, this command is used to
assign the IP address and netmask to an interface or to enable or disable a
given interface.

2. NSLOOKUP

CN Lab/ V 7
Shivajirao S Jondhale College of Engineering,
Dombivli (E)
Department of Computer Engineering
Nslookup (stands for “Name Server Lookup”) is a
useful command for getting information from DNS server. It is a network
administration tool for querying the Domain Name System (DNS) to obtain
domain name or IP address mapping or any other specific DNS record. It is
also used to troubleshoot DNS related problems.

3.Ping

PING (Packet Internet Groper) command is used to check the network


connectivity between host and server/host. This command takes as input the IP
address or the URL and sends a data packet to the specified address with the
message “PING” and get a response from the server/host this time is recorded
which is called latency. Fast ping low latency means faster connection. Ping
uses ICMP(Internet Control Message Protocol) to send an ICMP echo
message to the specified host if that host is available then it sends ICMP reply
message. Ping is generally measured in millisecond every modern operating
system has this ping pre-installed.

4.TRACEROUTE
traceroute command in Linux prints the route that a packet takes to reach the
host. This command is useful when you want to know about the route and
about all the hops that a packet takes. Below image depicts how traceroute

CN Lab/ V 8
Shivajirao S Jondhale College of Engineering,
Dombivli (E)
Department of Computer Engineering
command is used to reach the Google(172.217.26.206)
host from the local machine and it also prints detail about all the hops that it
visits in between.

5.Netstat
Netstat command displays various network related information such as
network connections, routing tables, interface statistics, masquerade
connections, multicast memberships etc.,

CN Lab/ V 9
Shivajirao S Jondhale College of Engineering,
Dombivli (E)
Department of Computer Engineering

6.ARP

arp command manipulates the System’s ARP cache. It also allows a


complete dump of the ARP cache. ARP stands for Address Resolution
Protocol. The primary function of this protocol is to resolve the IP address of a
system to its mac address, and hence it works between level 2(Data link layer)
and level 3(Network layer).

7.IP

ip command in Linux is present in the net-tools which is used for performing


several network administration tasks. IP stands for Internet Protocol. This
command is used to show or manipulate routing, devices, and tunnels. It is
similar to ifconfig command but it is much more powerful with more functions
and facilities attached to it. ifconfig is one of the deprecated commands in the
net-tools of Linux that has not been maintained for many years. ip command is
used to perform several tasks like assigning an address to a network interface
or configuring network interface parameters.
It can perform several other tasks like configuring and modifying the default
and static routing, setting up tunnel over IP, listing IP addresses and property
information, modifying the status of the interface, assigning, deleting and

CN Lab/ V 10
Shivajirao S Jondhale College of Engineering,
Dombivli (E)
Department of Computer Engineering
setting up IP addresses and routes.

8.Dig
dig command stands for Domain Information Groper. It is used for retrieving
information about DNS name servers. It is basically used by network
administrators. It is used for verifying and troubleshooting DNS problems and
to perform DNS lookups. Dig command replaces older tools such as nslookup
and the host.

CONCLUSION: Hence, in this experiment, we have successfully studied


some important networking command and also implemented them in Linux

CN Lab/ V 11
Shivajirao S Jondhale College of Engineering,
Dombivli (E)
Department of Computer Engineering

EXPERIMENT NO - 3

AIM: Build a simple network topology and configure it for static routing
protocol using packet tracer. Setup a network and configure IP addressing,
subnetting, masking.

THEORY:
Cisco Packet Tracer is a cross-platform visual simulation tool designed by
CiscoSystems 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.

Steps:
1. Pick a total of 4 pcs in the packet tracer application.
2.We need 2 routers.
3. We need a single router.

Connect the devices as shown below:

3. Give the appropriate IP addresses to the pcs accordingly. 5.Test the


network with the help of packets.

CN Lab/ V 12
Shivajirao S Jondhale College of Engineering,
Dombivli (E)
Department of Computer Engineering

CONCLUSION: Hence we have successfully created simple network using


CISCO PACKET TRACER.

CN Lab/ V 13
Shivajirao S Jondhale College of Engineering,
Dombivli (E)
Department of Computer Engineering

Experiment No - 04
AIM:
To study and implement CRC

THEORY:
Cyclic Redundancy Check
• This is a type of polynomial code in which a bit string is represented in
the form of polynomials with coefficients 0 and 1 only.
• Polynomial arithmetic uses a modulo-2 arithmetic i.e. addition and
subtraction are identical to EX-OR .
• For CRC code, sender and receiver should agree upon an operator
polynomial Q(x).Both high and low order bits of generator must be 1.
• To compute CRC for some frame with m-bits corresponding to the
polynomial M(x), the frame must be longer than generator.
• The idea is to append a CRC to the end of frame in such way that the
frame is divisible by Q(x).
• If there is remainder, there has been a transmission error.
• A CRC will be valid if and only if,
• It should have only one bit less than divisor.
• Appending the CRC to end of data unit should result in bit sequence
which is exactly divisible by divisor CRC generation..

STEP 01: Append string of n 0’s to the data unit where n is1 less than the
number of bits in the predefine divisor.
STEP 02: Divide the newly generated data unit in step 01 by divisor. This is a
binary division.
STEP 03: The remainder obtained after division in step 02 is n-bit CRC.
STEP 04: This CRC will replace the n 0’s appended to data unit n step 01, to
get the code word to be transmitted.

CN Lab/ V 14
Shivajirao S Jondhale College of Engineering,
Dombivli (E)
Department of Computer Engineering

CRC Checker:
• Code word received at receiver consists of data and CRC.
• The receiver treat it as one unit and divide it by the same(n+1) bit
divisor which was used at transmitter.
• The remainder of the division is checked.
• If the remainder is zero then the received code word is error free and
hence should be accepted.
• But a non-zero remainder indicates presence of errors; hence
corresponding code word should be rejected.
For Example:

CN Lab/ V 15
Shivajirao S Jondhale College of Engineering,
Dombivli (E)
Department of Computer Engineering

Code :

Diagram:
Cyclic Redundancy Check
● Sender’s side

● Receiver’s Side

CN Lab/ V 16
Shivajirao S Jondhale College of Engineering,
Dombivli (E)
Department of Computer Engineering
Conclusion: In this way we have successfully
implemented CRC

EXPERIMENT NO - 05

AIM: Java program for Socket Programming

THEORY:
Java Socket Programming
• Java Socket programming is used for communication between the
applications running on different JRE.
• Java Socket programming can be connection-oriented
orconnection-less.
• Socket and Server Socket classes are used for connection-oriented
socket programming and Datagram Socket and Datagram Packet
classes are used for connection-less socket programming.

The client in socket programming must know two information:


a. IP Address of Server,and
b. Port number.
Here, we are going to make one-way client and server communication. In this
application, client sends a message to the server, server reads the message and
prints it. Here, two classes are being used: Socket and Server Socket.
The Socket class is used to communicate client and server. Through this class,
we can read and write message. The Server Socket class is used at server-side.
The accept() method of Server Socket class blocks the console until the client
is connected. After the successful connection of client, it returns the instance of
Socket at server-side.

#Socket class
A socket is simply an endpoint for communications between the machines. The
Socket class can be used to create a socket.

#ServerSocket class
The Server Socket class can be used to create a server socket. This object is
used to establish communication with the clients.

CN Lab/ V 17
Shivajirao S Jondhale College of Engineering,
Dombivli (E)
Department of Computer Engineering

Creating Server:
To create the server application, we need to create the instance of Server
Socket class. Here, we are using 6666 port number for the communication

between the client and server. You may also choose any other port number. The
accept() method waits for the client. If clients connects with the given port

number, it returns an instance of Socket.


ServerSocket ss=new ServerSocket(6666);
Socket s=ss.accept();//establishes connection and waits for the client

Creating Client:
To create the client application, we need to create the instance of Socket class.
Here, we need to pass the IP address or hostname of the Server and a port
number. Here, we are using "localhost" because our server is running on same
system.
Socket s=new Socket("localhost",6666);
Code:

MyServer.java file
import java.io.*; import java.net.*; public class MyServer
public static void main(String[] args){ try
{
ServerSocket ss=new ServerSocket(6666); Socket s=ss.accept();//establishes
connection
DataInputStream dis=new DataInputStream(s.getInputStream());
Stringstr=(String)dis.readUTF();
System.out.println("message= "+str); ss.close();
}
catch(Exception e){System.out.println(e);}

CN Lab/ V 18
Shivajirao S Jondhale College of Engineering,
Dombivli (E)
Department of Computer Engineering
}
}

MyClient.java file
import java.io.*; import java.net.*; public class MyClient
{
public static void main(String[] args)
{
try
{
Socket s=new Socket("localhost",6666);
DataOutputStreamdout=new DataOutputStream(s.getOutputStream());
dout.writeUTF("Hello Server");
dout.flush();
dout.close();
s.close();
}catch(Exception e){System.out.println(e);}
}
}

Output:
To execute this program open two command prompts and execute each
program at each command prompt as displayed in the below figures.
First run Myserver.java file in terminal/cmd,

CN Lab/ V 19
Shivajirao S Jondhale College of Engineering,
Dombivli (E)
Department of Computer Engineering

Running MyServer.java

Then in new terminal/cmd run MyClient.java file,

Running MyClient.java

As soon as you run MyClient program a message is sent to server and


displayed in MyServer Terminal/CMD as shown below,

Message displayed in MyServer after running MyClient

CONCLUSION: So, in this experiment we have successfully understood the


concept of Socket Programming and implemented it using Java Programming.

CN Lab/ V 20
Shivajirao S Jondhale College of Engineering,
Dombivli (E)
Department of Computer Engineering

Experiment No - 06
AIM:
Study and implement Leaky bucket algorithm.

THEORY:
The congesting control algorithms are basically divided into two groups: open
loop and closed loop. Open loop solutions attempt to solve the problem by
good design, in essence, to make sure it does not occur in the first place. Once
the system is up and running, midcourse corrections are not made. Open loop
algorithms are further divided into ones that act at source versus ones that act at
the destination.

In contrast, closed loop solutions are based on the concept of a feedback loop if
there is any congestion. Closed loop algorithms are also divided into two sub
categories: explicit feedback and implicit feedback. In explicit feedback
algorithms, packets are sent back from the point of congestion to warn the
source. In implicit algorithm, the source deduces the existence of congestion by
making local observation, such as the time needed for acknowledgment to
come back.

The presence of congestion means that the load is (temporarily) greater than
the resources (in part of the system) can handle. For subnets that use virtual
circuits internally, these methods can be used at the network layer.

Another open loop method to help manage congestion is forcing the packet to
be transmitted at a more predictable rate. This approach to congestion
management is widely used in ATM networks and is called traffic shaping.

The other method is the leaky bucket algorithm. Each host is connected to the
network by an interface containing a leaky bucket, that is, a finite internal
queue. If a packet arrives at the queue when it is full, the packet is discarded. In
other words, if one or more process are already queued, the new packet is
unceremoniously discarded. This arrangement can be built into the hardware

CN Lab/ V 21
Shivajirao S Jondhale College of Engineering,
Dombivli (E)
Department of Computer Engineering

interface or simulate d by the host operating system. In fact it is nothing other


than a single server queuing system with constant service time.

The host is allowed to put one packet per clock tick onto the network. This
mechanism turns an uneven flow of packet from the user process inside the
host into an even flow of packet onto the network, smoothing out bursts and
greatly reducing the chances of congestion.

Algorithm:
• Start
• Set the bucket size or the buffer size.
• Set the output rate.
• Transmit the packets such that there is no overflow.
• Repeat the process of transmission until all packets are transmitted.
(Reject packets where its size is greater than the bucket size)
• Stop

Code:

Conclusion:
In this way we have implemented Leaky bucket algorithm successfully.

CN Lab/ V 22
Shivajirao S Jondhale College of Engineering,
Dombivli (E)
Department of Computer Engineering

EXPERIMENT NO - 7

AIM: Use Wireshark to understand the operation of TCP/IPlayers:

THEORY:

Wireshark, a network analysis tool formerly known as Ethereal, captures


packets in real time and display them in human-readable format. Wireshark
includes filters, color coding, and other features that let you dig deep into
network traffic and inspect individual packets.
Capturing Packets

After downloading and installing Wireshark, you can launch it and


double-click the name of a network interface under Capture to start capturing
packets on that interface. For example, if you want to capture traffic on your
wireless network, click your wireless interface. You can configure advanced
features by clicking Capture > Options, but this isn’t necessary for now.

As soon as you click the interface’s name, you’ll see the packets start to appear
in real time. Wireshark captures each packet sent to or from your system.
If you have promiscuous mode enabled—it’s enabled by default—you’ll also
see all the other packets on the network instead of only packets addressed to
your network adapter. To check if promiscuous mode is enabled, click Capture
> Options and verify the “Enable promiscuous mode on all interfaces”
checkbox is activated at the bottom of this window.

CN Lab/ V 23
Shivajirao S Jondhale College of Engineering,
Dombivli (E)
Department of Computer Engineering

Click the red “Stop” button near the top left corner of the window when you
want to stop capturing traffic.

Color Coding
You’ll probably see packets highlighted in a variety of different colors.
Wireshark uses colors to help you identify the types of traffic at a glance. By
default, light purple is TCP traffic, light blue is UDP traffic, and black
identifies packets with errors—for example, they could have been delivered out
of order.
To view exactly what the color codes mean, click View > Coloring Rules. You
can also customize and modify the coloring rules from here, if you like.

CN Lab/ V 24
Shivajirao S Jondhale College of Engineering,
Dombivli (E)
Department of Computer Engineering

Sample Captures

If there’s nothing interesting on your own network to inspect, Wireshark’s wiki


has you covered. The wiki contains a page of sample capture files that you can
load and inspect. Click File > Open in Wireshark and browse for your
downloaded file to open one.

You can also save your own captures in Wireshark and open them later. Click
File > Save to save your captured packets.

Filtering Packets
If you’re trying to inspect something specific, such as the traffic a program
sends when phoning home, it helps to close down all other applications using
the network so you can narrow down the traffic. Still, you’ll likely have a large
amount of packets to sift through. That’s where Wireshark’s filters come in.
The most basic way to apply a filter is by typing it into the filter box at the top
of the window and clicking Apply (or pressing Enter). For example, type “dns”

CN Lab/ V 25
Shivajirao S Jondhale College of Engineering,
Dombivli (E)
Department of Computer Engineering
and you’ll see only DNS packets. When you start typing,
Wireshark will help you autocomplete your filter.

You can also click Analyze > Display Filters to choose a filter from among the
default filters included in Wireshark. From here, you can add your own custom
filters and save them to easily access them in the future.

For more information on Wireshark’s display filtering language, read


the Building display filter expressions page in the official Wireshark
documentation.

Another interesting thing you can do is right-click a packet and select Follow >
TCP Stream.

CN Lab/ V 26
Shivajirao S Jondhale College of Engineering,
Dombivli (E)
Department of Computer Engineering
You’ll see the full TCP conversation between the client and the
server. You can also click other protocols in the Follow menu to see the full
conversations for other protocols, if applicable.

Close the window and you’ll find a filter has been applied automatically.
Wireshark is showing you the packets that make up the conversation.

CN Lab/ V 27
Shivajirao S Jondhale College of Engineering,
Dombivli (E)
Department of Computer Engineering

Inspecting Packets

Click a packet to select it and you can dig down to view its details.

You can also create filters from here — just right-click one of the details and
use the Apply as Filter submenu to create a filter based on it.

CN Lab/ V 28
Shivajirao S Jondhale College of Engineering,
Dombivli (E)
Department of Computer Engineering

Wireshark is an extremely powerful tool, and this tutorial is just scratching the
surface of what you can do with it. Professionals use it to debug network
protocol implementations, examine security problems and inspect network
protocol internals.

CONCLUSION: Thus, we have studied the working of Wire Shark.

EXPERIMENT NO - 8

AIM: Perform network discovery using discovery tools (eg. Nmap, mrtg)

THEORY:
Nmap (Network Mapper) is a security scanner originally written by Gordon
Lyon (also knownby his pseudonym Fyodor Vaskovich) used to discover hosts
and services on a computer network, thus creating a "map" of the network. To
accomplish its goal, Nmap sends specially crafted packets to the target host and
then analyzes the responses. Unlike many simple port scanners that just send
packets at some predefined constant rate, Nmap accounts for the network
conditions (latency fluctuations, network congestion, the target interference
with the scan) during the run. Also, owing to the large and active user
community providing feedback and contributing to its features, Nmap has been
able to extend its discovery capabilities beyond simply figuring out whether a
host is up or down and which ports are open and closed; it can determine the

CN Lab/ V 29
Shivajirao S Jondhale College of Engineering,
Dombivli (E)
Department of Computer Engineering
operating system of the target, names and versions of the
listening services, estimated uptime, type of device, and presence of a firewall.

Nmap features include:


● Host Discovery – Identifying hosts on a network. For example, listing
the hosts which respond to pings or have a particular port open.
● Port Scanning – Enumerating the open ports on one or more target
hosts.
● Version Detection – Interrogating listening network services listening
on remote devices to determine the application name and version
number.
● OS Detection – Remotely determining the operating system and some
hardware characteristics of network devices.

Basic commands working in Nmap:


● For target specifications: nmap<target‘s URL or IP with spaces between
them>
● For OS detection: nmap -O <target-host's URL or IP>
● For version detection: nmap -sV<target-host's URL or IP>

SYN scan is the default and most popular scan option for good reasons. It can
be performed quickly, scanning thousands of ports per second on a fast
network not hampered by restrictive firewalls. It is also relatively unobtrusive
and stealthy since it never completes TCP connections

Algorithm\Implementation Steps\Installation Steps:

1.Download Nmap from www.nmap.org and install the Nmap Software with
WinPcapDriver utility.
1. Execute the Nmap-Zenmap GUI tool from Program Menu or
Desktop Icon
2. Type the Target Machine IP Address(ie.GuestOS or any website
Address)
3.Perform the profiles shown in the utility.

CN Lab/ V 30
Shivajirao S Jondhale College of Engineering,
Dombivli (E)
Department of Computer Engineering

CN Lab/ V 31
Shivajirao S Jondhale College of Engineering,
Dombivli (E)
Department of Computer Engineering

CONCLUSION: Thus, we have studied different options to scan ports in


Nmap

CN Lab/ V 32
Shivajirao S Jondhale College of Engineering,
Dombivli (E)
Department of Computer Engineering

Experiment No. : - 9

AIM :- To install and configure NS2 in Linux environment.

THEORY:

NS(Network Simulator)
NS (version 2) is an object-oriented, discrete event driven network
simulator developed at UC Berkely written in C++ and OTcl. NS is primarily
useful for simulating local and wide area networks. NS is an event driven
network simulator developed at UC Berkeley that simulates variety of IP
networks. It implements network protocols such as TCP and UPD, traffic
source behavior such as FTP, Telnet, Web, CBR and VBR, router queue
management mechanism such as Drop Tail, RED and CBQ, routing algorithms
such as Dijkstra, and more. NS also implements multicasting and some of the
MAC layer protocols for LAN simulations.

Figure 1. Simplified User's View of NS


As shown in Figure 1, in a simplified user's view, NS is Object-oriented
Tcl (OTcl) script interpreter that has a simulation event scheduler and network
component object libraries, and network setup (plumbing) module libraries
(actually, plumbing modules are implemented as member functions of the base
simulator object). In other words, to use NS, you program in OTcl script
language. To setup and run a simulation network, a user should write an OTcl
script that initiates an event scheduler, sets up the network topology using the
network objects and the plumbing functions in the library, and tells traffic
sources when to start and stop transmitting packets through the event scheduler.

CN Lab/ V 33
Shivajirao S Jondhale College of Engineering,
Dombivli (E)
Department of Computer Engineering
The term "plumbing" is used for a network setup, because
setting up a network is plumbing possible data paths among network objects by
setting the "neighbor" pointer of an object to the address of an appropriate
object. When a user wants to make a new network object, he or she can easily
make an object either by writing a new object or by making a compound object
from the object library, and plumb the data path through the object. This may
sound like complicated job, but the plumbing OTcl modules actually make the
job very easy. As shown in Figure 1, when a simulation is finished, NS
produces one or more text-based output files that contain detailed simulation
data, if specified to do so in the input Tcl (or more specifically, OTcl) script.
The data can be used for simulation analysis (two simulation result analysis
examples are presented in later sections) or as an input to a graphical
simulation display tool called Network Animator (NAM) that is developed as a
part of VINT project. NAM has a nice graphical user interface similar to that of
a CD player (play, fast forward, rewind, pause and so on), and also has a
display speed controller. Furthermore, it can graphically present information
such as throughput and number of packet drops at each link, although the
graphical information cannot be used for accurate simulation analysis.
Another major component of NS beside network objects is the event
scheduler. An event in NS is a packet ID that is unique for a packet with
scheduled time and the pointer to an object that handles the event. In NS, an
event scheduler keeps track of simulation time and fires all the events in the
event queue scheduled for the current time by invoking appropriate network
components, which usually are the ones who issued the events, and let them do
the appropriate action associated with packet pointed by the event. Network
components communicate with one another passing packets, however this does
not consume actual simulation time. All the network components that need to
spend some simulation time handling a packet (i.e. need a delay) use the event
scheduler by issuing an event for the packet and waiting for the event to be
fired to itself before doing further action handling the packet.

CN Lab/ V 34
Shivajirao S Jondhale College of Engineering,
Dombivli (E)
Department of Computer Engineering

Figure 2. C++ and OTcl: The Duality


NS is written not only in OTcl but in C++ also. For efficiency reason,
NS separates the data path implementation from control path implementations.
In order to reduce packet and event processing time (not simulation time), the
event scheduler and the basic network component objects in the data path are
written and compiled using C++. These compiled objects are made available to
the OTcl interpreter through an OTcl linkage that creates a matching OTcl
object for each of the C++ objects and makes the control functions and the
configurable variables specified by the C++ object act as member functions
and member variables of the corresponding OTcl object. In this way, the
controls of the C++ objects are given to OTcl. It is also possible to add member
functions and variables to a C++ linked OTcl object. The objects in C++ that
do not need to be controlled in a simulation or internally used by another object
do not need to be linked to OTcl. Likewise, an object (not in the data path) can
be entirely implemented in OTcl. Figure 2 shows an object hierarchy example
in C++ and OTcl. One thing to note in the figure is that for C++ objects that
have an OTcl linkage forming a hierarchy, there is a matching OTcl object
hierarchy very similar to that of C++.

Figure 3. Architectural View of NS

CN Lab/ V 35
Shivajirao S Jondhale College of Engineering,
Dombivli (E)
Department of Computer Engineering
Figure 3 shows the general architecture of NS. In this
figure a general user (not an NS developer) can be thought of standing at the
left bottom corner, designing and running simulations in Tcl using the
simulator objects in the OTcl library. The event schedulers and most of the
network components are implemented in C++ and available to OTcl through an
OTcl linkage that is implemented using tclcl. The whole thing together makes
NS, which is a OO extended Tcl interpreter with network simulator libraries.

Installation and configuration of NS2 in LINUX environment

We assume that you have already installed fully functional Linux


desktop computer with Gnome. In our setup we are going to use ubuntu 9.10
(desktop edition). This is 32 bit environment

1. Download the stable release of ns2


● root@ubuntu:~# mkdir ns2
● root@ubuntu:~# cd ns2/
● root@ubuntu:~/ns2# wget
http://citylan.dl.sourceforge.net/project/nsnam/allinone/ns
-allinone-2.34/ns-allinone-2.34.tar.gz

2. Extract this Tar File


● root@ubuntu:~/ns2# tar -xzf
ns-allinone-2.34.tar.gz

Now you will have this directory ns-allinone-2.34.

3. Configuration and Installation of ns2


● root@ubuntu:~/ns2# cd ns-allinone-2.34
● root@ubuntu:~/ns2/ns-allinone-2.34# apt-get install autoconf
● root@ubuntu:~/ns2/ns-allinone-2.34# apt-get install libc6-dev g++ gcc
● root@ubuntu:~/ns2/ns-allinone-2.34# apt-get install build- essential

CN Lab/ V 36
Shivajirao S Jondhale College of Engineering,
Dombivli (E)
Department of Computer Engineering
● root@ubuntu:~/ns2/ns-allinone-2.34# apt-get
install libx11-dev
● root@ubuntu:~/ns2/ns-allinone-2.34# apt-get install x-dev
● root@ubuntu:~/ns2/ns-allinone-2.34# apt-get install xorg-dev

Need to add patch for OTCL


● For Ubuntu 9.10 (karmic), you may encounter this error in the linking
of otcl: So,
● root@ubuntu:~/ns2/ns-allinone-2.34# cd otcl-1.13
● root@ubuntu:~/ns2/ns-allinone-2.34# cp configure configure.orig
● Modify the following line
● --- configure.orig 2009-11-02 12:14:52.556167945 -0800
● +++ configure 2009-11-02 12:17:28.966706099 -0800
● @@ -6301,7 +6301,7 @@
● ;;
● Linux*)
● SHLIB_CFLAGS="-fpic"
● SHLIB_LD="ld -shared"
● + SHLIB_LD="gcc -shared"
● SHLIB_SUFFIX=".so"
● DL_LIBS="-ldl"
● SHLD_FLAGS=""
● root@ubuntu:~/ns2/ns-allinone-2.34# ./install

By executing this command all of the required ns2 software will be


installed except xgraph. For xgraph installation execute the following
command. By the way, I used gnuplot, gnuplot has more advanced features. So,

● root@ubuntu:~/ns2# apt-get install xgraph

● root@ubuntu:~/ns2/ns-allinone-2.34# apt-get install gnuplot

4. Export System Variables


Execute the following commands

CN Lab/ V 37
Shivajirao S Jondhale College of Engineering,
Dombivli (E)
Department of Computer Engineering
● root@ubuntu:~/ns2/ns-allinone-2.34# cp
/root/.bashrc /root/.bashrc.bk
● root@ubuntu:~/ns2/ns-allinone-2.34# vi /root/.bashrc
● export
PATH=$PATH:/root/ns2/ns-allinone-2.34/bin:/root/ns2/ns-alli
none-2.34/tcl8.4.18/unix:/root/ns2/ns-allinone-2.34/tk8.4.1
8/unix
● export
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/root/ns2/ns-allinone-2.34
/otcl-1.13:/root/ns2/ns-allinone-2.34/lib
● export
TCL_LIBRARY="/root/ns2/ns-allinone-2.34/tcl8.4.18/library"

5. NS2 Testing
Now, your ns2 system is ready for use, download a test script and test it.

● root@ubuntu:~/ns2# wget http://nile.wpi.edu/NS/Example/ns-simple.tcl

● root@ubuntu:~/ns2# ns ns-simple.tcl

NS-2-Demonstration

Conclusion: - Hence we studied NS (Version 2) Network Simulator


installation and configuration in Linux environment.

CN Lab/ V 38
Shivajirao S Jondhale College of Engineering,
Dombivli (E)
Department of Computer Engineering

Experiment No:-10
AIM :
To study & implement shortest path routing
THEORY:
One of the important function of network layer is to route the packet from
source to destination machine rowing algorithm is responsible for deciding the
output line over WHich packect is to be sent
Static routing algorithm is a type of algoritmwhere routing decision is not
based on the measurement or estimation of current traffic & topology .The
routes is decided in advances ,offline & it is downloaded to the routers .It is
also called as non-adaptive algorithm.
Shortest path routing is an example of static algorithm .A graph of subnet is
built in which each representation os router & link or connection line is
present.
To choose path between paor of routers,shortest path is found by measuring the
path length.The metric can be number of hops or geographical distance in
kilometers
Dijstra's Algorithm:
This algorithm is used for computing the shoertest path from root node to every
other node to every other node in the network.
The total number of nodes are divided into 2 groups namely P&T.In P we have
nodes for which shortest path in already found in T the remaining nodes are
placed.
At the time of storting ,P is intialized to the current node & T is intialized to
null .The algorithm then repeats these steps.
1)Shortest path describe node say P.Write P in the P set.
2)For this node P,add it's negiobours n to T set .The addition of these will have
to satisfy following conditions:
a)If the neighbouring node is not present in T,then add it adding with the cost
to reach it through P.
b)It n is already present in T & the path to n through P has lower cost ,then
removed earlier instances of n &add new instances connected with the cost to

CN Lab/ V 39
Shivajirao S Jondhale College of Engineering,
Dombivli (E)
Department of Computer Engineering
reach through P.
3)Pick neighbour n which has the smallest value in T & If it is not present in T
then add it to P.Use it annotation to dermine rater P to releassed A.
4)Stop WHen T is Empty.
The goal of this algorithm is to find out every possible way in which an outside
node can be reached by a node already present in P & choose the shortest of
these as path to desired node
Example
Q)show computations at node A using Dijjstra algorithm
Add Storting node A is P(permenent)group.Add neighbourd nodes B & D in
T(temporary) group along with their costs to reach them through A .
Pick up neighbour to T-group,continue till last node to obtain find table
Permanent (P) Temporary(T)
1) A B(A,1),D(A,2)
2)A,B(A,1) D(A,2),C(B,2)
3)A,B(A,1),D(A,2) E(D,4),C(B,2)
3)A,B(A,1),D(A,2),C(B,2) E(C,3),E(C,4)
cannot be include
4)A<B(A<1),D(A,2)C(B,2),E(1,3) F(E,6),F(E,7) cannot
be included
5)A,B(A,1),D(A,2),C(B,2),E(C,3),F(E,6) Empty (null)

The shoetest path to other nodes from A is

Code :

Conclusion:
Hence,we have studied & impemented shortest path routing using Dijkstra's

CN Lab/ V 40
Shivajirao S Jondhale College of Engineering,
Dombivli (E)
Department of Computer Engineering

Experiment No:-11
AIM :
To Study & implement Hamming code.
THEORY: This experiment you have to do.

CN Lab/ V 41

You might also like