0% found this document useful (0 votes)
27 views55 pages

saurabh cn 2

This document is a practical file for a Computer Network Lab course, detailing various networking commands and simulation tools. It includes an index of practical exercises covering topics such as IP commands, network simulation tools, and network topologies. The document serves as a guide for students in the Electronics & Communication Engineering program at Chaudhary Ranbir Singh State Institute of Engineering and Technology.
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)
27 views55 pages

saurabh cn 2

This document is a practical file for a Computer Network Lab course, detailing various networking commands and simulation tools. It includes an index of practical exercises covering topics such as IP commands, network simulation tools, and network topologies. The document serves as a guide for students in the Electronics & Communication Engineering program at Chaudhary Ranbir Singh State Institute of Engineering and Technology.
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/ 55

A

Practical File
On
Computer Network Lab
(LC-ECE322G)
Submitted
For
Bachelor of Technology
In
Electronics & Communication
Engineering
At

Chaudhary Ranbir Singh State Institute of Engineering and


Technology, SilaniKeso, Jhajjar (124103)

Submitted to: Submitted By:


Shri:- Sachin Dahaiya Saurabh Pandey
Assistant professor 211901429
ECE Department ECE 6th sem
.

INDEX
S. Practical Date Page Teacher sign.
no No.
1 Running and using
services/commands like ping,
trace route, NSLOOKUP,
ARP,
TELNET, FTP, etc.
2 Network simulation using tools
like Cisco Packet Tracer,
NetSim, OMNeT++, NS2,
NS3, etc.
3 Network Topology – Star, Bus,
Ring
4 Simulate the transmission of
ping messaged over a network
topology and find
the number of packets dropped
due to congestion.
5 Understanding IP Addressing
using the simulation tool.
6 Study of various application
protocols using the simulation
like FTP, HTTP
7 Understand IP forwarding
within a LAN and across a
router
8 Understand the working of
“Connection Establishment” in
TCP using Network simulation
using tools
9 Study how the Data Rate of a
Wireless LAN (IEEE 802.11b)
network varies as the distance
between the Access Point and
the wireless nodes is varied

10 Study the working and routing


table formation of Interior
routing protocols, i.e.
Routing Information Protocol
(RIP) and Open Shortest Path
First (OSPF)
11 To determine the optimum
persistence of a CSMA / CD
network
12 Implementation of distance
vector routing algorithm
13 Implementation of Link state
routing algorithm
14 Study of Network simulator
(NS) and simulation of
Congestion Control Algorithms
using NS
15 Encryption and decryption
PRACTICAL NO. 1

WINDOWS IP COMMANDS
ipconfig command:

