saurabh cn 2
saurabh cn 2
Practical File
On
Computer Network Lab
(LC-ECE322G)
Submitted
For
Bachelor of Technology
In
Electronics & Communication
Engineering
At
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
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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".
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.
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 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.
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
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.
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
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.
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.
• 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.
• After the simulation, the number of packets dropped due to congestion is calculated based on the packet
loss events observed during the transmission.
Procedure:-
1. Click the pc
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:
Create a new simulation project or open an existing one to start configuring the network.
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.
Test DHCP functionality by connecting new devices to the network and verifying that they receive IP
addresses dynamically.
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.
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.
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 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
main()
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 :
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.
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.
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.
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:
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).
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.
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 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.
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).
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).
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.
• 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.
• 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.
• 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.
➔ 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.
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.
➔ 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)
➔ 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.
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)
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.
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.
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.
Router A:
Router B:
Router C:
Router A:
B:
C:
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.
Routers periodically exchange LSAs to describe their links and network reachability.
The SPT determines the best path (shortest path) to each destination network.
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).
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.
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 the probability of collision for various persistence values using the formula:
Collision Probability=1−(1−P)
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.
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.
3. Open a nam trace file and define finish procedure then close the trace file, and execute nam on trace file.
9. Choose distance vector routing protocol to transmit data from sender to receiver.
exit 0 }
$udp0
$ns rtproto DV
$ns at 45 "finish"
$ns run
Output for the above program:
PRACTICAL NO. 13
LINK STATE ROUTING ALGORITHM
Algorithm:
1. Create a simulator object.
3. Open a nam trace file and define finish procedure then close the trace file, and execute nam on trace file.
9. Choose Link state routing protocol to transmit data from sender to receiver.
exit 0
Application/Traffic/CBR]
$ns rtproto LS
$ns at 45 "finish"
$ns run
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.
• It is not necessary to declare a data type for variable prior to the usage.
Basics of TCL
Syntax: command arg1 arg2 arg3 ]
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
In order to have output files with data on the simulation (trace files) or files used for visualization (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.
a link is:
―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:
There are number variants of the TCP protocol, such as Tahoe, Reno, NewReno, Vegas. The type of
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
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.
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.
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
Program:
# include <stdio.h>
#include<conio.h>
void main ( )
for (i=0;i<=n;i++)
(c[i]<65) c[i]=c[i]+26;}
}
Output: