0% found this document useful (0 votes)
3 views19 pages

DPCN

The document outlines a series of practical exercises for a Computer Networks Lab course, focusing on various networking devices such as hubs, switches, routers, and gateways, as well as hardware configuration and network simulation using Cisco Packet Tracer. It includes detailed objectives, theoretical explanations, and procedures for hands-on activities, including the implementation of protocols like ARQ and ARP/RARP. Each practical session is designed to enhance understanding of network functionality and device configuration.

Uploaded by

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

DPCN

The document outlines a series of practical exercises for a Computer Networks Lab course, focusing on various networking devices such as hubs, switches, routers, and gateways, as well as hardware configuration and network simulation using Cisco Packet Tracer. It includes detailed objectives, theoretical explanations, and procedures for hands-on activities, including the implementation of protocols like ARQ and ARP/RARP. Each practical session is designed to enhance understanding of network functionality and device configuration.

Uploaded by

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

Computer Networks Lab

BCS653

PRACTICAL-1
Date:06-02-2026
Objective: To study different Network devices (Hub, Switch, Router and Gateway) in
detail.
Hub:- A hub is a very basic networking device that simply connects multiple cables or
computers together. It operates only at the physical layer (Layer 1) of the OSI model,
meaning it does not perform any signal processing or intelligent decision-making. Its main
job is to forward electrical signals, acting as a central point where all devices in a network
can plug in.
When a signal enters one port, the hub sends that signal out to all other connected ports
except the one it came from. This broadcasting behaviour is why a hub is often compared to a
repeater. However, unlike switches or routers, hubs cannot understand or manage data at the
data link (Layer 2) or network (Layer 3) levels, making them less efficient for handling
complex communication tasks.

Figure 1: Hub

Switch:- A switch is a device that helps computers in a network talk directly to each other. It
works at the data link layer (Layer 2) of the OSI model and uses something called a switching
table to figure out exactly where to send the data. Unlike a hub, which sends signals
everywhere, a switch makes sure the information goes only to the right computer.
Switches can start and stop connections depending on what is needed at that moment. They
also have useful features such as flooding (sending data to all devices when the destination is
unknown), filtering (blocking unnecessary traffic), and frame transmission (delivering data
correctly to the intended device). This makes them much more reliable and faster than basic
devices like hubs.

Figure 2: Switch

2304221520022 1
Computer Networks Lab
BCS653

Router:- A router is a device with multiple ports that is more advanced than repeaters and
bridges. It uses a routing table to decide the best path for sending data from one computer to
another. This means it can choose between several possible routes and pick the most suitable
one for each transmission, making communication faster and more efficient.
Routers work at the network layer (Layer 3) of the OSI model. They are commonly used in
LANs, MANs, and WANs to connect different networks together. A router stores and
manages IP addresses on its own, which allows it to keep track of devices and direct data
correctly without needing extra help.

Figure 3: Router

Gateway:- A gateway is a device that connects two networks that use different setups or
rules. Because the networks may not “speak the same language,” the gateway acts as a
protocol converter, changing the data format so both sides can understand each other. This
makes communication between different types of networks smooth and possible.
It also works as the entry and exit point of a network, meaning all data going in or out must
pass through the gateway. While doing this, it keeps track of and controls the flow of traffic,
ensuring that only the right information gets through. In short, a gateway manages
communication between unlike networks and makes sure everything moves safely and
correctly.

Figure 4: Gateway

2304221520022 2
Computer Networks Lab
BCS653

PRACTICAL-2
Date:13-02-2026
Objective: To learn handling and configuration of networking hardware like RJ45
connecter, CAT-6 cable, Crimping Tool and LAN tester.

RJ45 Connector: RJ45 means Registered Jack 45 and is the most common connector used in
wired computer networks. It was first designed for telephones but is now widely used in
Ethernet LAN connections. The “45” is simply its listing number. RJ45 connectors are wider
than telephone jacks and can carry much more data.
These connectors can support speeds up to 10 Gbps, which makes them fast and secure for
linking computers to servers, routers, and other devices. They are mostly used in star
topology networks, where each computer connects to a central hub or switch. Because of
their speed and reliability, RJ45 connectors are the standard choice for modern wired
networking.

Figure 1: RJ45 Connector

