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

Computer Network Lab File

The document is a lab file for a Computer Networks course at Shri Ramswaroop Memorial University for the session 2024-2025. It includes a series of experiments using Cisco Packet Tracer and C programming, covering topics such as connecting LANs and networks, implementing bit and byte stuffing, retrieving MAC addresses using ARP, subnetting, and configuring a DHCP server. Each lab outlines the software used, procedures, and expected outcomes for the experiments.

Uploaded by

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

Computer Network Lab File

The document is a lab file for a Computer Networks course at Shri Ramswaroop Memorial University for the session 2024-2025. It includes a series of experiments using Cisco Packet Tracer and C programming, covering topics such as connecting LANs and networks, implementing bit and byte stuffing, retrieving MAC addresses using ARP, subnetting, and configuring a DHCP server. Each lab outlines the software used, procedures, and expected outcomes for the experiments.

Uploaded by

stdeepak3614
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 15

SHRI RAMSWAROOP MEMORIAL

UNIVERSITY

COMPUTER NETWORKS
(BCS 6501)

LAB FILE

Session: 2024-2025

Submitted To: Submitted By:

Mr. Shaeque Khan Name -


Roll
no.-
Course -
INDEX
Name: Roll No.

Faculty
S.No Name of Experiment Date Remarks
Signature

1 Use Packet Tracer to connect the


computers of different LANs

2 Use Packet Tracer to connect the


computers of different networks.

3
Write a C program to implement Bit Stuffing.

4 Write a C program to implement Byte


Stuffing.

5 Getting MAC Address Using ARP and


Subnetting a Network.

6 Use Packet Tracer to create a DHCP Server.

7 Implement Bit Stuffing and De-stuffing

8 Configure RIP using Packet Tracer.

Configure OSPF (Open Shortest Path First)


9 using Packet Tracer

10 Configure Static Routing using Packet


Tracer.
LAB- 1
Use Packet Tracer to connect the computers of different LANs.

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

Use Packet Tracer to connect the computers of different networks.

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

Write a C program to implement Bit Stuffing.

#include <stdio.h>
#include <string.h>

int main() {
char data[100], stuffedData[200];
int i, j = 0, count = 0;

printf("Enter the binary data (0s and 1s only): ");


scanf("%s", data);

printf("Original Data: %s\n", data);

for (i = 0; i < strlen(data); i++) {


stuffedData[j++] = data[i];

if (data[i] == '1') {
count++;
} else {
count = 0;
}

if (count == 5) {
stuffedData[j++] = '0'; // Bit stuffing: insert a 0 after five 1s
count = 0;
}
}

stuffedData[j] = '\0'; // Null-terminate the stuffed string

printf("Data after Bit Stuffing: %s\n", stuffedData);

return 0;
}

Output:

Enter the binary data (0s and 1s only): 01111110111110


Original Data: 01111110111110
Data after Bit Stuffing: 0111110101111100
LAB- 4

Write a C program to implement Byte Stuffing.


#include <stdio.h>
#include <string.h>

int main() {
char data[100], stuffedData[200];
char flag[] = "F";
char esc[] = "E";
int i, j = 0;

printf("Enter the data (without spaces): ");


scanf("%s", data);

printf("Original Data: %s\n", data);

// Start and end the stuffed data with the flag


strcpy(stuffedData, flag);
j = 1;

for (i = 0; i < strlen(data); i++) {


// If data contains flag or escape character, prepend it with escape character
if (data[i] == 'F' || data[i] == 'E') {
stuffedData[j++] = 'E'; // Stuff escape character
}
stuffedData[j++] = data[i]; // Add original byte
}

stuffedData[j++] = 'F'; // Ending flag


stuffedData[j] = '\0'; // Null terminate

printf("Data after Byte Stuffing: %s\n", stuffedData);

return 0;
}

Output:
Enter the data (without spaces): ABEFCD
Original Data: ABEFCD
Data after Byte Stuffing: FABEEFCD F
LAB- 5

Getting MAC Address Using ARP and Subnetting a Network.


