Computer Network Lab File
Computer Network Lab File
UNIVERSITY
COMPUTER NETWORKS
(BCS 6501)
LAB FILE
Session: 2024-2025
Faculty
S.No Name of Experiment Date Remarks
Signature
3
Write a C program to implement Bit Stuffing.
SOFTWARE USED
Cisco Packet Tracer
PROCEDURE
1. Open Cisco Packet Tracer and a default screen will appear on your computer screen.
2. Now, we will select a switch from the shelf. We will drag and drop three or more
end devices from the shelf again and place them near the switch.
3. After placing the switch from the shelf, we will drag and drop the end devices again, go
to the "Connections" section, and select "Copper Straight-Through" wire as the medium
of connection. Connect the devices (PC-0, PC-1, PC-2) to Switch-0.
PC-0 (Fast Ethernet 0) → Switch-0 (Fast Ethernet 0/1)
PC-1 (Fast Ethernet 0) → Switch-0 (Fast Ethernet 0/2)
PC-2 (Fast Ethernet 0) → Switch-0 (Fast Ethernet 0/3)
4. After completing all the steps, the main step is to set IP addresses in all PCs that
are connected to Switch-0. By default, a subnet mask will be allotted.
5. Now check the ping by double-clicking on any end device (PC-0, PC-1, PC-2), go to the
"Desktop" option, and select "IP Configuration." Copy the IP address associated with
that device. Then go to the "Command Prompt" and type:
ping 10.0.0.8
Then press the Enter key.
Output:
LAB- 2
SOFTWARE USED
Cisco Packet Tracer
PROCEDURE
1. Open Cisco Packet Tracer and a blank default screen will appear on your
computer screen.
2. In the configuration, we will begin by selecting and placing two switches (Switch 0 and
Switch 1) from the Packet Tracer shelf. After placing the switches, select and drop some
end devices (PC-0, PC-1, PC-2 connected to Switch 0 and PC-3, PC-4, PC-5 connected to
Switch 1), placing three with each switch.
3. After completing the above step, go again to the Packet Tracer shelf. Under Connections,
select Copper Straight-Through wire and connect:
Switch 0 Configuration
PC-0 (Fast Ethernet 0) → Switch 0 (Fast Ethernet 0/1)
PC-1 (Fast Ethernet 0) → Switch 0 (Fast Ethernet 0/2)
PC-2 (Fast Ethernet 0) → Switch 0 (Fast Ethernet 0/3)
Switch 1 Configuration
PC-3 (Fast Ethernet 0) → Switch 1 (Fast Ethernet 0/1)
PC-4 (Fast Ethernet 0) → Switch 1 (Fast Ethernet 0/2)
PC-5 (Fast Ethernet 0) → Switch 1 (Fast Ethernet 0/3)
4. After connecting all the devices to their respective switches, assign IP addresses
by double-clicking on each end device, going to the Desktop tab, selecting IP
Configuration, and assigning a unique IP address to each device.
5. 5) Now, select a Copper Straight-Through wire from the shelf and connect Switch 0
and Switch 1 to Router 0.
Router 0 Configuration:
Switch 0 (Fast Ethernet 0/4) → Router 0 (Fast Ethernet 0/0)
Switch 1 (Fast Ethernet 0/4) → Router 0 (Fast Ethernet 0/1)
6. To configure the router, double-click on Router 0.
Go to the Config tab, then under the Interface section, select Fast Ethernet 0/0.
Turn the Port Status to ON, and assign it an IP address from the same network as
the devices connected to Switch 0. The Subnet Mask will be added automatically.
7. Repeat the same configuration for Fast Ethernet 0/1, using an IP address from the
network of devices connected to Switch 1.
8. Now assign the Default Gateway to the end devices.
For devices connected to Switch 0, set the Default Gateway as the IP of Router 0 – Fast
Ethernet 0/0.
For devices connected to Switch 1, set the Default Gateway as the IP of Router 0 – Fast
Ethernet 0/1.
9. To test the connection, open the Command Prompt on any end device and type the
ping command to send a message from one device to another across networks.
Example: ping 192.168.1.2
If the reply is received, the configuration is successful.
Output:
LAB- 3
#include <stdio.h>
#include <string.h>
int main() {
char data[100], stuffedData[200];
int i, j = 0, count = 0;
if (data[i] == '1') {
count++;
} else {
count = 0;
}
if (count == 5) {
stuffedData[j++] = '0'; // Bit stuffing: insert a 0 after five 1s
count = 0;
}
}
return 0;
}
Output:
int main() {
char data[100], stuffedData[200];
char flag[] = "F";
char esc[] = "E";
int i, j = 0;
return 0;
}
Output:
Enter the data (without spaces): ABEFCD
Original Data: ABEFCD
Data after Byte Stuffing: FABEEFCD F
LAB- 5
OBJECTIVE
Use Packet Tracer to create a DHCP Server.
SOFTWARE USED
Cisco Packet Tracer
PROCEDURE
2. From the bottom-left device list, drag and drop a switch onto the workspace.
3. Now drag and drop three end devices (PC-0, PC-1, PC-2) and one server (to act as the DHCP Server).
4. After placing all devices, go to the Connections section and select Copper Straight-Through wire as
the medium.
o PC-0 → Switch 0
o PC-1 → Switch 0
o PC-2 → Switch 0
o Server → Switch 0
o IP Address: 192.168.1.214
7. After assigning the static IP, click on the Server, go to the Config tab, and then select DHCP from the
left sidebar.
11. The PCs should automatically receive their IP addresses, gateway, and subnet mask from the
DHCP server.
LAB- 7
OBJECTIVE
To implement Bit Stuffing and De-stuffing using C programming.
SOFTWARE USED
C Language (Code::Blocks / Turbo C / GCC / Online IDE)
THEORY
Bit Stuffing is a technique used to prevent confusion between data and control information in communication
protocols. It is mainly used in protocols like HDLC.
In Bit Stuffing, a 0 is inserted after every five consecutive 1s in the data stream.
At the receiving end, the De-stuffing process removes the extra 0 added after five consecutive 1s,
reconstructing the original data.
ALGORITHM
Bit Stuffing:
1. Read the binary input data.
2. Traverse the input bit-by-bit.
3. Maintain a count of consecutive 1’s.
4. If five 1’s are encountered, insert a 0.
5. Continue until the end of the input.
Bit De-stuffing:
1. Read the stuffed bitstream.
2. Traverse bit-by-bit.
3. Count consecutive 1’s.
4. If five 1’s are found, skip the next bit (which is a stuffed 0).
5. Continue until the end of the data.
PROGRAM
int main() {
char input[100], stuffed[150], destuffed[100];
return 0;
}
Output:
Enter binary data: 0111111011
Before Bit Stuffing: 0111111011
After Bit Stuffing: 01111101011
After De-Stuffing: 0111111011
LAB- 8
OBJECTIVE
Configure RIP using Cisco Packet Tracer.
SOFTWARE USED
Cisco Packet Tracer
PROCEDURE
1. Open Cisco Packet Tracer and create a new topology using two routers, a few PCs, and the
necessary switches. Assign appropriate IP addresses to all devices.
2. After completing IP configuration, go to Router 1, click on the CLI tab, and enter the
following commands to configure RIP:
Router> enable
Router# configure terminal
Router(config)# router rip
Router(config-router)# network 10.0.0.0
Router(config-router)# network 192.168.1.0
Router(config-router)# exit
(Note: Use actual network addresses based on your setup.)
3. Similarly, go to Router 2, open the CLI and enter:
Router> enable
Router# configure terminal
Router(config)# router rip
Router(config-router)# network 20.0.0.0
Router(config-router)# network 192.168.1.0
Router(config-router)# exit
4. After configuring RIP on both routers, wait for a few seconds so that RIP can complete its
convergence process.
5. To verify whether RIP is working properly, use the following command on any router:
Router# show ip route
6. If configured correctly, you will see routes learned via RIP marked with an R in the routing table. This
confirms RIP is functioning successfully.
LAB- 9
OBJECTIVE:
Configure Open Shortest Path First (OSPF) using Packet Tracer.
SOFTWARE USED
Cisco Packet Tracer
Step 1:
Select two PCs and two routers and connect them with auto-connect cables and Serial 2/0 connection between both
routers.
Step 2:
Configure PCs:
PC0
IP: 192.168.1.2
Gateway: 10.0.0.4
PC1
IP: 192.168.2.2
Gateway: 10.0.0.2
Step 3:
Give IP address to Router0:
For PC connection: 192.168.1.1 (Fast Ethernet 0/0)
For Serial connection: 10.0.0.1 (Serial 2/0)
Then add both interfaces to OSPF with process ID 100 and include the network IPs: 192.168.1.0 and 10.0.0.0.
LAB- 10
OBJECTIVE:
Configure Static Routing using Packet Tracer.
SOFTWARE USED
Cisco Packet Tracer
Step 1:
Select 2 routers and 2 PCs and connect them with auto-connect cables. Connect both routers using a serial
connection.
Step 2:
Configure the routers using command line:
Router 0
nginx
CopyEdit
enable
configure terminal
ip route 192.168.7.0 255.255.255.0 192.168.2.2
Router 1
nginx
CopyEdit
ip route 192.168.1.0 255.255.255.0 192.168.2.1
Step 3:
Configure both PCs manually:
PC0
IP: 192.168.1.2
Gateway: 192.168.1.1
PC1
IP: 192.168.3.2
Gateway: 192.168.3.1
Step 4:
Configure the interfaces:
Router 0
FastEthernet 0/0: 192.168.1.1
Serial 2/0: 192.168.2.1
Router 1
FastEthernet 0/0: 192.168.3.1
Serial 2/0: 192.168.2.2
Step 5:
Finally, transmit a message from one system to another to test the static route.