CAT-6 Cable: Category 6 (Cat6) cable is a type of Ethernet or LAN cable made of four
twisted copper pairs inside a protective cover. It supports data speeds up to 1 Gbps, which
makes it suitable for quickly transferring large files in office or home networks. Cat6 works
with standards like 10BASE-T, 100BASE-TX, and Gigabit Ethernet, and it is also
backward-compatible with older cables such as Cat5/5E and Cat3.
Each end of a Cat6 cable usually has an RJ45 connector (8P8C) that links two devices
together. To get the best performance, the connectors used must meet the Cat6 rating.
Because of its speed and reliability, Cat6 is widely used in modern networking setups.

Figure 2: CAT-6 Cable

2304221520022 3
Computer Networks Lab
BCS653

Crimping Tool: A crimping tool is a handheld device used to join, terminate, or connect
electrical wires and cables by deforming a metal connector (lug, terminal, or RJ45) onto the
wire through intense pressure. This "cold weld" process ensures a secure, reliable, and
durable connection without soldering, often creating a gas-tight bond that resists corrosion
and vibrations.

Figure 3: Crimping Tool

How does Crimping Tool work? To use this crimping tool, each wire is first placed into the
connector. Then, the connector with wires are placed into the crimping tool, and the handles
are squeezed together. Crimping punctures the plastic connector and holds each of the wires,
allowing data to transmit through the connector.

LAN Tester : A LAN tester is an electronic, handheld tool designed to check the
connectivity, continuity, and configuration of LAN (Local Area Network) cables, typically
CAT5/CAT6 (RJ45) and telephone (RJ11) wires. It verifies if wires are properly mapped,
identifies broken cables, shorts, or miswires, and helps technicians troubleshoot network
faults quickly.

Figure 2: LAN Tester

2304221520022 4
Computer Networks Lab
BCS653

PRACTICAL-3
Date:06-02-2026
Objective: To study different Network devices (Hub, Switch, Router and Gateway) in
detail.

2304221520022 5
Computer Networks Lab
BCS653

2304221520022 6
Computer Networks Lab
BCS653

2304221520022 7
Computer Networks Lab
BCS653

PRACTICAL-4
Date:20-03-2026
Objective: To design and simulate a network using CISCO Packet Tracer where two IP
network are connected.
Theory
Two IP networks represent separate broadcast domains requiring Layer 3 routing for
intercommunication. Routers connect LAN1 and LAN2 via FastEthernet interfaces acting as
gateways. PCs within each LAN use switches for Layer 2 switching but send cross-subnet
traffic to their default gateway. Cisco Packet Tracer visualizes packet flow showing ARP
resolution and routing table lookups. The simulation verifies connectivity via ping tests
confirming proper IP addressing, subnet masks, and interface status (up/up)

Procedure:
Step 1: Open Cisco Packet Tracer
1. Launch Cisco Packet Tracer application.
2. Select File  New to Create a new workspace.

Step 2: Add Network Devices


1. From bottom-left panel, Select End Devices.
2. Drag 4 PCs into workspace.
3. Now select Network Devices  Switches and Router
4. Drag 2 Switches (2960) into the workspace.
5. Now select Routers.
6. Drag 1 Router (1841) into the centre.

Fig.1: All devices placed on the workspace


Step 3: Connect the Devices
1. Click on Connections.
2. Select Copper Straight-Through Cable.
3. Connect:
Network 1

• PC0 → Switch0 (FastEthernet0/1)


• PC1 → Switch0 (FastEthernet0/2)
• Switch0 → Router (FastEthernet0/0)
Network 2
• PC2 → Switch1 (FastEthernet0/1)
2304221520022 8
Computer Networks Lab
BCS653

• PC3 → Switch1 (FastEthernet0/2)


• Switch1 → Router (FastEthernet0/1)
Now network forms two different networks connected via router.

Fig.2: Connection of two networks using router


Step 4: Configure IP Addresses
1. Click on each PC and configure IP addresses.
2. Go to: Desktop → IP Configuration

Device IP Address Subnet Mask Default Gateway


PC0 [Link] [Link] [Link]
PC1 [Link] [Link] [Link]
PC2 [Link] [Link] [Link]
PC3 [Link] [Link] [Link]