1. Introduction
This experiment focuses on writing a C program to retrieve the MAC address of a system using ARP (Address
Resolution Protocol) and configuring subnetting using Cisco Packet Tracer.
2. Address Resolution Protocol (ARP)
ARP is used to find the MAC address of a device associated with a given IP address within a local network by
broadcasting an ARP request and receiving an ARP reply.
3. Subnetting
Subnetting divides a network into smaller subnets, improving performance and management. Each subnet has a
unique range of IP addresses defined by its subnet mask.
Part A: C Program to Get MAC Address Using ARP
1. Open a C IDE like Code::Blocks or Visual Studio Code.
2. Write the C program using system commands to retrieve the MAC address.
3. Compile using gcc and run the program.
C Program: #include <stdio.h> #include <stdlib.h> int main()
{ printf("Getting MAC Address using ARP...\n"); system("arp -a");
return 0; }
Compile: gcc mac_address.c -o mac_address
Run: ./mac_address (Linux/Mac) or mac_address.exe (Windows)
Part B: Subnetting in Cisco Packet Tracer
Scenario: Network Address - 192.168.1.0/24
Divide the network into 4 subnets with at least 50 hosts each. Subnet Calculation:
- Total IPs in /24 = 256
- 50 hosts need 6 host bits, so the new subnet mask is /26 (255.255.255.192)
- Subnets:
1. 192.168.1.0/26
2. 192.168.1.64/26
3. 192.168.1.128/26
4. 192.168.1.192/26
Packet Tracer Configuration:
1. Open Cisco Packet Tracer and add routers, switches, and PCs.
2. Configure routers:
enable
configure terminal interface FastEthernet0/0
ip address 192.168.1.1 255.255.255.192 no shutdown
exit
3. Assign IPs to PCs in Desktop > IP Configuration.
4. Verify connectivity using the ping command.
4. Practical Example
Ping from PC1 (192.168.1.2) to PC2 (192.168.1.66) should be successful. Cross-subnet ping works with correct
routing.
5. Conclusion
The C program successfully retrieves the MAC address using ARP. Cisco Packet Tracer demonstrates
subnetting by dividing the network into multiple subnets with specific IP ranges.
LAB- 6

Use Packet Tracer to create a DHCP Server.

OBJECTIVE
Use Packet Tracer to create a DHCP Server.

SOFTWARE USED
Cisco Packet Tracer

PROCEDURE

1. Open Cisco Packet Tracer and start a new file.

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.

5. Connect each device to Switch 0 using the wire:

o PC-0 → Switch 0

o PC-1 → Switch 0

o PC-2 → Switch 0

o Server → Switch 0

6. Now configure a static IP address on the Server:

o IP Address: 192.168.1.214

o Subnet Mask: 255.255.255.0

o Default Gateway: 192.168.1.1

7. After assigning the static IP, click on the Server, go to the Config tab, and then select DHCP from the
left sidebar.

8. Enter the following DHCP configuration details:


o Pool Name: HY-LAN

o Default Gateway: 192.168.1.1

o DNS Server: 192.168.1.2

o Starting IP Address: 192.168.1.0

o Subnet Mask: 255.255.255.0

o Maximum Number of Users: 256

9. Click Add and ensure the DHCP service is turned ON.

10. Now, go to each PC → Desktop → IP Configuration → Select DHCP.

11. The PCs should automatically receive their IP addresses, gateway, and subnet mask from the
DHCP server.
LAB- 7

Implement Bit Stuffing and De-stuffing.

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

#include <stdio.h> #include


<string.h>

void bitStuffing(char *input, char *stuffed)


{ int i, j = 0, count = 0;
for (i = 0; input[i] != '\0'; i++)
{ if (input[i] == '1') {
count++;
stuffed[j++] = input[i]; if
(count == 5) {
stuffed[j++] = '0';
count = 0;
}
} else {
stuffed[j++] = input[i];
count = 0;
}
}
stuffed[j] = '\0';
}

void bitDeStuffing(char *stuffed, char *original)


{ int i, j = 0, count = 0;
for (i = 0; stuffed[i] != '\0'; i++)
{ if (stuffed[i] == '1') {
count++;
original[j++] = stuffed[i];
if (count == 5) {
i++; // skip the stuffed 0
count = 0;
}
} else {
original[j++] = stuffed[i];
count = 0;
}
}
original[j] = '\0';
}

int main() {
char input[100], stuffed[150], destuffed[100];

printf("Enter binary data: ");


scanf("%s", input);

bitStuffing(input, stuffed); printf("\


nBefore Bit Stuffing: %s", input); printf("\
nAfter Bit Stuffing: %s", stuffed);

bitDeStuffing(stuffed, destuffed); printf("\


nAfter De-Stuffing: %s\n", destuffed);

return 0;
}

Output:
Enter binary data: 0111111011
Before Bit Stuffing: 0111111011
After Bit Stuffing: 01111101011
After De-Stuffing: 0111111011
LAB- 8

Write a Java program for Java Database Connectivity – Data Retrieval.

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

Configure OSPF (Open Shortest Path First) using Packet Tracer.

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

Configure Static Routing using Packet Tracer.

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.

You might also like