Computer Networks
Computer Networks
Aim:- To create a Peer-to-Peer (P2P) connection using Local Area Network (LAN)
Theory:-
• A Peer-to-Peer (P2P) network is a decentralized system where all devices (peers) are
equally privileged.
• Peers share resources (files, printers, internet access) directly without any centralized
server.
• Each node in a P2P network acts as both a client and server.
Unstructured Random connections; harder to search but easier to build. Napster, Gnutella
Structured Organized connections; easy search but complex setup. P-Grid, Kademlia
Hybrid Uses both central servers and P2P features for balance. Torrent trackers
2
• Collaborative Platforms (Git, P2P Cloud Storage)
Advantages:
• Simple setup and low cost
• No dedicated network administrator needed
• Scalable by simply adding new devices
• Reduced traffic bottlenecks compared to server-based networks
Disadvantages
• Difficult to secure data
• Locating resources can be hard
• Less performance reliability
• Maintenance becomes harder as the network grows
Questions & Answers:
S.
Question Answer
No.
How is a P2P network In a P2P network, every device acts both as a server and
2 different from a Client-Server a client, while in Client-Server, specific servers serve
network? multiple client devices.
Give two real-life examples of BitTorrent for file sharing and Bitcoin for
3
P2P applications. cryptocurrency are examples of P2P applications.
What are the types of P2P The three types are: Unstructured, Structured, and
4
networks? Hybrid P2P networks.
Where are P2P networks Small offices, residential areas, and environments
6
mostly used? requiring easy and cost-effective sharing of resources.
3
Practical-02
Aim:-To create a network connection using a Hub.
Theory
• A hub is a basic networking device that operates at the Physical Layer (Layer 1) of the
OSI model.
• It is used to connect multiple devices in a network (LAN) and broadcast the data it
receives to all connected ports.
• Hubs do not filter or intelligently route data; they simply repeat the signal across all
ports.
• Hubs are suitable for small networks where the traffic load is low.
Type Description
Active Hub Amplifies, regenerates, and retransmits network signals. Requires power.
Passive Hub Simply connects devices; does not amplify signals. No power supply needed.
Intelligent Functions like an active hub but also monitors network traffic using MIB
Hub (Management Information Base).
4
Features of a Hub
• Operates at the physical layer.
• Supports half-duplex communication.
• Works on shared bandwidth and uses broadcasting.
• Cannot identify the destination; broadcasts to all ports.
• Does not support VLAN (Virtual LAN) or spanning tree protocol.
• Unable to determine the best route for data transmission.
• Can detect collisions and send jamming signals.
Applications of Hubs
• Connecting computers in a small LAN.
• Extending network range in home or small offices.
• Used in network labs for training purposes.
Advantages of Hubs
• Low cost and easy to install.
• No software configuration required.
• Supports different types of network media.
Disadvantages of Hubs
• Broadcasts data to all ports, causing unnecessary traffic.
• Cannot filter data or find the shortest path.
• Poor performance under heavy traffic.
• No security features.
What is the main purpose of a A hub connects multiple devices and broadcasts
1
hub in a network? incoming data to all connected ports without filtering.
5
S.
Question Answer
No.
At which OSI layer does a hub Hubs work at the Physical Layer (Layer 1) of the OSI
2
operate? Model.
Why are hubs considered Because they broadcast data to all devices, causing high
4
inefficient for large networks? network traffic and collisions.
State two advantages of using 1) Cost-effective and 2) Easy to set up without needing
6
a hub. technical expertise.
6
Practical-03
Aim:-To create a network connection using a Switch.
Theory:-
• A switch is a networking device that operates at Layer 2 (Data Link Layer) of the OSI
model.
• Unlike hubs, switches intelligently forward data only to the device that needs it, using
MAC addresses.
• It uses packet switching to receive, process, and forward data to the destination device.
• Switches help reduce network traffic and improve performance by creating dedicated
communication links between devices.
Types of Switches:-
Type Description
Unmanaged
Plug-and-play; no configuration needed. Used in home networks.
Switch
LAN Switch Connects devices within a local network; also called Ethernet Switch.
Power over Ethernet switch; provides both power and data to devices over
PoE Switch
the same cable.
Features of Switches:-
• Operates mainly at the Data Link Layer (Layer 2).
7
• Uses MAC addresses to identify the destination device.
• Supports Unicast, Multicast, and Broadcast communication.
• Full duplex communication: devices can send and receive data simultaneously.
• Reduces network collisions.
• High port density (24/48 ports available).
• Capable of error checking before forwarding frames.
Applications of Switches:-
• Building Local Area Networks (LANs) in businesses and organizations.
• Used in Data Centers for high-speed network connectivity.
• Supporting VoIP phones, IP cameras, and wireless access points using PoE switches.
Advantages of Switches:-
• Reduces network traffic through efficient switching.
• Increases bandwidth availability for devices.
• Supports centralized management (in managed switches).
• Decreases frame collisions.
Disadvantages of Switches:-
• More expensive compared to hubs.
• Broadcast traffic can still create network congestion.
• Configuration (for managed switches) may require technical expertise.
At which layer of the OSI model Switches primarily operate at the Data Link Layer
2
does a switch primarily operate? (Layer 2).
8
S.
Question Answer
No.
List two applications where PoE 1) IP Cameras and 2) VoIP Phones, where both
6
switches are used. power and data are transmitted over one cable.
9
Practical-04
Aim:-To create a connection using a Router to forward data packets between different
networks.
Theory:-
A Router is a network device that forwards data packets between computer networks. It
connects two or more networks, such as LANs or WANs, and routes packets toward their
destination IP address using routing tables and protocols.
Routers allow multiple devices to share a single Internet connection, manage traffic, and
enhance security.
Types of Routers
Type Description
10
Type Description
Edge Router Placed at the network edge, connects to ISP and external networks.
Portable Router Lightweight mobile routers that create private Wi-Fi networks.
Functions of a Router
1. Forwarding – Forwards packets to the correct output port using the routing table.
2. Routing – Chooses the best path to reach a destination using algorithms.
3. NAT (Network Address Translation) – Maps private IPs to a public IP for Internet
access.
4. Security – Offers firewall and filtering to block unauthorized traffic.
5. QoS (Quality of Service) – Prioritizes specific traffic types (e.g., video, VoIP).
6. VPN Connectivity – Supports secure remote access via VPN.
7. Bandwidth Management – Controls traffic flow to prevent congestion.
8. Monitoring – Tracks traffic and offers diagnostics for fault resolution.
Architecture of a Router
11
Component Role
Switching Methods:
• Switching via Memory: CPU handles packet forwarding.
• Switching via Bus: Shared bus between input/output ports.
• Switching via Interconnection Network: High-speed matrix for fast internal routing.
Advantages of Routers
1. Multi-device Connectivity – Supports multiple devices sharing one Internet line.
2. Improved Security – Acts as a buffer between internal network and the Internet.
3. Efficient NAT – Allows multiple private IPs to access Internet through one public IP.
4. Dynamic Routing Support – Learns and adjusts paths automatically.
5. Traffic Filtering – Controls and blocks unwanted packets.
Disadvantages of Routers
1. Slower Processing – Routing decisions across multiple layers can cause delay.
2. Higher Cost – Advanced routers can be expensive.
3. Requires Configuration – Needs technical setup and management.
4. Interference – Quality may degrade due to signal issues or shared bands.
5. Bandwidth Overhead – Dynamic routing consumes bandwidth for route updates.
Applications of Routers
1. Connecting telecom hardware like BSC, MGW, SGSN for remote networking.
2. Used in both wired and wireless communications with STM interfaces.
3. ISPs use routers to transfer data (audio/video/email) across the Internet.
4. Routers enable access control, restricting or allowing certain users.
Questions and Answers
12
S.
Question Answer
No.
What is the primary function of A router forwards data packets between networks using
1
a router in a network? destination IP addresses to determine the best path.
Which address does a router use Routers use the destination IP address in the packet's
2
to forward packets? header to determine the path.
How does a router handle ARP The router includes its own IP and MAC addresses in
4
queries? the ARP query; the target replies with its MAC address.
13
Practical-05
Aim:-To create a network connection using a Repeater device.
Theory:-
• A Repeater is a network device that operates at the Physical Layer (Layer 1) of the OSI
model.
• It receives weak or corrupted signals over a network, amplifies or regenerates them,
and then forwards the refreshed signals.
• The main purpose of a repeater is to extend the distance a signal can travel over a
network without losing quality.
How a Repeater Works:
• Receives incoming signal from a network cable.
• Regenerates or amplifies the signal strength.
• Transmits the improved signal towards the next segment of the network.
Types of Repeaters
Type Description
14
Type Description
Remote Repeater Used where network spans long distances (large LANs).
Features of Repeaters
• Works only at the physical layer.
• Does not modify the actual content of the data.
• Extends network range by regenerating signals.
• Can work with both analog and digital signals.
• Needs external power to operate.
Applications of Repeaters
• Extending Ethernet networks over longer distances.
• Boosting Wi-Fi signals in large homes or offices.
• Used in fiber optic and satellite communication systems.
Advantages of Repeaters
• Extends the effective communication range.
• Reduces signal degradation over long distances.
• Cost-effective solution for small networks.
• Enhances network reliability by maintaining signal quality.
Disadvantages of Repeaters
• Cannot filter traffic; forwards all signals, including noise.
15
• No collision management in shared network mediums.
• Does not segment a network into separate collision domains.
• Adds a small delay due to signal processing.
At which layer of the OSI model A Repeater operates at the Physical Layer (Layer
2
does a Repeater operate? 1).
What is the difference between an Analog Repeaters amplify analog signals, while
3 Analog Repeater and a Digital Digital Repeaters regenerate digital signals
Repeater? precisely.
Give one practical use of a Wireless Extending Wi-Fi coverage in homes, offices, or
4
Repeater. large buildings.
Why can't Repeaters filter or Because they work only at the Physical Layer and
5
manage network traffic? deal with signals, not data content or addresses.
16
Practical-06
Aim:-To simulate Static Routing connection in a network .
Theory
• Static Routing involves manually setting fixed paths for data packets to reach their
destination.
• Routing Information Protocol (RIP) is a dynamic routing protocol that allows routers
to share information about network topology automatically.
• In this practical, static routes are configured manually, and RIP can be used for backup
or verification purposes.
Key Concepts:
Term Description
Routing Table A database containing the paths routers use to forward packets.
Procedure
1. Set Up Devices:
o PCs, Switches, Routers as per topology diagram.
17
2. Assign IP Addresses:
a. Assign unique IP addresses and subnet masks to each PC based on the provided table.
S.NO Device IPv4 Address Subnet mask Default Gateway
1. PC0 192.168.1.1 255.255.255.0 192.168.1.3
2. PC1 192.168.1.2 255.255.255.0 192.168.1.3
3. PC2 192.168.2.1 255.255.255.0 192.168.2.3
b. Configure IP addresses and subnet masks for router interfaces and make sure the
connection is enabled.
3. Configure Routers:
o Set up static routing using Cisco Packet Tracer or real routers.
S.NO Device Interface IPv4 Address Subnet mask
1. router0 GigabitEthernet0/0 192.168.1.3 255.255.255.0
GigabitEthernet0/1 193.168.3.1 255.255.255.0
2. router1 GigabitEthernet0/0 192.168.2.3 255.255.255.0
GigabitEthernet0/1 192.168.3.2 255.255.255.0
4. Enable RIP:
o Configure routers to advertise connected networks using RIP.
18
5. Verification:
o Test connectivity using ping commands.
o Check routing tables to verify routes.
19
• Manual configuration required for changes.
• Not scalable for large or frequently changing networks.
• Risk of misconfiguration if manual errors are made.
Why is Static Routing preferred in It provides predictable and secure routing paths
3
small networks? without the overhead of dynamic protocols.
What metric does RIP use to determine RIP uses hop count as its metric to choose the
4
the best route? best path.
What is one major disadvantage of It is not scalable and requires manual updates
5
Static Routing? for every network change.
How often does RIP update its routing RIP updates routing information every 30
7
information? seconds.
20
Practical-07
Aim:-To simulate Dynamic Routing in a network using Routing Information
Protocol (RIP).
Theory:-
Dynamic Routing is a technique where routers automatically calculate and update the best path
to forward data between networks based on real-time network conditions. Unlike static routing,
where paths are manually configured, dynamic routing uses routing protocols to share and
adjust routes across routers.
Dynamic routing is highly adaptive. If one path fails, the router detects the failure and
recalculates a new route based on protocols like RIP (Routing Information Protocol) or OSPF
(Open Shortest Path First).
For example, if the path R1 → R2 → R5 → R9 → R10 is disrupted due to a failure at R9, the
router can dynamically reroute the data using an alternate path like R1 → R2 → R5 → R8 →
R10 without requiring manual reconfiguration.
21
Working of Dynamic Routing
1. Protocol Installation: Routing protocols like RIP or OSPF are installed on each router
to enable communication.
2. Initial Configuration: The protocol starts manually and populates the initial routing
table.
3. Automatic Updates: Routers exchange routing information automatically and update
their routing tables.
4. Path Adjustment: If a network path fails, routers detect the issue and reroute data via
an alternative route.
5. Default Gateway Check: Hosts compare default gateway IPs with their local router to
ensure correct path delivery.
Purpose of Dynamic Routing
• Automatically explore multiple paths and select the best path.
• Enable real-time route updates in response to network changes.
• Share network topology with other routers.
• Eliminate manual routing tasks for administrators.
Component Function
22
Component Function
Routing Algorithm Calculates the best paths and updates routing tables.
S.
Question Answer
No.
How does RIP (Routing RIP uses hop count to determine the best path and shares
2
Information Protocol) work? updates with neighboring routers every 30 seconds.
23
S.
Question Answer
No.
What is the administrative RIP has an administrative distance of 120, while OSPF
5
distance of RIP and OSPF? has 110 — lower values are preferred.
What are some ways to Use show ip protocols, show ip route, show ip ospf
6 troubleshoot dynamic neighbor, or show ip bgp summary to check
routing? configurations and status.
List one scenario where In large enterprise networks where frequent topology
7 dynamic routing is preferred changes occur, dynamic routing adapts better and reduces
over static routing. manual overhead.
24
Practical-08:
Aim:-To configure a network using DHCP (Dynamic Host Configuration
Protocol)
Theory:-
DHCP (Dynamic Host Configuration Protocol) is an application-layer protocol that
automatically assigns IP addresses and other network parameters (like subnet mask, DNS, and
default gateway) to client devices in a network. It eliminates the need for manual IP
configuration and reduces IP conflicts.
DHCP is essential for efficiently managing large networks, enabling seamless device
connectivity, especially for mobile or frequently changing devices. It uses the client-server
model over UDP, with port numbers 67 (server) and 68 (client).
Why Do We Use DHCP?
• Automates IP allocation
• Prevents address conflicts
• Centralizes network configuration
• Reduces human error
• Enables easy scalability in large environments
Components of DHCP:-
Component Description
DHCP Options Includes subnet mask, domain name, time server, etc.
25
Component Description
Dynamic DNS
Automatically update DNS records.
Updates
Advantages of DHCP:-
• Centralized IP management
• Reduces manual configuration
• Prevents IP conflicts
• Supports mobile devices
• Enables fast network scaling
• Reuse of IPs improves efficiency
• Supports dynamic DNS updates
• Logging and monitoring aid troubleshooting
26
Disadvantages of DHCP:-
• IP conflicts if multiple servers offer the same range
• Clients may connect to rogue DHCP servers
• Clients can't operate without a DHCP server
• Hostname/IP changes may cause mismatches
• DHCP communication depends on open UDP ports
Applications of DHCP:-
• Enterprise networks – Automate large-scale IP allocation
• ISPs and broadband setups – Manage home IP addresses
• Wi-Fi zones – Support mobile and roaming clients
• IoT networks – Handle frequent device joins and leaves
• Virtual environments – Assign IPs to virtual machines
What happens if two DHCP It may cause IP conflicts. To prevent this, servers should
3 servers exist in the same be configured with non-overlapping IP ranges or
network? coordinated using failover protocols.
How can you troubleshoot a Ensure DHCP service is active, check configurations,
4 DHCP server if clients aren’t verify network connectivity, and examine logs or firewall
getting IPs? rules on ports 67 & 68.
27
S.
Question Answer
No.
28
Practical-09
Aim:-To configure and understand the working of incoming and outgoing
email communication
29
Theory:-
Email (Electronic Mail) is one of the most widely used services on the Internet. It enables
users to send and receive messages, including text, images, videos, and files, over the
internet. Emails follow a client-server model, where the sender and recipient communicate
through mail servers and protocols.
An email address typically follows the structure: [email protected], where:
• username identifies the user
• @ is a mandatory separator
• domain.com specifies the server handling the email
Emails can be sent using SMTP (Simple Mail Transfer Protocol) and received using POP3 or
IMAP, depending on the client configuration and requirements.
Components of an Email System:-
Component Description
Email Protocols
30
Protocol Use Port
SMTP Sending emails from client to server or server to server 25, 465, 587
IMAP Reading and managing emails directly from the server 143
Disadvantages:-
1. Prone to spam and phishing attacks
2. May lead to information overload
3. Misinterpretations due to lack of tone/body language
4. Dependent on server availability and network
Applications of Email:-
31
Domain Use Case
S.
Question Answer
No.
32
Practical 10
Aim:- To configure FTP connection.
33
Theory:-File transfer protocol (FTP) is an Internet tool provided by TCP/IP. The first
feature of FTP was developed by Abhay Bhushan in 1971. It helps to transfer files from one
computer to another by providing access to directories or folders on remote computers and
allows software, data, and text files to be transferred between different kinds of computers.
The end-user in the connection is known as localhost and the server which provides data is
known as the remote host.
Goals:-
1. It encourages the direct use of remote computers.
2. It shields users from system variations (operating system, directory structures, file
structures, etc.)
3. It promotes the sharing of files and other types of data.
Why FTP
FTP is a standard communication protocol. There are various other protocols like HTTP
which are used to transfer files between computers, but they lack clarity and focus as
compared to FTP. Moreover, the systems involved in connection are heterogeneous systems,
i.e. they differ in operating systems, directories, structures, character sets, etc the FTP shields
the user from these differences and transfers data efficiently and reliably.
FTP can transfer ASCII, EBCDIC, or image files. The ASCII is the default file share format,
in this, each character is encoded by NVT ASCII. In ASCII or EBCDIC the destination must
be ready to accept files in this mode. The image file format is the default format for
transforming binary files.
FTP Clients
FTP works on a client-server model. The FTP client is a program that runs on the user’s
computer to enable the user to talk to and get files from remote computers. It is a set of
commands that establishes the connection between two hosts, helps to transfer the files, and
then closes the connection.
Some of the commands are: get the filename(retrieve the file from the directories get server),
mget filename(retrieve multiple files from the server ), ls(lists files available in the current
directory of the server). There are also built-in FTP programs, which makes it easier to
transfer files and it does not require remembering the commands.
Anonymous FTP
Some sites can enable anonymous FTP whose files are available for public access. So, the
user can access those files without any username or password. Instead, the username is set to
34
anonymous and the password to the guest by default. Here, the access of the user is very
limited. For example, the user can copy the files but not allowed to navigate through
directories.
Transmission Mode
35
FTP transfer files using any of the following modes:
1. Stream Mode: It is the default mode. In stream mode, the data is transferred from FTP
to TCP in stream bytes. Here TCP is the cause for fragmenting data into small
segments. The connection is automatically closed if the transforming data is in the
stream bytes. Otherwise, the sender will close the connection.
2. Block Mode: In block mode, the data is transferred from FTP to TCP in the form of
blocks, and each block followed by a 3-byte header. The first byte of the block contains
the information about the block so it is known as the description block and the other
two bytes contain the size of the block.
3. Compressed Mode: This mode is used to transfer big files. As we know that, due to
the size limit we can not transfer big files on the internet, so the compressed mode is
used to decrease the size of the file into small and send it on the internet.
Advantages
1. Multiple transfers: FTP helps to transfer multiple large files in between the systems.
2. Efficiency: FTP helps to organize files in an efficient manner and transfer them
efficiently over the network.
3. Security: FTP provides access to any user only through user ID and password.
Moreover, the server can create multiple levels of access.
4. Continuous transfer: If the transfer of the file is interrupted by any means, then the
user can resume the file transfer whenever the connection is established.
5. Simple: FTP is very simple to implement and use, thus it is a widely used connection.
6. Speed: It is the fastest way to transfer files from one computer to another.
Disadvantages
1. Less security: FTP does not provide an encryption facility when transferring files.
Moreover, the username and passwords are in plain text and not a combination of
symbols, digits, and alphabets, which makes it easier to be attacked by hackers.
2. Old technology: FTP is one of the oldest protocols and thus it uses multiple TCP/IP
connections to transfer files. These connections are hindered by firewalls.
3. Virus: The FTP connection is difficult to be scanned for viruses, which again increases
the risk of vulnerability.
4. Limited: The FTP provides very limited user permission and mobile device access.
5. Memory and programming: FTP requires more memory and programming efforts,
as it is very difficult to find errors without the commands.
Applications
The following are the applications of FTP:
1. FTP connection is used by different big business organizations for transferring files
in between them, like sharing files to other employees working at different locations
or different branches of the organization.
2. FTP connection is used by IT companies to provide backup files at disaster recovery
sites.
3. Financial services use FTP connections to securely transfer financial documents to
the respective company, organization, or government.
4. Employees use FTP connections to share any data with their co-workers.
36
Questions and Answers:-
Question
Question Answer
No.
FTP is used to transfer files between
What is the primary computers over a network. It allows
1
purpose of FTP? uploading, downloading, and managing files
on remote servers.
What are the default Port 21 is used for control (command), and
2 port numbers used by Port 20 is used for data transfer (in active
FTP? mode).
In active mode, the server opens the data
What is the difference
connection. In passive mode, the client
3 between active and
initiates both control and data connections,
passive FTP modes?
making it firewall-friendly.
Which command is
4 used to upload a file to The PUT command is used to upload files.
the server in FTP?
FTP itself is not secure. FTPS (uses SSL/TLS)
How does FTP ensure
5 and SFTP (uses SSH) are secure alternatives
secure file transfers?
for encrypted data transfers.
37
Practical - 11
Aim:-Create a socket for HTTP for web page upload and download.
Introduction:
In this practical, we will be creating a client-server application to upload and download images
using sockets. The client will read an image file from the disk, send it to the server via a socket
connection, and the server will receive and display the image. The communication is done
using the TCP protocol.
Client Side Code:
The client reads an image from the local disk, converts it into byte format, and sends it to the
server over a socket connection. The following code demonstrates the client-side
implementation:
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.OutputStream;
import java.net.Socket;
try {
System.out.println("Reading image from disk.");
38
img = ImageIO.read(new File("C:\\Users\\sachi\\Desktop\\save.jpeg"));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(img, "jpg", baos);
baos.flush();
byte[] bytes = baos.toByteArray();
baos.close();
dos.close();
out.close();
} catch (Exception e) {
System.out.println("Exception: " + e.getMessage());
soc.close();
}
soc.close();
}
}
Server Side Code:
The server listens on a specified port for incoming connections. Upon receiving a connection,
it reads the incoming image data and displays it in a graphical window.
import java.net.*;
import java.io.*;
import java.awt.image.*;
39
import javax.imageio.*;
import javax.swing.*;
40
// Display the image in a window
JFrame f = new JFrame("Server");
ImageIcon icon = new ImageIcon(bImage);
JLabel l = new JLabel();
l.setIcon(icon);
f.add(l);
f.pack();
f.setVisible(true);
}
}
Explanation:
• Client Side: The client reads an image from the disk using ImageIO.read() and converts
it into a byte array using ByteArrayOutputStream. The byte array is then sent to the
server through the socket connection.
• Server Side: The server listens for incoming connections. Once connected, it reads the
image size and data, then displays it using ImageIO.read() and JFrame.
Output:-
41
Questions and Answers:
No. Question Answer
What does the server do when it The server reads the image data, converts it into a
4
receives the image data? BufferedImage, and then displays it in a JFrame.
42
No. Question Answer
43
Practical - 12
Aim:-Study of TCP/UDP performance.
Introduction:
TCP (Transmission Control Protocol): TCP is a connection-oriented transport layer protocol
that facilitates the transmission of data packets from the source to the destination. TCP ensures
reliable communication by establishing a connection between the source and destination before
transmitting data. It divides the data into packets, numbers them, and transmits them to the
destination. The receiver reassembles the packets and sends them to the application layer. The
connection remains established until the entire communication is completed.
UDP (User Datagram Protocol): UDP is a connectionless protocol in the transport layer. It is
known for its simplicity and speed, but it does not guarantee reliability. Unlike TCP, UDP does
not establish a connection or wait for acknowledgements. It is used for time-sensitive
applications where speed is more important than reliability, such as real-time video streaming,
VoIP, etc. While UDP provides basic error-checking, it does not address other issues such as
packet loss or out-of-order delivery.
Ordering of Data
Guarantees ordered packet delivery No fixed order of packets
Packets
44
Basis of Comparison TCP UDP
Unreliable, no guarantee of
Reliability Reliable, guarantees data delivery
delivery
Header Size 20-80 bytes variable length header 8 bytes fixed length header
Why is TCP considered TCP is reliable because it ensures data delivery using
2
reliable? acknowledgment, error checking, and flow control.
45
No. Question Answer
Can UDP guarantee No, UDP does not guarantee packet delivery, and packets may
6
packet delivery? be lost or arrive out of order.
How does TCP handle TCP handles lost or corrupted data by using acknowledgment
7
lost or corrupted data? and retransmission mechanisms, ensuring reliable delivery.
46
Practical-13
Aim:- To simulate the working of ARP (Address Resolution Protocol) and RARP
(Reverse Address Resolution Protocol) protocols using Java.
Objective:
The ARP protocol is used to map a known IP address to a MAC (Physical) address in a local
network, while RARP maps a MAC address to an IP address. In this practical, we will
implement ARP using client-server programming.
Explanation:
• Client Side: The client will send an IP address to the server, and the server will return
the corresponding MAC address.
• Server Side: The server will listen for requests from the client, check the IP address,
and send the corresponding MAC address.
1. Client Side Code (Java):
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.net.Socket;
class Client {
public static void main(String args[]) {
try {
BufferedReader in = new BufferedReader(new
InputStreamReader(System.in));
Socket clientSocket = new Socket("127.0.0.1", 5604); // Connect to server on
localhost, port 5604
DataInputStream din = new DataInputStream(clientSocket.getInputStream());
DataOutputStream dout = new
DataOutputStream(clientSocket.getOutputStream());
47
System.out.println(e);
}
}
}
Explanation of Client Code:
• The client establishes a socket connection to the server at IP 127.0.0.1 and port 5604.
• It prompts the user to enter a logical address (IP address) and sends it to the server.
• The server responds with the corresponding MAC address, which the client displays on
the console.
class ServerARP {
public static void main(String args[]) {
try {
ServerSocket serverSocket = new ServerSocket(5604); // Server listens on port 5604
Socket clientSocket = serverSocket.accept(); // Accept client connection
while (true) {
DataInputStream din = new DataInputStream(clientSocket.getInputStream());
DataOutputStream dout = new
DataOutputStream(clientSocket.getOutputStream());
48
// Check if the IP address matches and return the corresponding MAC address
for (int i = 0; i < ipAddresses.length; i++) {
if (requestedIP.equals(ipAddresses[i])) {
dout.writeBytes(macAddresses[i] + '\n'); // Send the MAC address to the client
break;
}
}
}
} catch (Exception e) {
System.out.println(e);
}
}
}
Explanation of Server Code:
• The server listens for incoming connections on port 5604.
• Once a client connects, the server reads the requested IP address from the client.
• The server checks the IP address against a predefined list of IPs and their corresponding
MAC addresses.
• If a match is found, the server sends the corresponding MAC address back to the client.
Working:
1. Client Side:
o The client enters an IP address.
o The client sends the IP address to the server and waits for a response.
o The client displays the corresponding MAC address received from the server.
2. Server Side:
o The server waits for incoming requests from clients.
o Upon receiving an IP address, the server checks it against a list of predefined
IP-MAC pairs.
o The server sends the corresponding MAC address back to the client.
49
Output:-
What is the purpose of RARP allows a device to discover its IP address when it knows
4
RARP? only its MAC address.
50
Practical-14
Aim:To study and compare the performance of various Media Access
Control (MAC) protocols, specifically focusing on ALOHA, CSMA, and
CSMA/CD.
Theory:
The Media Access Control (MAC) sub-layer is part of the Data Link Layer in the OSI model.
It is responsible for managing how devices access the shared communication medium and how
data is transmitted without collision. The MAC layer is critical in controlling access to a
network, ensuring efficient communication by managing transmission and collision detection.
In shared communication networks, multiple nodes might transmit simultaneously, leading to
collisions. MAC protocols define how nodes should behave to avoid these collisions.
The MAC sub-layer has two primary functions:
1. Data Encapsulation: Ensuring correct frame assembly before transmission.
2. Media Access Control: Coordinating transmission initiation and collision recovery.
The following MAC protocols are commonly used:
1. ALOHA (Areal Location of Hawaiian Access):
• ALOHA was developed in the 1970s at the University of Hawaii for coordinating
access to a shared communication channel.
• In ALOHA, a node transmits whenever it has data to send. If a collision occurs (when
two nodes transmit simultaneously), the data is lost. Nodes listen to the channel to
determine if their transmission was successful and retransmit after a random delay if
necessary.
2. CSMA (Carrier Sense Multiple Access):
• CSMA is a method used in shared network topologies like Ethernet. Devices "sense"
the channel before transmitting. If the channel is free, they transmit; otherwise, they
wait.
• While CSMA reduces the likelihood of collisions, it does not eliminate them
completely.
3. CSMA/CD (Carrier Sense Multiple Access with Collision Detection):
• CSMA/CD is an enhancement of CSMA used in Ethernet networks. If two devices
transmit at the same time, a collision occurs. CSMA/CD detects the collision, stops
transmission, waits for a random time, and then retransmits the data.
• CSMA/CD performs well under moderate traffic but suffers from performance
degradation under heavy traffic due to frequent collisions.
51
Observations:
• Collision Rate: Measure how often collisions occur in each protocol.
• Throughput: The amount of data successfully transmitted across the network.
• Network Efficiency: The percentage of the network's total capacity used for successful
transmission.
Conclusion:
Based on the study, the following conclusions can be drawn:
• ALOHA is simple but inefficient due to high collision rates and poor throughput.
• CSMA performs better than ALOHA but still suffers from collisions and performance
degradation under heavy traffic.
• CSMA/CD is the most efficient protocol under normal conditions, with good collision
detection and recovery. However, its performance decreases significantly under heavy
network traffic.
What is the role of the Media Access The MAC layer controls access to the shared
1 Control (MAC) layer in a network, medium, preventing collisions and ensuring
and why is it essential? efficient data transmission.
Explain the difference between ALOHA transmits without checking the channel,
2 ALOHA and CSMA in terms of leading to collisions, while CSMA listens to the
collision handling. channel before transmitting to avoid collisions.
How does CSMA reduce the CSMA senses the channel before transmitting,
5 likelihood of collisions compared to reducing the chance of collisions, unlike
ALOHA? ALOHA, which transmits anytime.
52
S.no. Conceptual Question Answer
What factors determine the efficiency Efficiency depends on collision handling and
7 of a MAC protocol, and how do these channel access. Higher traffic increases
factors vary with traffic load? collisions, reducing efficiency.
53
Pracrical-15
Aim:-To study the performance comparison of different routing protocols used in
computer networks.
Introduction:
A routing protocol specifies how routers communicate with each other to select routes
between any two nodes in a computer network. These protocols enable routers to share
information about the network topology, helping them make decisions about the best paths for
data transmission. A routing algorithm determines the specific route a packet will follow from
the source to the destination. Each router only has knowledge of its directly connected network,
and it shares this information with neighboring routers, gradually disseminating the topology
information throughout the entire network.
There are three major classes of routing protocols commonly used in IP networks:
1. Interior Gateway Protocols (IGPs):
o Link-state routing protocols, such as OSPF (Open Shortest Path First).
o Distance-vector routing protocols, such as RIP (Routing Information
Protocol), RIPv2, and IGRP (Interior Gateway Routing Protocol).
2. Exterior Gateway Protocols (EGPs):
o Used for exchanging routing information between Autonomous Systems (AS)
on the internet, such as BGP (Border Gateway Protocol).
54
2. Link-State Routing Protocols:
In link-state routing, each router builds and maintains a complete topology map of the entire
internetwork (or at least the partition to which the router is attached). Routers only send updates
when there is a change in the network topology. These updates are event-driven, reducing
bandwidth usage.
Link-state protocols use the Dijkstra algorithm to calculate the shortest path to any destination.
Key Points:
• Uses the Dijkstra algorithm for calculating the shortest path.
• Each router has complete knowledge of the network's topology.
• OSPF (Open Shortest Path First) and BGP (Border Gateway Protocol) are examples of
link-state protocols.
• Requires more CPU and memory compared to distance-vector protocols, as routers
must store the entire network's topology.
• Typically faster convergence but with higher processing overhead.
55
Updat Suppor
Protoc Algorith Convergen Classle Administrat
Type Metric e ts
ol m ce ss ive Distance
Timer VLSM
Distan 30
Bellman-
RIPv1 ce Hop Count Slow secon No No 120
Ford
Vector ds
Distan 30
Bellman-
RIPv2 ce Hop Count Slow secon Yes Yes 120
Ford
Vector ds
Distan 90
Bandwidth/De Bellman-
IGRP ce Slow secon No No 100
lay Ford
Vector ds
Chang
90 (internal),
EIGR Bandwidth/De e
Hybrid DUAL Very Fast Yes Yes 170
P lay occurs
(external)
only
Chang
Link- e
OSPF Cost Dijkstra Fast Yes Yes 110
State occurs
only
Chang
Link- e
IS-IS Cost Dijkstra Fast Yes Yes 115
State occurs
only
Chang
20 (internal),
Path Multiple e
BGP Best Path Average Yes Yes 200
Vector Attributes occurs
(external)
only
56
S.No. Question Answer
Why do link-state protocols require Link-state requires storing the entire network
3
more resources? topology, demanding more CPU and memory.
Purpose of the Dijkstra algorithm in It calculates the shortest path from the source to all
4
link-state protocols? other routers in the network.
57