Fig.3: IP address configuration of PCs


Step 5: Configure Router
1. Click on the Router.
2. Go to the Config tab.
Configure Interface for Network 1
3. In the left panel, select FastEthernet0/0.
4. Turn Port Status → ON.
5. In IP Configuration.
 IPv4 Address: [Link]
 Subnet Mask: [Link]

2304221520022 9
Computer Networks Lab
BCS653

Configure Interface for Network 2


6. In the left panel, select FastEthernet0/1.
7. Turn Port Status → ON.
8. In IP Configuration:
 IPv4 Address: [Link]
 Subnet Mask: [Link]

2304221520022 10
Computer Networks Lab
BCS653

Step 6: Verify Connectivity


1. Click on PC0
2. Open Desktop → Command Prompt
3. Type: ping [Link]

If replies are received, the network is successfully configured.


Similarly, test from other PCs.

Fig.4: Network connectivity test using ping command

2304221520022 11
Computer Networks Lab
BCS653

PRACTICAL-5
Date:03-04-2026
Objective: To implement stop and wait ARQ Protocol.

[Link]

import [Link].*;
import [Link].*;
public class Sender {
Socket sender;
ObjectOutputStream out;
ObjectInputStream in;
String packet, ack, str, msg;
int n, i = 0, sequence = 0;
Sender() {
}
public void run() {
try {
BufferedReader br = new BufferedReader(new InputStreamReader([Link]));
[Link]("Waiting for Connection....");
sender = new Socket("localhost", 2005);
sequence = 0;
out = new ObjectOutputStream([Link]());
[Link]();
in = new ObjectInputStream([Link]());
str = (String) [Link]();
[Link]("Receiver > " + str);
[Link]("Enter the data to send....");
packet = [Link]();
n = [Link]();
do {
try {
if (i < n) {
msg = [Link](sequence);
msg = [Link]([Link](i, i + 1));
} else if (i == n) {
msg = "end";
[Link](msg);
[Link]();
break;
} else {
break;
}
[Link](msg);
[Link]();
[Link]("Data sent > " + msg);
ack = (String) [Link]();
[Link]("Waiting for ack.....\n");
sequence = (sequence == 0) ? 1 : 0;
if ([Link]([Link](sequence))) {
2304221520022 12
Computer Networks Lab
BCS653

i++;
[Link]("Receiver > Packet received\n");
} else {
[Link]("Time out, resending data....\n");
sequence = (sequence == 0) ? 1 : 0;
}
} catch (Exception e) {
[Link]("Error while sending packet: " + [Link]());
}
} while (i < n + 1);
[Link]("All data sent. Exiting.");
} catch (Exception e) {
[Link]("Connection error: " + [Link]());
} finally {
try {
if (in != null) [Link]();
if (out != null) [Link]();
if (sender != null) [Link]();
} catch (Exception e) {
[Link]("Error while closing resources: " + [Link]());
}
}
}
public static void main(String[] args) {
Sender s = new Sender();
[Link]();
}
}

[Link]

import [Link].*;
import [Link].*;
public class Receiver {
ServerSocket reciever;
Socket connection = null;
ObjectOutputStream out;
ObjectInputStream in;
String packet, ack, data = "";
int i = 0, sequence = 0;
Receiver() {
}
public void run() {
try {
BufferedReader br = new BufferedReader(new InputStreamReader([Link]));
reciever = new ServerSocket(2005, 10);
[Link]("waiting for connection...");
connection = [Link]();
sequence = 0;
[Link]("Connection established :");

2304221520022 13
Computer Networks Lab
BCS653

out = new ObjectOutputStream([Link]());


[Link]();
in = new ObjectInputStream([Link]());
[Link]("connected .");
do {
try {
packet = (String) [Link]();
if ([Link]("end")) {
break;
}
if ([Link]([Link](0, 1)) == sequence) {
data += [Link](1);
sequence = (sequence == 0) ? 1 : 0;
[Link]("\n\nreceiver >" + packet);
} else {
[Link]("\n\nreceiver >" + packet + " duplicate data");
}
if (i < 3) {
[Link]([Link](sequence));
i++;
} else {
[Link]([Link]((sequence + 1) % 2));
i = 0;
}
[Link]();
} catch (Exception e) {
}
} while (![Link]("end"));
[Link]("Data recived=" + data);
[Link]("connection ended .");
[Link]();
} catch (Exception e) {
} finally {
try {
[Link]();
[Link]();
[Link]();
} catch (Exception e) {
}
}
}
public static void main(String args[]) {
Receiver s = new Receiver();
while (true) {
[Link]();
}
}
}

