Computer Networks Practical File Taruna Gupta 22BCE11551
Computer Networks Practical File Taruna Gupta 22BCE11551
Bhopal-Indore Highway
Kothrikalan,
Sehore,
Madhya Pradesh - 466114
Submitted By
Taruna Gupta
Reg No: 22BCE11551
Submitted to
Dr. M. Manimaran,
Senior Assistant Professor,
NETWORKS is my original work and has been completed under the guidance of
I affirm that this record has not been submitted elsewhere and complies with the rules and
Faculty Signature
Index
9
3 07/02/2025 To study various types of Connectors
12
4 14/02/2025 LAN installations and their Configuration
34
10 04/04/2025 To study various TCL commands.
36
The message entered in the client is sent to the server and the
11 11/04/2025 server encodes the message and returns it to the client. Encoding is
done by replacing a character by the character next to it (i.e.) a as
b, b as c…z as a.
AIM:
ALGORITHM:
1) Start
2) Create Devices with name, MAC address, and IP address.
3) Hub Function:
a) Connect devices.
b) On data send → broadcast to all devices except sender.
4) Switch Function:
a) Store MAC addresses of connected devices.
b) On data send → forward only to device with matching MAC.
5) Router Function:
a) Store IP addresses of connected devices.
b) On data send → route to the device with matching IP.
6) Access Point Function:
a) Connect devices wirelessly.
b) On data send → share with all connected devices.
7) Modem Function:
a) Transmit: Convert data to binary (simulate analog signal).
b) Receive: Convert binary back to original data.
8) Display Results of sending and receiving through each device.
9) End
PROGRAM:
class Device:
def __init__(self, name, mac, ip=None):
self.name = name
self.mac = mac
self.ip = ip
OUTPUT:
Successfully connect a modem, router, and switch to establish a wired and wireless
network.
Use tools like ping, tracert, and Wireshark to diagnose network problems.
AIM:
ALGORITHM:
If error occurs:
The aim of this experiment is to establish a peer-to-peer connection between two computers using
a network simulation tool (Cisco Packet Tracer) and identify their IP addresses, MAC addresses,
and observe packet transfer between the end devices.
PROCEDURE:
44
1. Set up network simulation tool and create a virtual network environment.
2. Add two computer to the network topology and establish connection between the two computer
using Ethernet cables or virtual connections.
3. Assign IP addresses to each computer in the same subnet.
4. Use various commands to identify and note down the MAC addresses of both computers.
5. Configure the network settings of each computer to ensure they can communicate with each
other.
6. Monitor andobserve the packet transfer between the end devices.
7. Analyze the network traffic to identify the IP addresses, and successful packet transfers.
DESCRIPTION:
In computer networks, a peer-to-peer connection refers to a direct communication link between the
devices without the need for an intermediary server. IP addresses are unique numerical identifiers
assigned to each device on a network, allowing them to send and receive data. MAC addresses are
physical addresses that are permanently assigned to network interface cards (NICs) and serve as
unique identifiers at the data link layer
PROGRAM:
Commands Used:
• ipconfig
• ipconfig /all
• ping
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
try {
// MySQL Connector
System.out.println("Connecting to MySQL...");
Connection mysqlConn = DriverManager.getConnection(mysqlUrl, mysqlUser,
mysqlPass);
Statement mysqlStmt = mysqlConn.createStatement();
ResultSet mysqlRs = mysqlStmt.executeQuery("SELECT * FROM users");
while (mysqlRs.next()) {
System.out.println("MySQL User: " + mysqlRs.getString("username"));
}
mysqlConn.close();
// SQLite Connector
System.out.println("\nConnecting to SQLite...");
Connection sqliteConn = DriverManager.getConnection(sqliteUrl);
Statement sqliteStmt = sqliteConn.createStatement();
ResultSet sqliteRs = sqliteStmt.executeQuery("SELECT * FROM users");
while (sqliteRs.next()) {
System.out.println("SQLite User: " + sqliteRs.getString("username"));
}
sqliteConn.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
OBSERVATION:
OUTPUT:
3. Ipconfig on PC0-
4. Ipconfig on PC1-
9. Packet Transfer-
RESULT:
Based on the observations made during the experiment, the following conclusions can be drawn:
• The network simulation tool effectively facilitated the establishment of a peer-to-peer
connection between two computers.
• The IP addresses assigned to the computers allowed them to communicate with each other
within the same subnet.
• The MAC addresses uniquely identified each computer at the data link layer.
• The successful packet transfers confirmed the successful communication between the two
computers.
• This experiment provided a practical understanding of network connectivity. IP addressing,
MAC addressing and packet transfer in a simulated network environment.
AIM:
THEORY:
A Local Area Network (LAN) is a network that connects multiple devices within a limited area,
such as a home, office, or school. LAN installation involves hardware setup, configuration, and
security measures to ensure efficient communication between device.
PROCEDURES:
If you are connecting four or fewer computers, you'll just need a single router, or
one switch if you don't need internet.
If you're connecting more than four computers, you'll want a router and a switch,
or just a switch if you don't need internet.
Obtain the network hardware. To create a LAN, you'll need a router and/or a network. These
pieces of hardware are the "hub" of your LAN, and all of your computers will be connected to
them.
Connect your modem to the WAN port on the router. This port may be labeled "INTERNET"
instead. This will provide internet access to every computer that is connected to your LAN.
You can skip this if you're setting up a LAN without internet access.You don't need a router at all
to create a LAN, but it makes things easier. If you just use a network switch, you'll need to
manually assign IP addresses to each computer after connecting them.
Connect the switch to a LAN port on the router. If you're using a network switch to
connect more computers, connect it to one of the LAN ports on the router. You can
use any open port on the switch to make the connection. When connected, the router
will provide IP addresses for every computer that is connected to either device.
Configuration:
network icon in your task bar. If you are connecting your computers through a
switch with no router, you'll need to assign each computer on the network its own
individual IP address. This process is handled automatically if you're using a
router.[5]
Click next to "IP assignment." You may need to click "Ethernet" first to expand the menu.
Clicking this prompts a window to pop up
Select "Manual" from the drop-down menu.
Toggle IPv4 or IPv6, then edit the text fields. You can enable both or one of the toggles, then
continue with the next steps:
Enter
Enter
Enter
50 into the IP address field.
0 into the Subnet mask field.
0 into the Default gateway fi
Click Save. This will save the settings for that computer.
Open the "Network and Internet" settings on the next computer. Follow the steps
above on the second computer to open the same IP menu in "Ethernet".
Type 192 . 168 . 1 . 51 into the IP address field. Notice that the final group of numbers has
incremented by
Enter the same values for subnet and Gateway. These values should be the same as they were on
the first computer (255.255.0.0 and 192.168.0.0 respectively)
Give each additional computer a unique IP. Repeat these steps for each additional
computer, incrementing the IP address by 1 each time (up to 255). The "Subnet mask"
and "Gateway" fields should be the same on each computer.
LAN INSTALLATION OUTPUTS:
RESULTS:
AIM:
ALGORITHM:
1. Start
2. Input the binary data/message to be transmitted.
3. Display error correction options to the user:
o Parity Bit
o Hamming Code
o Checksum
o CRC
4. User selects one technique.
5. Encode the message using the selected method:
o Parity Bit: Add 1 parity bit based on even/odd parity.
o Hamming Code: Insert redundancy bits at power-of-two positions and calculate
their values.
o Checksum: Divide data into blocks, sum them, and append the checksum.
o CRC: Perform binary division using generator polynomial and append the
remainder (CRC bits).
6. Simulate transmission:
o Optionally introduce an error (flip 1 or more bits).
7. At receiver side:
o Decode the message using the same method.
o Check for errors.
o Correct the error (if applicable, e.g., in Hamming Code).
8. Display results:
o Original message
o Transmitted message
o Received message
o Error detected or corrected (Yes/No)
9. End
PROGRAM:
import java.util.Scanner;
int count = 0;
if (c == '1') count++; }
return count % 2 == 0 ? 0 : 1; }
// 2. Checksum
int sum = 0;
int p2 = d1 ^ d3 ^ d4;
int p3 = d2 ^ d3 ^ d4;
return remainder;}
// 1. Parity
// 2. Checksum
int n = sc.nextInt();
// 3. Hamming Code
// 4. CRC
sc.close();}
OUTPUT:
RESULT:
The program for implementing various error correcting techniques was successfully executed.
Techniques like Hamming Code were applied to detect and correct single-bit errors. The
simulation showed accurate encoding, transmission, error detection, and correction. It verified
the importance of error control in reliable data communication.
Ex. No: 6
To implement various types of DLL protocols.
Date:
AIM:
THEORY:
The Data Link Layer (DLL) is responsible for framing, error detection, and flow control in
networking. Some key protocols used in DLL include:
PROGRAM:
1. Stop-and-wait protocol:
OUTPUT:
RESULT:
The program to implement various types of Data Link Layer (DLL) protocols such as Stop-and-
Wait, Go-Back-N, and Selective Repeat was successfully executed. It demonstrated reliable
frame transmission, acknowledgment handling, and retransmission of lost or corrupted frames.
The simulation confirmed proper flow control and error control mechanisms at the DLL level,
ensuring accurate and orderly data delivery between sender and receiver processes.
Ex. No: 7 Imagine two processes communicate across a network. One process running
in your local system is web browser and the other process running in the
remote system is the web server. Once a connection is established between
Date: the web browser and web server, the server’s current date and time has to be
displayed in
web browser. Write a suitable program for this scenario.
AIM:
Imagine two processes communicate across a network. One process running in your local system
is web browser and the other process running in the remote system is the web server. Once a
connection is established between the web browser and webserver, the server’s current date and
time has to be displayed in web browser. Write a suitable program for this scenario.
ALGORITHM:
PROGRAM:
SERVER CODE:
CLIENT CODE:
#Include <unistd.h>
#include <arpa/inet.h>
// Convert IP address
if (inet_pton(AF_INET,
SERVER_IP,
// Connect to server
if (connect(sock, (struct
sockaddr*)&serv_addr,
return 1;
}
OUTPUT:
RESULT:
The client-server program was successfully executed. A socket-based connection was established
between the web browser and the server. Upon connection, the server fetched its current date and
time and sent it as an HTTP response. The web browser displayed this information correctly.
This demonstrates a basic web communication model using sockets.
Ex. A network communication model is created by establishing connection
d No: 8
between a client and a server. The connection is also guaranteed by
transferring client’s IP address to the server and displays it in the server’s
Date: premises. Write a program for the above situation.
AIM:
ALGORITHM:
1. Create a socket to connect to the server using its IP address and port.
2. Establish the connection.
3. Optionally, send a message (not required for IP display).
4. Close the socket.
PROGRAM:
SERVER CODE:
import java.io.*;
import java.net.*;
public class Server {
public static void main(String[] args) {
try {
ServerSocket serverSocket = new ServerSocket(5000); // Port number
System.out.println("Server started. Waiting for client...");
Socket clientSocket = serverSocket.accept(); // Accept connection
InetAddress clientAddress = clientSocket.getInetAddress(); // Get IP
d
System.out.println("Client connected from IP: " + clientAddress.getHostAddress
// Close connection
clientSocket.close();
serverSocket.close();
} catch (IOException e) {
e.printStackTrace();}}}
CLIENT SIDE:
import java.io.*;
import java.net.*;
// Close connection
socket.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
OUTPUT:
d
RESULT:
The client-server network communication model was successfully implemented using socket
programming. The server was able to:
Establish a connection with the client.
Obtain the client’s IP address using socket functions.
Display the client’s IP address on the server side (server console).
The output was as expected, where the server displayed the connected client’s IP address.
Ex. No: 9 Consider two processes client and server communicates across a network.
The client sends a message to the server in the request and the server
responds with the same message. Write a Socket program for the above
d Date:
mentioned scenario.
AIM:
Consider two processes client and server communicates across a network. The client
sends a message to the server in the request and the server responds with the same
message. Write a Socket program for the above mentioned scenario.
ALGORITHM:
SERVER SIDE:
import java.io.*;
import java.net.*;
// Streams
BufferedReader input = new BufferedReader
PrintWriter output = new PrintWriter(clientSocket.getOutputStream(), true);
// Close connections
input.close();
output.close();
clientSocket.close();
serverSocket.close();
} catch (IOException e) {
e.printStackTrace();}}}
CLIENT SIDE:
import java.io.*;
import java.net.*;
// Streams
BufferedReader userInput = new BufferedReader(new InputStreamReader(System.in));
PrintWriter output = new PrintWriter(socket.getOutputStream(), true);
BufferedReader input = new BufferedReader
// Send message
System.out.print("Enter message to send: ");
String message = userInput.readLine();
output.println(message);
// Close connections
input.close();
output.close();
socket.close();
} catch (IOException e) {
e.printStackTrace();}}}
OUTPUT:
RESULT:
The client-server socket program was successfully implemented and executed. The client sent a
message to the server over the network, and the server responded with the same message,
demonstrating a basic echo communication model.
This program verified that:
Socket creation, connection establishment, and data transmission between client and
server were successful.
Both client and server could send and receive messages reliably.
It confirmed a foundational understanding of network communication using sockets,
which is essential for building more complex distributed systems and applications.
AIM:
To study and demonstrate the use of various TCL commands such as variable declaration,
conditional statements, loops, procedures, and file operations.
ALGORITHM:
PROGRAM:
# Display variables
puts "Name: $name"
puts "Age: $age"
# Conditional Statement
if {$age >= 18} {
puts "Status: Adult"
} else {
puts "Status: Minor"
}
# Loop - For
puts "\nFor loop from 1 to 5:"
for {set i 1} {$i <= 5} {incr i} {
puts "i = $i"
}
# Loop - While
puts "\nWhile loop till i < 3:"
set i 0
while {$i < 3} {
puts "i = $i"
incr i
}
# foreach loop
puts "\nForeach loop:"
foreach item {apple banana mango} {
puts "Fruit: $item"
}
# Procedure
proc greet {person} {
puts "Hello, $person! Welcome to TCL."
}
greet "Taruna"
# File Operations
set filename "sample.txt"
# Write to file
set file [open $filename "w"]
puts $file "This is a TCL file writing example."
close $file
OUTPUT:
RESULT:
The TCL program was successfully executed and demonstrated various commands such as
variable declaration, conditional logic, looping structures, procedure definition, and file
handling. This helped in understanding the core functionality and syntax of TCL scripting.
Ex. No: 11 The message entered in the client is sent to the server and the server encodes
the message and returns it to the client.
Date: Encoding is done by replacing a character by the character next to
it.(i.e.) a as b, b as c…z as a.
AIM:
To implement a client-server communication model where the client sends a message to the
server, and the server encodes the message by replacing each character with the next character in
the alphabet, then returns the encoded message to the client.
ALGORITHM:
Server Side:
Client Side:
PROGRAM:
SERVER CODE:
import java.io.*;
import java.net.*;
input.close();
output.close();
clientSocket.close();
serverSocket.close();
} catch (IOException e) {
e.printStackTrace();
}
}
CLIENT CODE:
import java.io.*;
import java.net.*;
public class Client {
public static void main(String[] args) {
try {
Socket socket = new Socket("localhost", 7000);
System.out.println("Connected to server.");
output.println(message);
String encoded = input.readLine();
output.close();
input.close();
socket.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
OUTPUT:
SERVER TERMINAL:
CLIENT TERMINAL:
Connected to server.
Enter a message: Hello Zebra!
Encoded message from server: Ifmmp Afcsb!
RESULT:
The client-server socket program was successfully implemented. The client sends a message to
the server, the server encodes it by shifting each alphabet character to the next, and the encoded
message is sent back and displayed by the client. The program demonstrated effective socket
communication and basic text encoding.
Ex. No: 12 Packet Tracer: Observing Packets across the network and Performance
Analysis of
Date: Routing protocols
AIM:
To simulate a network using Cisco Packet Tracer, observe packet flow across the network, and
analyze the performance of routing protocols (RIP, OSPF, EIGRP) using packet inspection tools
and simulation mode.
ALGORITHM:
Network Design
Open Cisco Packet Tracer.
Place required network devices (e.g., routers, switches, and PCs).
Connect the devices using appropriate cables.
IP Addressing
Assign IP addresses to all PCs and routers.
Use different subnets for different networks.
Routing Protocol Configuration
Configure static or dynamic routing on routers using:
o RIP using router rip
o OSPF using router ospf
o EIGRP using router eigrp
Advertise the correct networks in each protocol.
Testing Connectivity
Ping between PCs in different networks to verify successful routing.
Packet Inspection
Switch to Simulation Mode in Packet Tracer.
Add a PING packet and observe its journey.
Watch how the routing protocol updates and data packets flow.
Performance Analysis
Compare:
o Convergence time (how fast routes are learned)
o Number of updates exchanged
o Path taken by packets
Use the event list to analyze packet routing behavior.
PROGRAM:
CONFIGURATION:
On Router1:
enable
configure terminal
interface fastEthernet 0/0
ip address 192.168.1.1 255.255.255.0
no shutdown
router ospf 1
network 192.168.1.0 0.0.0.255 area 0
On Router2:
enable
configure terminal
interface fastEthernet 0/0
ip address 192.168.2.1 255.255.255.0
no shutdown
router ospf 1
network 192.168.2.0 0.0.0.255 area 0
OUTPUT:
The network was successfully configured in Packet Tracer. Routing protocols (OSPF in this
case) were correctly implemented and tested. Packet traversal was observed using simulation
mode. Performance parameters like convergence time and routing behavior were analyzed using
event lists and packet flow visualization.