This is one of the most useful IP commands on Windows. It displays tons of useful information about the current network
settings on the machine such as IPv4 and IPv6 address of all network interface cards (Ethernet adapters, WIFI, adapters, virtual
network adapters etc., MAC address, default gateway, subnet mask, DNS server, DHCP information etc.

If you want to find the local IP address assigned to your computer or the MAC address of your Ethernet Adapter (shown as
“Physical Address” in the command output as shown in the picture below), this is the quickest way to find this information.

Different options for this command are as follows:

1. ipconfig/?: Displays all available options.

2. ipconfig /all: This will display output as shown on the screenshot above but for ALL network connection adapters of
the computer (Wired Ethernet, WIFI, VMware adapters etc).
3. ipconfig /release: This will release the current IPv4 addresses which were assigned dynamically from a DHCP server.
If you specify also a connection name at the end, it will release only the IP of that connection adapter.

4. ipconfig /release6: Same as above but for the IPv6 address.


5. ipconfig /renew: This usually comes after the above command and is used to request a new IP address from a DHCP
server.

6. ipconfig /renew6: Same as above but for the IPv6 address.


7. ipconfig /flushdns: This deletes the local DNS resolver cache of the computer. This cache stores DNS entries of
frequently accessed internet resources so that the computer will not query an external DNS server every time you try to
access an internet resource (website etc.). This command is useful when troubleshooting DNS connection problems.

8. ipconfig /registerdns: Refreshes all DHCP addresses and also communicates again with the external DNS server to
make sure its reachable etc. Very useful when troubleshooting DNS and network connectivity problems of the local
computer.

# nslookup command

“nslookup” stands for “Name System Lookup” and is very useful in obtaining Domain Name
System (DNS) related information about a domain or about an IP address (reverse DNS lookup).

1. nslookup [domain name]: The most popular usage of this command is to find quickly the IP address of
a specific domain name (A-record) as shown below:

2. nslookup [IPAddress]: This will perform a reverse-DNS lookup and will try to match
the given IP address in the command with its corresponding domain name .
As shown on the screenshot above, the IP address 8.8.8.8 is mapped with the name “google- public-dns-
a.google.com”. You should note however that not all IP addresses are assigned to a domain name so a lot of times
you will not get any information from the command above.

There are several other interesting features of the nslookup command such as finding the authoritative DNS servers
of a domain, the SOAand MX records of a domain and much more.

ping command

Probably the first command that every computer user runs on the command line when having connectivity problems
is the “ping” command.

This will quickly show you if can send and receive packets (icmp packets to be exact) from your computer and hence shows
whether you have network connectivity or not.

Note also that “ping” is useful for testing connectivity for both the local computer from where you execute the command
and also for a remote computer or server which you try to reach.

1. ping /?: Displays all available options as shown below:

2. ping [IPAddress]: By default, it will send 4 ICMP packets to the stated IP address.
As you can see from the screenshot above, pinging the IP 8.8.8.8 results in sending 4 packets
and then receiving back 4 packets from that IP.

3. ping [hostname or domain] : When “pinging” a hostname or domain name, the command will resolve first
the name to IP address and then send the icmp packets to that IP.

4. ping [IP address] -t :This will send ping packets (icmp echo requests) continuously to the target IP.4
-ping -n 8 [IP address] :This will send 10 ping packets (icmp echo requests) to the target IP.

5. ping -l 1500 [IP address] : This will send ping packets (icmp echo requests) with size of 1500 bytes length
to the target IP.
6. ping -a [IP address] : The -a switch tells the computer to try to find the hostname assigned to the specific IP
address and then ping the IP.

Tracert command

“tracert” in Windows stands for “Trace Route”. In Linux, the same command is “traceroute”.

The command traces the path that a TCP/IP packet takes towards a destination target and shows some information (if
available) of the routing nodes within this path.

Just like the “ping” command, “tracert” sends also ICMP echo packets to the destination with varying Time-to- Live
(TTL) values.

1. tracert [domain or IP] : Traces the TCP/IP path to the specified destination target IP or domain.

As shown above,

Tracing the path to domain www.zomato.com shows all the intermediary routing nodes (with their hostname and
IP address) until the final target destination.

When troubleshooting connection problems in a large network, you can use tracert to see where the packets stop before
reaching the target and focus your efforts to find the problem on the node which does not route packets.
netstat command
Another important command is the Network Statistics (“netstat”) utility found in both Windows and Linux OS.

Here are some popular usages of this command:

1. netstat -ano : Displays all connections and listening ports (-a), addresses and ports in numerical form (-n) and
also the process ID of each connection (-o).

2. netstat -p tcp -f : The “-p tcp” switch will show only TCP connections and the “-f” switch will show the FQDN
name of each connection instead of just IP address.

route command

The “route” command is used to manipulate the local routing table of the computer. You can print the current routing
table, add new static routes, delete entries etc.

Personally, the way I use the “route” command is to add a permanent static route entry in a computer. For example,
there might be a specific network subnet which is not accessible via the default gateway of the computer. Instead, this
remote subnet might be accessible via a different gateway IP. By adding a static route in the computer’s routing table
you will be able to reach that remote subnet from a different gateway.

1. route PRINT : Displays the current routing table of the computer.


2. route ADD [Destination network] MASK [mask] [gatewayIP]: This adds a static route in the
table.

arp command

ARP stands for “Address Resolution Protocol” and is one of the core networking protocols that work in Layer 2 level
and facilitate communication in a LAN.

The job of ARP is to find the physical address (MAC address) of the target and map it with its corresponding Layer
3 IP address when communicating in a LAN. The ARP cache table stores mappings of IP addresses with their
corresponding MAC address.
1. arp -a : Displays all ARP cache mappings (IP to MAC address).

As you can see from above, the local computer has learned dynamically (type=dynamic) using the ARP protocol
two other local devices (192.168.242.229 and 192.168.242.255) and has stored their MAC address (Physical Address) in
the ARP table. 2. arp -d [IP address] : This will delete the arp entry for the specified IP address.
PRACTICAL 2
NETWORK SIMULATION USING TOOLS LIKE CISCO PACKET
TRACER, NETSIM, OMNEeT++, NS2,
NS3.
Theory:

Network Simulation is a technique by which one can easily create a virtual representation of the network. This
virtual representation can either be used for testing, learning, or research purposes. With the help of network
simulation tools, users can design, configure, and analyse different network scenarios without relying on
hardware or software. Apart from all this, these tools can help users understand the core concepts of networking,
practice for various certification exams such as CCNA, assist in testing new network topologies or protocols, or
one can conduct experiments on network performance and security.

Network Simulator

A network simulator is a software application that works the same as the real network with the help of various
mathematical models and algorithms. It can run either on a single computer or on a distributed system of multiple
computers. Using a network simulator, one can create various types of networks, such as LANs, WANs, wireless
networks, etc. It can also support a wide range of network devices, including routers, switches, firewalls, servers,
etc.

Network Simulation Tools

Many network simulation tools are available, each with different features, advantages, and limitations.
1 – Cisco Packet Tracer

The Cisco packet tracer is a network simulation tool developed by Cisco Systems in the late 90s. This tool’s
main purpose is to help students and experts learn and practice networking concepts and skills. It has a drag-
and-drop UI (User Interface) that is used by users to create and configure network devices and connections
easily. It also has a CLI (Command Line Interface) that supports various Cisco commands and protocols. One
can easily access the Cisco packet tracer, which is free to download.
2 – GNS3 (Graphical Network Simulator 3)

GNS3 is an open-source computer network simulator that was first released in 2008. With the help of GNS3,
one can create complex and realistic network topologies using real device images. For better functioning, it
supports various vendors and platforms, which include Cisco, Juniper, Arista, MikroTik, etc.

It can also integrate with VMs (Virtual Machines) or containers in order to run applications or services on the
simulated network. GNS3 also has a GUI that allows users to drag and drop devices easily. It also has a CLI that
supports various commands and protocols.

3 – EVE-NG (Emulated Virtual Environment – Next Generation)

EVE-NG is also a network automation tool that was first introduced in 2014. It can be used to create and run
virtual networks using multiple hypervisors. If we talk about the supported platforms, it supports a wide range,
including Cisco, Juniper, Fortinet, Palo Alto Networks, Linux, Windows, etc. EVE-NG can also support nested
virtualization and live migration of virtual machines.

4 – OMNeT++
It is an open-source network simulation tool introduced in the early 90s. It helps users create and simulate
network models with modular and component-based architecture. It uses C++ as the programming language.
Various network technologies are supported by OMNeT++ which include wired networks, wireless networks,
sensor networks, optical networks, etc.

It also has a GUI and several frameworks for specific domains, such as INET for Internet protocols, VEINS for
vehicular networks, etc. Apart from this, it assists in providing various network visualizations and animation
functions such as network topology view, network traffic view, network statistics view, etc.

5 – NS-3 (Network Simulator 3)

It is an open-source network simulation tool that was introduced in 2008. It is mainly used to create and
simulate network models using a C++ or Python programming language. It supports various network
technologies, some of which include wireless networks, mobile networks, internet protocols, etc. Apart from all
this, it also offers various network debugging and tracing functions.
6 – OPNET

It is a commercial network simulator that was developed by OPNET Technologies Inc., and in 2012, Riverbed
Technology acquired it. This tool offers a comprehensive solution for network modeling and simulation. If we
talk about the network technologies that OPNET supports, include Ethernet, ATM, MPLS, IP, TCP, UDP, etc., as
well as application-level protocols and services. Apart from this, OPNET has a powerful analysis tool in order
to evaluate performance and optimize.

7 – QualNet

It is also a network simulation tool introduced in 2000 by Scalable Network Technologies. With the help of
QualNet, one can easily create and simulate large-scale networks using GUI and CLI. Like many other network
simulator tools, it supports various network technologies such as wired networks, wireless networks, mobile
networks, satellite networks, etc. Apart from this, it can perform various optimization functions, which include
network planning, network configuration, etc.
8 – NetSim

NetSim is also a network simulator that specializes in wireless networks. It was first introduced by Telcos Pvt
Ltd. In 2003. When we talk about wireless technologies, these tools include Wi-Fi, WiMAX, LTE, Bluetooth,
ZigBee, etc. It also supports wired technologies such as Ethernet, IPv6/v6, TUV/UDP, etc. It also has a GUI and
analysis tool, also known as NetSim Analyzer, which is used for performance evaluation and optimization.

9 – Mininet

Mininet is one of the lightweight network simulators that was developed by Bob Lantz. It is mainly used to
create virtual networks using Linux containers. It supports SDN (software-defined networking) with OpenFlow
protocol. Further, with the help of Mininet, one can create scalable network topologies with minimal resources.
It also has a CLI and a Python API for easy network manipulation and experimentation.

10 – CORE (Common Open Research Emulator)

It is an open-source tool for building and running virtual networks on either one or more than one machine. It
can connect these networks to real networks and is highly customizable as per one’s requirements. One can use
it to test applications and protocols in realistic scenarios. CORE has a graphical user interface for designing
network topologies and Python modules for scripting and controlling the emulation.
PRACTICAL NO.3

NETWORK TOPOLOGIES
Definition: Topology defines the structure of the network of how all the components are interconnected to
each other.

Types of Network Topologies:

1. Bus Topology

o The bus topology is designed in such a way that all the stations are connected through a single cable
known as a backbone cable.

o When a node wants to send a message over the network, it puts a message over the network. All the
stations available in the network will receive the message whether it has been addressed or not.

o The bus topology is mainly used in 802.3 (ethernet) and 802.4 standard networks. o The most

common access method of the bus topologies is CSMA (Carrier Sense Multiple Access).

CSMA: It is a media access control used to control the data flow so that data integrity is maintained, i.e., the
packets do not get lost. There are two alternative ways of handling the problems that occur when two nodes
send the messages simultaneously.
o CSMA CD: CSMA CD (Collision detection) is an access method used to detect the collision.
Once
the collision is detected, the sender will stop transmitting the data. Therefore, it works on "recovery after
the collision".

o CSMA CA: CSMA CA (Collision Avoidance) is an access method used to avoid the collision
by
checking whether the transmission media is busy or not. If busy, then the sender waits until the media
becomes idle. This technique effectively reduces the possibility of the collision. It does not work on
"recovery after the collision".

Advantages of Bus Topology:

o Low-cost cable: In bus topology, nodes are directly connected to the cable without passing through a
hub. Therefore, the initial cost of installation is low.

o Familiar technology: Bus topology is a familiar technology as the installation and troubleshooting
techniques are well known, and hardware components are easily available.

o Limited failure: A failure in one node will not have any effect on other nodes.

o Moderate speed: Coaxial or twisted pair cables are mainly used in bus-based networks that support till
10 Mbps.

Disadvantages of Bus Topology:

o Extensive cabling: A bus topology is quite simpler, but still it requires a lot of cabling. o

Difficult troubleshooting: If this in the cable, then it would disrupt the communication for all the

nodes.

o Signal interference: It requires specialized test equipment to determine the cable faults. If any fault occur
wo nodes send the messages simultaneously, then the signals of both the nodes collide with each other.

2. Ring Topology
o Ring topology is like a bus topology, but with connected ends. o The node that receives the

message from the previous computer will retransmit to the next node. o The data flows in one

direction, i.e., it is unidirectional. o The data flows in a single loop continuously known as an

endless loop. o The most common access method of the ring topology is token passing. o

o Working of Token Passing:

o A token moves around the network, and it is passed from computer to computer until it reaches the
destination.

o The sender modifies the token by putting the address along with the data.

o The data is passed from one device to another device until the destination address matches. Once the
token received by the destination device, then it sends the acknowledgment to the sender.

Advantages of Ring Topology:

o Network Management: Faulty devices can be removed from the network without bringing the

network down. o Product availability: Many hardware and software tools for network operation and

monitoring are available.

o Cost: Twisted pair cabling is inexpensive and easily available. Therefore, the installation cost is very
low.

o Reliable: It is a more reliable network because the communication system is not dependent on the
single host computer.

Disadvantages of Ring Topology:


o Failure: The breakdown in one station leads to the failure of the overall network. o

Reconfiguration difficult: Adding new devices to the network would slow down the network.
o Delay: Communication delay is directly proportional to the number of nodes. Adding new devices
increases the communication delay.

3. Star Topology
o Star topology is an arrangement of the network in which every node is connected to the central hub,
switch or a central computer.

o The central computer is known as a server, and the peripheral devices attached to the server are known
as clients.

o Coaxial cable or RJ-45 cables are used to connect the computers. o Hubs or Switches are mainly

used as a connection devices in physical star topology.

Advantages of Star Topology:


o Network control: Complex network control features can be easily implemented in the star topology. Any
changes made in the star topology are automatically accommodated.

o Limited failure: As each station is connected to the central hub with its own cable, therefore failure
in one cable will not affect the entire network.

o Familiar technology: Star topology is a familiar technology as its tools are cost-effective.
o Easily expandable: It is easily expandable as new stations can be added to the open ports on the hub.
o Cost effective: Star topology networks are cost-effective as it uses inexpensive coaxial cable.

Disadvantages of Star Topology:


o A Central point of failure: If the central hub or switch goes down, then all the connected nodes will not be
able to communicate with each other.

o Cable: Sometimes cable routing becomes difficult when a significant amount of routing is required.
PRACTICAL NO. 4
Transmission of Ping message over a network topology consisting of 6
nodes and find the number of packets dropped due to congestion

BASICS

1. Ping Message:
A Ping message is typically an ICMP (Internet Control Message Protocol) Echo Request packet sent
from a source node to a destination node. It's used to test the reachability of a host on an IP network
and measure the round-trip time for packets to reach the destination and return to the source.

2. Packet Transmission:
The Ping message is transmitted from the source node to the destination node over the network. The
message traverses through intermediate nodes (routers or switches) along the path to reach its destination.

3. Congestion:
Congestion occurs when the network experiences high traffic load, causing queues to build up at
routers or switches. When the queues become full, packets may be dropped due to lack of buffer space,
resulting in packet loss.

4. Packet Drop Detection:

• During the transmission of Ping messages, the simulation monitors the flow of packets
through the network and tracks any packets that are dropped due to congestion.
• Congestion-induced packet drops can be detected by monitoring packet loss events at the
routers or switches along the path.

5. Analysis and Calculation:

• After the simulation, the number of packets dropped due to congestion is calculated based on the packet
loss events observed during the transmission.

Procedure:-

Step-1: Take all the equipment (a switch and six pc’s).


Step-2: Connect all the devices by wire (Here, I have taken Automatically choose connection type).

Step-3: configure the pc’s [and so on….]

1. Click the pc

2. Goto “desktop” mode and select “Ip config” mode

3. Set start Ip address. [same] “192.168.10.1” [and so on…..]

4.Set subnet mask “255.255.255.128” close the dialoguebar


[No need switch configure. Only need switch configure. when we connect
VLAN]
Step-4: Now check……[By sending Packet].
Step-5: Now Ping…..[pc1 to pc5]
1. Click pc1

2. Goto “desktop” mode and select “command prompt”

3. Write “ping Ip address (destination pc Ip address)” and press enter.

Here the destination is pc5 so we write the pc5 Ip address

If loss 0% then all ok.

OUTPUT:-
PRACTICAL NO. 5
Understanding IP addressing using the simulation tool

Understanding IP addressing using simulation tools can provide hands-on experience in configuring
and managing IP addresses within a simulated network environment. Here's a step-by-step guide on
how to use simulation tools to understand IP addressing:

Choose a Simulation Tool:


Select a network simulation tool that supports IP addressing configuration and simulation. Some popular
options include Cisco Packet Tracer, GNS3, ns-3, OMNeT++, and Mininet.

Create a new simulation project or open an existing one to start configuring the network.

Design the Network Topology:


Design a network topology that reflects your desired configuration. This may include routers, switches,
computers, servers, and other networking devices.

Determine the number of subnets and the IP addressing scheme you want to implement in your network.

Configure IP Addresses:
Assign IP addresses to each device in the network based on the chosen addressing scheme.

Ensure that each device has a unique IP address within its subnet to avoid conflict .

Verify Connectivity:
Test connectivity between devices in the network to ensure that IP addressing and routing
configurations are correctly implemented. Use tools such as Ping and traceroute to verify
reachability and troubleshoot connectivity issues.

Implement DHCP (Optional):


Configure Dynamic Host Configuration Protocol (DHCP) servers to automatically assign IP addresses to
client devices on the network.

Test DHCP functionality by connecting new devices to the network and verifying that they receive IP
addresses dynamically.

Monitor and Analyse Traffic:


Use simulation tools to monitor network traffic and analyse IP addressing-related statistics, such as IP
address utilization, subnet utilization, and DHCP lease information.

Identify any IP address conflicts, subnetting errors, or performance bottlenecks in the network.
Experiment and Learn:
Experiment with different IP addressing scenarios, subnet configurations, and network designs to gain a
deeper understanding of IP addressing concepts.

Explore advanced topics such as IPv6 addressing, IP routing protocols, and network security mechanisms
within the simulation environment.

Download and Install the Simulation Tool:


Start by downloading and installing the simulation tool of your choice on your computer. Follow the
installation instructions provided by the tool's website.

Create a Network Topology:


Use the simulation tool to create a network topology. You can add routers, switches, computers, servers,
and other networking devices to simulate a real-world network environment.

Assign IP Addresses:
Configure IP addresses for each device in the network. Remember, IP addresses consist of two parts: the
network portion and the host portion. Ensure that IP addresses are assigned correctly according to the
network's addressing scheme.

Test Connectivity:
Once IP addresses are assigned and subnet masks are configured, test connectivity between devices
within the network. Use ping or traceroute commands to verify that devices can communicate with
each other.

Troubleshoot Issues:
If you encounter any connectivity issues, use the simulation tool's troubleshooting features to
identify and resolve them. Check IP configurations, subnet masks, routing tables, and firewall
settings to pinpoint the problem.

Experiment and Learn:


Experiment with different network configurations, IP addressing schemes, and routing protocols
using the simulation tool. This hands-on approach will help you gain a deeper understanding of IP
addressing concepts and their practical applications.

PROGRAM:-
import IP address

def validate_ip(ip):

try:

ipaddress.ip_address(ip)
return True except ValueError:
return False

def validate_subnet(subnet):
try:
ipaddress.ip_network(subnet, strict=False)
return True except ValueError:

return False

def calculate_network_host(ip, subnet):

network = ipaddress.ip_network(subnet, strict=False)


host = ipaddress.ip_address(ip) return
network.network_address, host

def main():
ip = input("Enter IP address: ") subnet =
input("Enter subnet mask: ")

if not validate_ip(ip):
print("Invalid IP address") return

if not validate_subnet(subnet):
print("Invalid subnet mask") return

network_address, host_address = calculate_network_host(ip, subnet)


print("Network Address:", network_address) print("Host
Address:", host_address)

if name == " main ":

main()

This program consists of several functions:

Validate_ip: This function validates whether an input string represents a valid IP address.

Validate_subnet: This function validates whether an input string represents a valid subnet mask.

Calculate_network_host: This function calculates the network address and host address based on the
given IP address and subnet. mask.

OUTPUT: -
PRACTICAL NO. 6
STUDY OF VARIOUS APPLICATION PROTOCOLS USING THE
SIMULATION LIKE FTP, HTTP
Studying various application protocols like FTP (File Transfer Protocol) and HTTP (Hypertext
Transfer Protocol) using simulation tools can provide valuable insights into their operation, performance,
and behavior under different conditions. Simulations allow researchers, network engineers, and developers to
analyze protocol interactions, evaluate protocol design choices, and assess network performance without the need
for physical infrastructure. Here's how simulations can be used to study FTP and HTTP :

FTP (File Transfer Protocol):


Protocol Operation Simulation: Simulations can emulate the behavior of FTP clients and servers, allowing
researchers to observe how commands and responses are exchanged between them during file transfers.

Performance Analysis: By varying parameters such as file size, network latency, and bandwidth, simulations can
analyze the performance of FTP under different conditions. This includes measuring transfer rates, throughput,
and latency.

Protocol Extensions: Researchers can simulate scenarios to test the behavior of extended FTP features such as
FTPS (FTP over SSL/TLS) or SFTP (SSH File Transfer Protocol) and analyze their impact on performance and
security.

Error Handling and Recovery: Simulations can simulate network errors, packet loss, and connection failures to
evaluate FTP's error handling mechanisms and recovery procedures.

Security Analysis: FTP simulations can assess the security vulnerabilities of the protocol, such as plaintext
transmission of credentials, and explore the effectiveness of security enhancements like encryption and
authentication mechanisms.

HTTP (Hypertext Transfer Protocol):

Request-Response Simulation: HTTP simulations can replicate the request-response model of the protocol,
allowing researchers to study how clients and servers communicate to retrieve web resources.

Performance Evaluation: Simulations can analyze the performance of HTTP by modeling factors such as
server load, caching mechanisms, and network conditions to measure response times, throughput, and server
scalability.

Protocol Extensions: Researchers can simulate scenarios involving HTTP/2 or HTTP/3 (QUIC) to understand
their impact on performance, latency, and compatibility with existing infrastructure.

Content Delivery Networks (CDNs): Simulations can model the behavior of CDNs and analyze their
effectiveness in accelerating content delivery by caching resources closer to end-users.
Security Assessment: HTTP simulations can assess security vulnerabilities such as man-in-the-middle
attacks, cross-site scripting (XSS), and SQL injection, and evaluate the effectiveness of security measures like
HTTPS (HTTP over TLS/SSL).
ns-3 (Network Simulator 3):
A discrete-event network simulator that provides support for simulating various network protocols, including
FTP Simulation Tools: and HTTP.

OMNeT++:
An extensible, modular, component-based simulation framework for building network simulators capable of
modeling complex protocols and network architectures.

Wireshark:
While primarily a network protocol analyzer, Wireshark can also be used to capture and analyze network traffic
generated by FTP and HTTP simulations, providing insights into protocol behavior and performance.

Matplotlib and other data visualization tools:


These tools can be used to analyze and visualize simulation results, such as throughput, latency, and packet loss,
to gain insights into protocol performance and behavior.
PRACTICAL NO. 7
IP FORWARDING WITHIN A LAN AND ACROSS A ROUTER
IP FORWARDING WITHIN A LAN

IP forwarding within a LAN (Local Area Network) involves the process by which devices communicate with each
other using IP addresses within the same network segment. Here’s a detailed explanation:

LAN Setup:
In a typical LAN environment:

• Devices: Computers, smartphones, printers, servers, and other network-enabled devices are connected
within a confined geographic area (like an office building, campus, or home).

• Network Infrastructure: Usually includes Ethernet switches, hubs (less common nowadays), and
sometimes wireless access points (for wireless LANs).

• IP Addressing: Devices within the LAN are assigned IP addresses from the same subnet. For example,
devices might have IP addresses like 192.168.1.2, 192.168.1.3, 192.168.1.4, etc., with a common subnet mask like
255.255.255.0.

IP Forwarding Process Within a LAN:

1. Sending Data:
• When a device (let's call it Device A) wants to communicate with another device (Device B) within the same
LAN, it creates an IP packet containing:

• Source IP address (e.g., 192.168.1.2)

• Destination IP address (e.g., 192.168.1.3)

• Data payload (e.g., the actual message or data to be sent)

2. Checking Destination:
• Device A checks if the destination IP address (192.168.1.3) belongs to the same subnet (determined by its
own IP address and subnet mask).

3. ARP Resolution (Address Resolution Protocol):


• If the destination IP address is within the same subnet, Device A needs to find out the MAC (Media Access
Control) address of Device B to send the IP packet at the data link layer.
• Device A broadcasts an ARP request on the LAN asking, "Who has the IP address 192.168.1.3?".

• Device B responds with its MAC address.

4. Packet Forwarding:
• Device A encapsulates the IP packet into an Ethernet frame with the MAC address of Device B as the
destination.

• The Ethernet switch in the LAN receives this frame. If it knows the port associated with Device B's MAC
address (learned via previous traffic), it forwards the frame directly to that port.

• Device B receives the Ethernet frame, recognizes its MAC address, and decapsulates the IP packet.

• Finally, Device B processes the IP packet and extracts the data.

Key Points:
• Direct Communication: Devices within the same LAN communicate directly using IP addresses and MAC
addresses without the need for routing.

• Subnet Mask: The subnet mask determines which IP addresses are considered local (within the same subnet)
and which require routing to reach.

• ARP for Address Resolution: ARP is used to map IP addresses to MAC addresses within the same subnet,
enabling devices to communicate at the data link layer.

• Ethernet Switches: Switches play a crucial role in forwarding frames within the LAN based on MAC
addresses, allowing efficient and direct communication between devices.

IP FORWARDING ACROSS A ROUTER

IP forwarding across a router involves the process of routing IP packets between different networks or subnets.
Routers are network devices that connect multiple networks together and make forwarding decisions based on
destination IP addresses. Here’s how IP forwarding works across a router:

Router Setup:

Multiple Networks: Routers connect different networks (LANs or WANs) together. Each network has its own IP
address range (subnet) and devices within these networks communicate through the router.

Routing Table: Routers maintain a routing table that contains information about known networks and how to reach
them. This table helps the router make decisions on where to forward packets.

IP Forwarding Process Across a Router:

Sending Data from a Local Device:


Suppose a device in one network (let's call it Network A) wants to communicate with a device in another network
(Network B).

The source device (Device A in Network A) creates an IP packet containing:

Source IP address (e.g., 192.168.1.2)

Destination IP address (e.g., 10.0.0.2)

Routing Decision:
Device A checks its own IP address and subnet mask to determine if the destination IP address (10.0.0.2) is within its
local subnet.

Since the destination IP address is not in the local subnet, Device A forwards the packet to its default gateway, which
is typically the IP address of the router (e.g., 192.168.1.1).

Packet Forwarding by the Router:


The router (192.168.1.1) receives the IP packet from Device A.

The router checks its routing table to determine where to forward the packet next.

The router looks at the destination IP address (10.0.0.2) and finds an entry in its routing table that specifies how to
reach the destination network (Network B).

The routing table might indicate that the next hop to reach Network B is through another interface or router (e.g.,
10.0.0.1).

Forwarding to the Next Hop:


The router encapsulates the received IP packet into a new frame suitable for the next hop (often using protocols like
Ethernet, MPLS, etc.).

The router sends this frame out of the appropriate interface towards the next hop (e.g., another router or directly to
Network B).

Key Points:
Interconnecting Networks: Routers enable communication between devices in different networks by forwarding
packets based on destination IP addresses.

Routing Tables: Routers use routing tables to determine the best path for forwarding packets to reach their destination
networks.

Network Address Translation (NAT): Routers may perform NAT when forwarding packets from a private network
(like 192.168.x.x) to a public network (like the Internet), translating private IP addresses to a public IP address
assigned to the router.

Gateway: Routers often act as gateways for devices in one network to communicate with devices in another network,
whether it's another LAN or the Internet.
PRACTICAL NO.8
UNDERSTAND THE WORKING OF "CONNECTION ESTABLISHMENT"
IN TCP USING NETWORK SIMULATION USING TOOLS

This process ensures that both the client and server are ready to exchange data before any actual data transmission
occurs. Here's an overview of the theory behind TCP connection establishment:

1. SYN (Synchronize):
• The client initiates the connection establishment process by sending a TCP segment with the SYN flag (SYN
packet) set to the server.

The SYN packet contains a randomly chosen initial sequence number (ISN) generated by the client.
This ISN helps in sequencing the data during the connection.

2. SYN-ACK (Synchronize-Acknowledge):
• Upon receiving the SYN packet from the client, the server responds by sending a TCP segment with both
the SYN and ACK flags set (SYN-ACK packet) back to the client.

• The SYN-ACK packet acknowledges the receipt of the client's SYN packet and contains the server's own
randomly chosen initial sequence number (ISN).

3. ACK (Acknowledge):
• Finally, the client acknowledges the receipt of the server's SYN-ACK packet by sending a TCP segment with the
ACK flag set (ACK packet) back to the server.

• This ACK packet confirms the establishment of the connection, and data transmission can begin.

During the three-way handshake, both the client and server exchange information necessary for establishing a
reliable communication channel. The process ensures that both parties agree on initial sequence numbers and are
aware of each other's readiness to transmit data.

When simulating TCP connection establishment using network simulation tools, such as ns-3 or OMNeT++, you
model the behavior of the client and server hosts and the network environment.

Procedure :- To simulate the working of connection establishment in TCP using network simulation tools like
ns-3 or OMNeT++, you would typically follow these steps:

1. Setup Environment:
• Install the chosen network simulation tool on your computer.

• Familiarize yourself with the simulation environment, including how to create network topologies, configure
hosts, and simulate network behavior.

2. Design Network Topology:


• Create a simulated network topology consisting of at least two hosts (client and server) connected by a
network link.

• Determine the characteristics of the network link, such as bandwidth, delay, and packet loss, which will
affect the TCP connection.

3. Configure Hosts:
• Configure the client and server hosts to use TCP as the transport protocol.
• Define the parameters of the TCP protocol stack on both hosts, including initial sequence numbers, maximum
segment size, and TCP options.

4. Implement Connection Establishment:


• Program the client host to initiate a TCP connection to the server host.

• Implement the three-way handshake process (SYN, SYN-ACK, ACK) within the simulation environment.
Ensure that the client sends a SYN packet, the server responds with a SYN-ACK packet, and the client
acknowledges the SYN-ACK packet.

5. Run Simulation:
• Start the simulation and monitor the interaction between the client and server hosts.

• Observe the exchange of TCP packets, including SYN, SYN-ACK, and ACK, as well as any retransmissions or
timeouts that may occur during connection establishment.

6. Analyze Results:
• Analyze the captured network traffic and simulation logs to verify that the connection establishment
process follows the expected TCP behaviour.

• Evaluate the timing and sequence of transmitted packets and ensure that the connection is successfully
established between the client and server.

7. Experiment with Parameters:


• Modify the parameters of the network link or TCP protocol stack to simulate different network conditions
or configurations.

• Repeat the simulation under varied conditions to observe how TCP connection establishment behaves in
response to changes in the environment.

8. Document Findings:
• Document your observations, findings, and any insights gained from the simulations.

• Note any deviations from expected behaviour and analyse the impact of different network conditions on TCP
connection establishment.
PRACTICAL NO.9
VARIATION IN DATA RATE OF WIRELESS LAN( IEEE 802.11B)
NETWORK AS THE DISTANCE BETWEEN THE
ACCESS POINT AND WIRELESS NODES VARIED

The data rate of a Wireless LAN (IEEE 802.11b) network varies with distance involves theunderstanding of how the
signal strength and quality degrade as the distance between the Access Point (AP) and wireless nodes increases. IEEE
802.11b operates in the 2.4 GHz frequency band and offers data rates of up to 11 Mbps. The effective data rate
experienced by devices connected to the network can decrease as distance increases due to several factors including
signal attenuation, interference, and environmental conditions.

Here's a general approach to study this variation:


1. Setup and Equipment:

➔ Use a setup with an IEEE 802.11b wireless router (AP) and compatible wireless
client devices (nodes). Ensure that the devices are capable of displaying the
current connection speed.
➔ Use appropriate tools for measuring signal strength and quality. This can include
software tools on the client devices or specialized Wi-Fi diagnostic tools.

2. Select Testing Locations:

Choose multiple test locations at varying distances from the AP. Ensure that each location represents a clear
line of sight with minimal obstacles between the AP and the wireless node.

3. Signal Strength Measurement:

➔ Begin at a known baseline distance where the wireless connection is strong (e.g., close proximity to the
AP).
➔ Measure and record the received signal strength indicator (RSSI) or similar metrics on the client devices
as you move them away from the AP in incremental distances (e.g., every 5 meters)

4. Data Rate Observation:

➔ At each distance point, record the observed data rate (throughput) of the wireless connection. This
can typically be viewed in the network settings or Wi-Fi connection details on the client device.
➔ Note any fluctuations in data rate and correlate them with changes in signal strength.

5. Analysis and Interpretation:


➔ Analyze the collected data to observe how the data rate changes with distance.
➔ Typically, as the distance increases:
➔ Signal strength decreases due to path loss and attenuation.
➔ Increased interference and noise might affect the connection quality.
➔ The AP and client devices might negotiate lower modulation schemes (from higher to lower data
rates) to maintain a stable connection at longer ranges.

6. Graphical Representation:
➔ Plot a graph showing the relationship between distance and data rate.
➔ This graph can help visualize the impact of distance on the performance of the IEEE 802.11b
network.

By systematically varying the distance between the AP and wireless nodes while monitoring signal strength and
data rate, you can gain insights into how IEEE 802.11b network performance is affected by distance. This
experiment helps in understanding the practical limitations and optimal deployment scenarios for wireless LAN
networks.
PRACTICAL NO. 10
Study the working and routing table formation of Interior routing
Protocols, i.e.,Routing Information Protocol (RIP) and Open
Shortest Path First(OSPF)

Routing Information Protocol (RIP)

1. Routing Information Protocol (RIP) Overview:


Routing Information Protocol (RIP) is one of the oldest distance-vector interior gateway protocols. It operates based
on the Bellman-Ford algorithm and uses hop count (number of routers) as the metric to determine the best path to a
destination network. RIP is suitable for small to medium-sized networks and is defined by RFC 2453.

2. Working of RIP:

Routing Updates: RIP routers periodically broadcast their entire routing table to neighboring routers. These updates
are sent every 30 seconds by default.

Hop Count Metric: RIP uses hop count (number of routers) as its metric. Each router maintains a routing table
where each entry includes the destination network, next hop router, and hop count to reach that network.

Distance-Vector Algorithm: RIP operates using the distance-vector algorithm, where routers inform neighbors
of the shortest path (in terms of hop count) to all known destinations.

Split Horizon and Poison Reverse: RIP uses techniques like split horizon and poison reverse to prevent routing
loops and manage routing information efficiently.

3. Routing Table Formation in RIP:

Initial Routing Table: Each router starts with its directly connected networks in its routing table, with a hop count
of 0.

Receiving Updates: When a router receives a routing update from a neighbor, it processes the information and
updates its routing table based on the hop counts advertised by the neighbor.

Updating Routing Table:


If a router receives an update for a destination network that it does not have in its routing table, it adds the network
with the advertised hop count and the neighbor as the next hop.
If the received hop count to a destination network is lower than what the router currently has, it updates its routing
table with the new path.

Triggered Updates: RIP routers send triggered updates (immediate updates) when changes occur in the network
topology (e.g., link failure) to inform neighbors of the change.

Example of Routing Table Formation (RIP):


Let's consider a simple network with three routers (A, B, C) and the following initial configurations:

Router A is directly connected to networks N1 (cost 1) and N2 (cost 2).

Router B is directly connected to networks N2 (cost 1) and N3 (cost 2).

Router C is directly connected to networks N1 (cost 1) and N3 (cost 1).

Initial Routing Tables:

Router A:

N1 via directly connected (cost 0)

N2 via directly connected (cost 0)

Router B:

N2 via directly connected (cost 0)

N3 via directly connected (cost 0)

Router C:

N1 via directly connected (cost 0)


N3 via directly connected (cost 0)

After RIP Updates:

Routers exchange updates:

Router A updates N3 (via B) with a hop count of 2.

Router B updates N1 (via C) with a hop count of 2.

Updated Routing Tables:

Router A:

N1 via directly connected (cost 0) N2

via directly connected (cost 0)

N3 via B (cost 2) Router

B:

N2 via directly connected (cost 0) N3

via directly connected (cost 0)


N1 via C (cost 2) Router

C:

N1 via directly connected (cost 0)

N3 via directly connected (cost 0)

Open Shortest Path First

1. Open Shortest Path First (OSPF) Overview:


OSPF is a link-state interior gateway routing protocol designed to efficiently route IP packets within a single
autonomous system (AS). It is widely used in large-scale networks due to its scalability and flexibility. OSPF
operates based on the Dijkstra's shortest path algorithm and uses link-state advertisements (LSAs) to build and
maintain a topology database. OSPF is defined by RFC 2328.

2. Working of OSPF:
Neighbor Discovery: OSPF routers establish neighbor relationships by exchanging hello packets. This allows routers
to dynamically discover neighboring routers and establish adjacencies.

Link-State Advertisements (LSAs): Routers exchange LSAs to describe their directly connected links and
network reachability information. Each LSA contains information about the router's interfaces, neighboring routers,
and link costs.

Database Synchronization: Routers maintain a link-state database (LSDB) that stores all received LSAs. By
exchanging LSAs and updating the LSDB, routers synchronize their views of the network topology.

Shortest Path Calculation: OSPF routers use the Dijkstra's algorithm to calculate the shortest path tree (SPT)
from themselves to all other routers in the network based on the LSDB.

Routing Table Calculation: Based on the computed SPT, each router constructs its routing table, which includes
entries for destination networks, next-hop routers, and associated costs (metric).

Path Selection: OSPF routers select the best path to each destination network based on the shortest path tree
(SPT) calculated using Dijkstra's algorithm.

3. Routing Table Formation in OSPF:


Initial Routing Table: Each OSPF router starts with minimal routing information, including directly connected
networks.

LSA Exchange and LSDB Update:

Routers exchange hello packets to establish adjacencies.

Routers periodically exchange LSAs to describe their links and network reachability.

Each router updates its LSDB based on received LSAs.


Shortest Path Calculation:
Routers use the LSDB to compute the shortest path tree (SPT) using Dijkstra's algorithm.

The SPT determines the best path (shortest path) to each destination network.

Routing Table Calculation:

Based on the computed SPT, each router constructs its routing table.

The routing table includes entries for destination networks, next-hop routers, and associated costs (metric).

Path Selection:
OSPF routers select the best path to each destination network based on the computed routing table (shortest path).

Initial Routing Tables:


Each router has routing entries for its directly connected networks.

LSDB and Shortest Path Calculation:

Routers exchange LSAs and update their LSDB with received LSAs.

Using Dijkstra's algorithm, routers compute the shortest path tree (SPT) from themselves to all other routers.

Updated Routing Tables:


Based on the computed SPT, routers update their routing tables with entries for destination networks, next-hop routers,
and associated costs.
PRACTICAL NO. 11
DETERMINING OPTIMUM PERSISTENCE OF CSMA/CD NETWORK
Determining the optimum persistence for a CSMA/CD (Carrier Sense Multiple Access with Collision Detection)
network involves finding a balance between channel utilization and collision probability. The goal is to choose a
persistence value (also known as the contention window size) that maximizes network efficiency while minimizing
the likelihood of collisions.

Here's a step-by-step approach:

Understanding CSMA/CD Basics:


Carrier Sense Multiple Access (CSMA):
Before transmitting, a node listens to the channel to check if it's idle. If the channel is busy, the node waits for a
random period before retrying.

Collision Detection (CD):


If a collision occurs (i.e., two or more nodes transmit simultaneously), nodes detect the collision and stop transmitting,
then wait for a random backoff period before retrying.

Steps to Determine Optimum Persistence:

Define Network Parameters:


Understand the characteristics of your CSMA/CD network, including:

Maximum transmission rate (data rate).

Propagation delay (time taken for a signal to travel from sender to receiver).

Round-trip time (RTT), which includes propagation delay and processing delay.

Calculate Slot Time:


Determine the slot time, which is the maximum amount of time it takes for a signal to propagate across the network.
It's typically calculated as:

Slot Time=2×Propagation Delay

Understand Persistence (P):


Persistence (P) is a value between 0 and 1 that represents the probability of transmitting in a given slot when the
channel is sensed idle.
Persistence is related to the contention window size and affects the probability of collision.

Model Network Performance:


Use theoretical or simulation models to analyze network performance metrics, such as throughput, delay, and collision
probability, for different values of persistence.

Simulate Collision Probability:

Calculate the probability of collision for various persistence values using the formula:

Collision Probability=1−(1−P)

where n is the number of contending nodes.

Optimize Persistence:
Aim to maximize channel utilization (efficiency) while minimizing collision probability.

Experiment with different persistence values and observe their impact on network performance metrics.

Tips for Optimization:

Start with Default Values: Commonly used default values for persistence are in the range of 0.01 to 0.1. Begin
your analysis with these values and adjust based on observed performance.

Consider Network Load: Higher network load (more contending nodes) generally requires smaller persistence
values to reduce collision probability.

Simulate Different Scenarios: Use simulation tools or mathematical models to simulate network behavior under
varying persistence settings and node densities.

Evaluate Trade-offs: Higher persistence values increase the chance of collisions but reduce idle time. Lower
persistence values decrease collision probability but increase idle time and decrease channel utilization.

Conclusion:
Determining the optimum persistence for a CSMA/CD network involves a balance between channel efficiency and
collision avoidance. By analyzing network parameters, simulating network behavior, and experimenting with
different persistence values, you can find the setting that optimizes performance based on your specific network
requirements and conditions.
PRACTICAL NO. 12
DISTANCE VECTOR ROUTING ALGORITHM
DISTANCE VECTOR ROUTING:
It is one of the routing algorithm in a Wide Area Network for computing shortest path between source and
destination. The Router is one main devices used in a wide area network. The main task of the router is Routing. It
forms the routing table and delivers the packets depending upon the routes in the tableeither directly or via an
intermediate devices. Each router initially has information about its all neighbors. Then this information will be
shared among nodes.

Algorithm:
1. Create a simulator object.

2. Define different colors for different data flows.

3. Open a nam trace file and define finish procedure then close the trace file, and execute nam on trace file.

4. Create n number of nodes using for loop.

5. Create duplex links between the nodes.

6. Setup UDP Connection between n(0) and n(5).

7. Setup another UDP connection between n(1) and n(5).

8. Apply CBR Traffic over both UDP connections.

9. Choose distance vector routing protocol to transmit data from sender to receiver.

10. Schedule events and run the program.

Program for this algorithm:


set ns [new Simulator]

set nr [open thro.tr w]

$ns trace-all $nr

exec nam thro.nam &

exit 0 }

for { set i 0 } { $i < 12} { incr i 1 } {


set n($i) [$ns node]} for {set i 0} {$i
< 8} {incr i} {
$ns duplex-link $n($i) $n([expr $i+1]) 1Mb 10ms DropTail }

$ns duplex-link $n(0) $n(8) 1Mb 10ms DropTail

$ns duplex-link $n(1) $n(10) 1Mb 10ms DropTail


$ns duplex-link $n(0) $n(9) 1Mb 10ms DropTail

$ns duplex-link $n(9) $n(11) 1Mb 10ms DropTail

$ns duplex-link $n(10) $n(11) 1Mb 10ms DropTail

$ns duplex-link $n(11) $n(5) 1Mb 10ms DropTail

set udp0 [new Agent/UDP] $ns attach-agent $n(0)

$udp0

set cbr0 [new Application/Traffic/CBR]

$cbr0 set packetSize_ 500

$cbr0 set interval_ 0.005

$cbr0 attach-agent $udp0 set

null0 [new Agent/Null] $ns

attach-agent $n(5) $null0

$ns connect $udp0 $null0

set udp1 [new Agent/UDP]

$ns attach-agent $n(1) $udp1

set cbr1 [new Application/Traffic/CBR]

$cbr1 set packetSize_ 500

$cbr1 set interval_ 0.005

$cbr1 attach-agent $udp1 set

null0 [new Agent/Null] $ns

attach-agent $n(5) $null0

$ns connect $udp1 $null0

$ns rtproto 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
Output for the above program:
PRACTICAL NO. 13
LINK STATE ROUTING ALGORITHM

LINK STATE ROUTING:


In link state routing, each router shares its knowledge of its neighborhood with every other router in the internet
work. (i) Knowledge about Neighborhood: Instead of sending its entire routing table a router sends info about its
neighborhood only. (ii) To all Routers: each router sends this information to every other router on the internet work
not just to its neighbor .It does so by a process called flooding. (iii)Information sharing when there is a change:
Each router sends out information about the neighbors when there is change.

Algorithm:
1. Create a simulator object.

2. Define different colors for different data flows.

3. Open a nam trace file and define finish procedure then close the trace file, and execute nam on trace file.

4. Create n number of nodes using for loop.

5. Create duplex links between the nodes.

6. Setup UDP Connection between n(0) and n(5).

7. Setup another UDP connection between n(1) and n(5).

8. Apply CBR Traffic over both UDP connections.

9. Choose Link state routing protocol to transmit data from sender to receiver.

10. Schedule events and run the program.

Program for this algorithm:

set ns [new Simulator]


set nr [open thro.tr w]
$ns trace-all $nr set nf
[open thro.nam w] $ns
namtrace-all $nf proc
finish { } { global ns nr
nf
$ns flush-trace
close $nf close $nr

exec nam thro.nam &

exit 0

} for { set i 0 } { $i < 12} { incr i 1

} { set n($i) [$ns node]} for {set i 0}

{$i < 8} {incr i} {

$ns duplex-link $n($i) $n([expr $i+1]) 1Mb 10ms DropTail }

$ns duplex-link $n(0) $n(8) 1Mb 10ms DropTail

$ns duplex-link $n(1) $n(10) 1Mb 10ms DropTail $ns

duplex-link $n(0) $n(9) 1Mb 10ms DropTail

$ns duplex-link $n(9) $n(11) 1Mb 10ms DropTail

$ns duplex-link $n(10) $n(11) 1Mb 10ms DropTail

$ns duplex-link $n(11) $n(5) 1Mb 10ms DropTail

set udp0 [new Agent/UDP] $ns attach-agent $n(0)

$udp0 set cbr0 [new Application/Traffic/CBR]

$cbr0 set packetSize_ 500

$cbr0 set interval_ 0.005

$cbr0 attach-agent $udp0

set null0 [new Agent/Null]

$ns attach-agent $n(5) $null0 $ns

connect $udp0 $null0 set udp1 [new

Agent/UDP] $ns attach-agent $n(1)

$udp1 set cbr1 [new

Application/Traffic/CBR]

$cbr1 set packetSize_ 500

$cbr1 set interval_ 0.005

$cbr1 attach-agent $udp1

set null0 [new Agent/Null]

$ns attach-agent $n(5) $null0

$ns connect $udp1 $null0

$ns rtproto LS

$ns rtmodel-at 10.0 down $n(11) $n(5)


$ns rtmodel-at 15.0 down $n(7) $n(6)

$ns rtmodel-at 30.0 up $n(11) $n(5)

$ns rtmodel-at 20.0 up $n(7) $n(6)

$udp0 set fid_ 1

$udp1 set fid_ 2

$ns color 1 Red

$ns color 2 Green

$ns at 1.0 "$cbr0 start"

$ns at 2.0 "$cbr1 start"

$ns at 45 "finish"

$ns run

Output for the above program:


PRACTICAL NO.14
NETWORK SIMULATOR(NS) AND SIMULATION OF
CONGESTION CONTROL ALGORITHMS USING NS

NETWORK SIMULATOR:

Network Simulator (Version 2), widely known as NS2, is simply an event driven simulation tool that has proved
useful in studying the dynamic nature of communication networks. Simulation of wired as well as wireless network
functions and protocols (e.g., routing algorithms, TCP, UDP) can be done using NS2. In general, NS2 provides
users with a way of specifying such network protocols and simulating their corresponding behaviors. Due to its
flexibility and modular nature, NS2 has gained constant popularity in the networking research community since its
birth in 1989. Ever since, several revolutions and revisions have marked the growing maturity of the tool, thanks to
substantial contributions from the players in the field. Among these are the University of California and Cornell
University who developed the REAL network simulator,1 the foundation which NS is based on. Since 1995 the
Defense Advanced Research Projects Agency (DARPA) supported development of NS through the Virtual Inter
Network Testbed (VINT) project . Currently the National Science Foundation (NSF) has joined the ride in
development. Last but not the least, the group of Researchers and developers in the community are constantly
working to keep NS2 strong and versatile.

Basic Architecture:

NS2 provides users with an executable command ns which takes on input argument, the name of a Tcl simulation
scripting file. Users are feeding the name of a Tcl simulation script (which sets up a simulation) as an input argument
of an NS2 executable command ns.

In most cases, a simulation trace file is created, and is used to plot graph and/or to create animation. NS2 consists of
two key languages: C++ and Object-oriented Tool Command Language (OTcl). While the C++ defines the internal
mechanism (i.e., a backend) of the simulation objects, the OTcl sets up simulation by assembling and configuring the
objects as well as scheduling discrete events (i.e., a frontend). The C++ and the OTcl are linked together using TclCL.
Mapped to a C++ object, variables in the OTcl domains are sometimes referred to as handles. Conceptually, a handle
(e.g., n as a Node handle) is just a string (e.g.,_o10) in the OTcl domain, and does not contain any
functionality. Instead, the functionality (e.g., receiving a packet) is defined in the mapped C++ object (e.g., of class
Connector). In the OTcl domain, a handle acts as a frontend which interacts with users and other OTcl GRT
INSTITUTE OF ENGINEERING AND TECHNOLOGY objects. It may defines its own procedures and variables to
facilitate the interaction. Note that the member procedures and variables in the OTcl domain are called instance
procedures (instprocs) and instance variables (instvars), respectively. Before proceeding further, the readers are
encouraged to learn C++ and OTcl languages. We refer the readers to [14] for the detail of C++, while a brief tutorial
of Tcl and OTcl tutorial are given in Appendices A.1 and A.2, respectively.

NS uses two languages because simulator has two different kinds of things it needs to do. On one hand,detailed
simulations of protocols requires a systems programming language which can efficiently manipulate bytes, packet
headers, and implement algorithms that run over large data sets. For these tasks run-time speed is important and
turn-around time (run simulation, find bug, fix bug, recompile, re-run) is less important. On the other hand, a large
part of network research involves slightly varying parameters or configurations, or quickly exploring a number of
scenarios. In these cases, iteration time (change the model and re-run) is more important. Since configuration runs
once (at the beginning of the simulation), run-time of this part of the task is less important. ns meets both of these
needs with two languages, C++ and OTcl.

Tcl scripting
Tcl is a general purpose scripting language. [Interpreter]

• Tcl runs on most of the platforms such as Unix, Windows, and Mac.

• The strength of Tcl is its simplicity.

• It is not necessary to declare a data type for variable prior to the usage.

Basics of TCL
Syntax: command arg1 arg2 arg3 ]

Variables Command Substitution


set a 5 set len [string length foobar]

set b $a set len [expr [string length foobar] + 9]

Wired TCL Script Components


Create the event scheduler

Open new files & turn on the tracing

Create the nodes

Setup the links

Configure the traffic type (e.g., TCP, UDP, etc)

Set the time of traffic generation (e.g., CBR, FTP)

Terminate the simulation


NS Simulator Preliminaries.
1. Initialization and termination aspects of the ns simulator. 2.

Definition of network nodes, links, queues and topology.

3. Definition of agents and of applications.

4. The nam visualization tool.

5. Tracing and random variables.

Initialization and Termination of TCL Script in NS-2


An ns simulation starts with the command

set ns [new Simulator]


Which is thus the first line in the tcl script. This line declares a new variable as using the set command,

you can call this variable as you wish, In general people declares it as ns because it is an instance of the

Simulator class, so an object the code[new Simulator] is indeed the installation of the class Simulator

using the reserved word new.

In order to have output files with data on the simulation (trace files) or files used for visualization (nam

files), we need to create the files using ―open command:

#Open the Trace file

set tracefile1 [open out.tr w]


$ns trace-all $tracefile1

#Open the NAM trace file

set namfile [open out.nam w] $ns namtrace-all $namfile


The above creates a dta trace file called out.tr and a nam visualization trace file called out.nam.

Within the tcl script, these files are not called explicitly by their names, but instead by pointers that are declared

above and called ―tracefile1 and ―namfile respectively. Remark that they begins with a # symbol. The second line

open the file ―out.tr to be used for writing, declared with the letter ―w. The third line uses a simulator method

called trace-all that have as parameter the name of the file where the traces will go.

Define a “finish‟ procedure


Proc finish { } { global ns
tracefile1 namfile
$ns flush-trace
Close $tracefile1
Close $namfile
Exec nam out.nam &
Exit 0
}

Definition of a network of links and nodes


The way to define a node is

set n0 [$ns node]


Once we define several nodes, we can define the links that connect them. An example of a definition of

a link is:

$ns duplex-link $n0 $n2 10Mb 10ms DropTail


Which means that $n0 and $n2 are connected using a bi-directional link that has 10ms of propagation delay

and a capacity of 10Mb per sec for each direction.

To define a directional link instead of a bi-directional one, we should replace ―duplex-link by

―simplex-link.

In ns, an output queue of a node is implemented as a part of each link whose input is that node. We should

also define the buffer capacity of the queue related to each link. An example would be:

#set Queue Size of link (n0-n2) to 20I

Procedure to do simulation of congestion control algorithm:


FTP over TCP
TCP is a dynamic reliable congestion control protocol. It uses Acknowledgements created by the destination

to know whether packets are well received.

There are number variants of the TCP protocol, such as Tahoe, Reno, NewReno, Vegas. The type of

agent appears in the first line: set tcp [new Agent/TCP]


The command $ns attach-agent $n0 $tcp defines the source node of the tcp connection.
The command set sink [new Agent /TCPSink] Defines the behavior of the destination node of TCP
and assigns to it a pointer called sink.
#Setup a UDP connection
set udp [new Agent/UDP]
$ns attach-agent $n1 $udp
set null [new Agent/Null]
$ns attach-agent $n5 $null
$ns connect $udp $null
$udp set fid_2
#setup a CBR over UDP connection
The below shows the definition of a CBR application using a UDP agent

The command $ns attach-agent $n4 $sink defines the destination node. The command $ns connect

$tcp $sink finally makes the TCP connection between the source and destination nodes. set
cbr [new Application/Traffic/CBR]
$cbr attach-agent $udp
$cbr set packetsize_ 100
$cbr set rate_ 0.01Mb
$cbr set random_ false
TCP has many parameters with initial fixed defaults values that can be changed if mentioned
explicitly. For example, the default TCP packet size has a size of 1000bytes.This can be changed to

another value, say 552bytes, using the command $tcp set packetSize_ 552.
When we have several flows, we may wish to distinguish them so that we can identify them with different colors in
the visualization part. This is done by the command $tcp set fid_ 1 that assigns to

the TCP connection a flow identification of ―1.We shall later give the flow identification of ―2‖ to the

UDP connection.
PRACTICAL NO. 15

ENCRYPTION AND DECRYPTION


Encryption: Encryption means that the sender converts the original information into another form and sends
the unintelligible message over the network.

Decryption: Decryption reverses the Encryption process in order to transform the message back to the original
form.

The data which is to be encrypted at the sender site is known as plaintext, and the encrypted data is known as
ciphertext. The data is decrypted at the receiver site.

There are two types of Encryption/Decryption techniques:

o Privacy with secret key Encryption/Decryption o Privacy with public key Encryption/Decryption
Secret Key Encryption/Decryption technique:

o In Secret Key Encryption/Decryption technique, the same key is used by both the parties, i.e., the sender
and receiver.

o The sender uses the secret key and encryption algorithm to encrypt the data; the receiver uses this key
and decryption algorithm to decrypt the data.

o In Secret Key Encryption/Decryption technique, the algorithm used for encryption is the inverse of the
algorithm used for decryption. It means that if the encryption algorithm uses a combination of addition
and multiplication, then the decryption algorithm uses a combination of subtraction and division.

o The secret key encryption algorithm is also known as symmetric encryption algorithm because the same
secret key is used in bidirectional communication.

o In secret key encryption/decryption algorithm, the secret code is used by the computer to encrypt the
information before it is sent over the network to another computer.

o The secret key requires that we should know which computers are talking to each other so that we can
install the key on each computer.

Data Encryption Standard (DES)


o The Data Encryption Standard (DES) was designed by IBM and adopted by the U.S. government as the
standard encryption method for nonmilitary and nonclassified use.

o The Data Encryption Standard is a standard used for encryption, and it is a form of Secret Key
Cryptography.

ALGORITHM-ENCRYPTION
Get the text to be encrypted (plain text) and key text.
a. Find the length of the plain text.
b. For i=1 to length of plain text
c. Find the binary equivalent of ith character of plain text.
d. Find the binary equivalent of ith character of key text
e. Find the XOR of above two values.
The resulting value will be the encrypted format (cipher text) of the plain text.

ALGORITHM-DECRYPTION

Get the text to be decrypted (cipher text)


and key text.Find the length of the cipher
text.
For i=1 to length of cipher text
a. Find the binary equivalent of ith character of cipher text.
b. Find the binary equivalent of ith character of key text
c. Find the XOR of above two values.
The resulting value will be the decrypted format (original plain text) of the cipher plain text.

Program:

# include <stdio.h>

#include<conio.h>

void main ( )

{ static int s, i, k,n,c[100];

printf(“\n program 1: encryption and 2. decryption”);

scanf (“%d”, &s); switch (s)

{ case 1: printf(“enter the key value:”);

scanf(“%d”, &k); printf(“enter the

length of text:”); scanf(“%d”, &n);

printf(“enter the data to be encrypted:”);

for (i=0;i<=n;i++) scanf(“%c”, &c[i]);

for (i=0;i<=n;i++)

{c[i]=c[i]+k; if (c[i]>90) c[i]=c[i]-26;}

printf(“encrypted data”); for

(i=1;i<=n;i++) printf(“%c”, c[i]); break;


case 2: printf(“enter the key value:”);

scanf(“%d”, &k); printf(“enter the

length of text:”); scanf(“%d”, &n);

printf(“enter the data to be decrypted:”);

for (i=0;i<=n;i++) scanf(“%c”, &c[i]);

for (i=0;i<=n;i++) {c[i]=c[i]-k; if

(c[i]<65) c[i]=c[i]+26;}

printf(“decrypted data”); for

(i=1;i<=n;i++) printf(“%c”, c[i]); break;

case 3: break; getch (); }

}
Output:

You might also like