2304221520022 14
Computer Networks Lab
BCS653

OUTPUT

2304221520022 15
Computer Networks Lab
BCS653

PRACTICAL-6
Date:10-04-2026
Objective: Write a code simulating ARP/RARP Protocol.

[Link]

import [Link].*;
import [Link].*;
class Clientarp {
public static void main(String args[]) {
try {
BufferedReader in = new BufferedReader(
new InputStreamReader([Link])
);
Socket clsct = new Socket("[Link]", 5604);
BufferedReader din = new BufferedReader(
new InputStreamReader([Link]())
);
DataOutputStream dout = new DataOutputStream(
[Link]()
);
[Link]("Enter the Logical address(IP):");
String str1 = [Link]();
[Link](str1 + "\n");
String str = [Link]();
[Link]("The Physical Address is: " + str);
[Link]();
} catch (Exception e) {
[Link](e);
}
}
}

[Link]

import [Link].*;
import [Link].*;
class Serverarp {
public static void main(String args[]) {
try {
ServerSocket obj = new ServerSocket(5604);
[Link]("Server started...");
Socket obj1 = [Link]();
[Link]("Client connected");
BufferedReader br = new BufferedReader(
new InputStreamReader([Link]())
);
DataOutputStream dout = new DataOutputStream(
[Link]()

2304221520022 16
Computer Networks Lab
BCS653

);
String ip[] = {"[Link]","[Link]"};
String mac[] = {"6A:08:AA:C2","8A:BC:E3:FA"};
while(true) {
String str = [Link]();
if(str == null) {
[Link]("Client disconnected");
break;
}
boolean found = false;
for(int i = 0; i < [Link]; i++) {
if([Link](ip[i])) {
[Link](mac[i] + "\n");
found = true;
break;
}
}
if(!found) {
[Link]("IP not found\n");
}
}
[Link]();
[Link]();
} catch(Exception e) {
[Link](e);
}
}
}
OUTPUT

2304221520022 17
Computer Networks Lab
BCS653

PRACTICAL-7
Date:17-04-2026
Objective: Write a code simulating Ping and Traceroute command.

[Link]

import [Link].*;
import [Link].*;
class PingServer {
public static void main(String args[]) {
try {
[Link]("Enter the IP Address to Ping: ");
BufferedReader buf1 = new BufferedReader(new InputStreamReader([Link]));
String ip = [Link]();
if (ip == null || [Link]()) {
[Link]("Invalid IP address");
return;
}
Runtime H = [Link]();
String os = [Link]("[Link]").toLowerCase();
Process p;
if ([Link]("win")) {
p = [Link]("ping " + ip);
} else {
p = [Link]("ping -c 4 " + ip);
}
BufferedReader buf2 = new BufferedReader(
new InputStreamReader([Link]()));
String str;
while ((str = [Link]()) != null) {
[Link](str);
}
[Link]();
[Link]();
} catch (Exception e) {
[Link]([Link]());
}
}
}

[Link]

import [Link].*;
public class TracerouteCmd {
public static void runSystemCommand(String command) {
try {
Process p = [Link]().exec(command);
BufferedReader inputStream = new BufferedReader(
new InputStreamReader([Link]()));

2304221520022 18
Computer Networks Lab
BCS653

String s;
while ((s = [Link]()) != null) {
[Link](s);
}
[Link]();
} catch (Exception e) {
[Link]([Link]());
}
}
public static void main(String[] args) {
try {
BufferedReader br = new BufferedReader(
new InputStreamReader([Link]));
[Link]("Enter host: ");
String ip = [Link]();
String os = [Link]("[Link]").toLowerCase();
if ([Link]("win")) {
runSystemCommand("tracert " + ip);
} else {
runSystemCommand("traceroute " + ip);
}
} catch (Exception e) {
[Link]([Link]());
}
}
}

OUTPUT

2304221520022 19

You might also like