CN Practical File Divya
CN Practical File Divya
PRACTICAL – 1
1
DIVYA PANDEY (2023218743)
2
DIVYA PANDEY (2023218743)
(ii). Each device should automatically be assigned an IP address via DHCP from the router
(if DHCP is enabled, which is the default for most routers)
3
DIVYA PANDEY (2023218743)
4
DIVYA PANDEY (2023218743)
PRACTICAL – 2
1. ping: Used to test network connectivity by sending ICMP echo requests to a specified
host.
Example: ping 192.168.1.1
5
DIVYA PANDEY (2023218743)
Example: ipconfig
Example: nslookup
7
DIVYA PANDEY (2023218743)
6. route: Used to view and manipulate the routing table, which determines how network
traffic is routed.
Example: route
7. arp: Used to display or modify the local ARP cache, which maps IP addresses to MAC
addresses.
Example: arp
8
DIVYA PANDEY (2023218743)
8. tracert: Traces the path that network packets take from your computer to a destination
IP address or domain name, showing each hop along the way.
Example : tracert
10
DIVYA PANDEY (2023218743)
PRACTICAL – 3
Step 4: Next screen will appear and will ask for email and password and other simple details,
fill them and click on Register.
12
DIVYA PANDEY (2023218743)
Step 6: On the next screen enter the password and press the Login button.
13
DIVYA PANDEY (2023218743)
Step 7: Dashboard will initialize, now click on Resources and choose Download Packet
Tracer Option.
Step 8: On the next web page choose the operating system to download the packet tracer.
Downloading will start automatically.
14
DIVYA PANDEY (2023218743)
Step 9: Check for the executable file in your system and run it.
Step 10: Next screen is of License Agreement so Click on I accept the license.
15
DIVYA PANDEY (2023218743)
Step 11: Choose the installing location which has sufficient space.
Step 12: Select the start menu folder and click the Next button.
16
DIVYA PANDEY (2023218743)
Step 13: Check the box for creating a desktop icon and click on the Next button.
Step 14: Now packet tracer is ready to install so click on the Install button.
Step 15: The installation process will start and will hardly take a minute.
18
DIVYA PANDEY (2023218743)
19
DIVYA PANDEY (2023218743)
PRACTICAL – 4
Aim:- Create Point to Point and Star Topology in CISCO Packet Tracer.
Point-to-Point Topology :-
Point-to-point topology is the simplest network configuration, directly connecting two
devices (nodes) with a dedicated link. This means data travels directly between the two
endpoints without going through any other device or hub. It's like a direct telephone call,
where one device (the sender) communicates directly with another (the receiver) without
interference.
2. Add end devices: Drag two PCs from the "End Devices" section to the workspace.
20
DIVYA PANDEY (2023218743)
3. Connect the devices: Select a "Straight-Through" cable and connect one PC to the
other.
21
DIVYA PANDEY (2023218743)
4. Configure IP addresses: Click on each PC, go to "Desktop" > "IP Configuration", and
assign static IP addresses (e.g., 192.168.2.10 for PC1 and 192.168.2.11 for PC2).
Ensure the subnet mask is correct (e.g., 255.255.255.0).
22
DIVYA PANDEY (2023218743)
5. Test connectivity: Use the "Ping" command from the Command Prompt on one PC to
test if it can reach the other.
Star Topology:-
In computer networking, a star topology is a network configuration where all devices connect
to a central hub or switch. This central node acts as a focal point, and all communication
passes through it. Each device has a dedicated point-to-point connection to the central hub,
making it easy to manage and isolate network traffic.
1. Open Cisco Packet Tracer and start a new project.
23
DIVYA PANDEY (2023218743)
2. Add a central device: Drag a "Switch" (or "Hub") from the "Devices" section to the
workspace.
24
DIVYA PANDEY (2023218743)
4. Configure IP addresses: Click on each PC, go to "Desktop" > "IP Configuration", and
assign static IP addresses. Ensure the subnet mask is correct for the network.
5. Test connectivity: Use the "Ping" command from the Command Prompt on one PC to
test if it can reach other PCs on the network.
25
DIVYA PANDEY (2023218743)
PRACTICAL – 5
Router: A router is a device like a switch that routes data packets based on their IP addresses.
The router is mainly a Network Layer device. Routers normally connect LANs and WANs
and have a dynamically updating routing table based on which they make decisions on
routing the data packets. The router divides the broadcast domains of hosts connected
through it.
Here's a step-by-step guide on how to configure a switch and router in Cisco Packet Tracer:
Step 1: Create a New Topology
1. Open Cisco Packet Tracer.
2. Create a new topology.
26
DIVYA PANDEY (2023218743)
27
DIVYA PANDEY (2023218743)
28
DIVYA PANDEY (2023218743)
29
DIVYA PANDEY (2023218743)
30
DIVYA PANDEY (2023218743)
PRACTICAL: - 6
Args:
data: A string representing the data.
Returns:
31
DIVYA PANDEY (2023218743)
return complement
Args:
data: A string representing the data.
checksum: A string representing the received checksum.
Returns:
True if the checksums match, False otherwise.
"""
calculated_checksum = checksum(data)
32
DIVYA PANDEY (2023218743)
# Example usage:
data = "101101011100"
received_checksum = checksum(data)
print("Data:", data)
print("Calculated checksum:", received_checksum)
# Simulate a data transmission with a potential error
# Let's say bit 2 (index 1) is flipped from 1 to 0
# data_with_error = "100101011100"
1100
1010
33
DIVYA PANDEY (2023218743)
1001
1100
-------
10011
1. Handle carry: The 5th bit carries over, so it's added to the sum:
10011
+1
-------
10100
10100 (Sum)
01011 (1's complement = Checksum)
1. Transmission: The sender sends 1100 1010 1001 1100 01011 (data + checksum).
1100
1010
1001
1100
01011 (Checksum)
34
DIVYA PANDEY (2023218743)
-------
11111 (Sum of all including checksum)
11111 (Sum)
00000 (1's complement = 0)
● Result: The result is all ones (or zero), indicating no errors were detected.
35
DIVYA PANDEY (2023218743)
PRACTICAL: 7
36
DIVYA PANDEY (2023218743)
3. Connect the devices: Select a “Straight- Through” cable and connect all end devices.
37
DIVYA PANDEY (2023218743)
5. Click on services of the server and click on DHCP and on the services.
6. Configure IP addresses: Click on each PC, go to "Desktop" > "IP Configuration", and
assign DHCP IP addresses.
38
DIVYA PANDEY (2023218743)
7. Click on server and go to desktop and select a IP v4 firewall and on the services of
firewall.
8. Click on any pc and go to desktop and click on command prompt and run ping 1.0.0.1
command to check the firewall.
39
DIVYA PANDEY (2023218743)
9. Click on any pc and go to desktop and click on web browser and run 1.0.0.1 to check
the firewall.
40
DIVYA PANDEY (2023218743)
PRACTICAL – 8
3. Connect the devices: Select a “Straight- Through” cable and connect all end devices .
42
DIVYA PANDEY (2023218743)
43
DIVYA PANDEY (2023218743)
44
DIVYA PANDEY (2023218743)
10. Check the VPN configuration on the PC command prompt with the tracert command .
45
DIVYA PANDEY (2023218743)
PRACTICAL – 9
Aim :- Write down the Steps to Setting up and Secure a Wireless Network .
Introduction :
A wireless network is a type of computer network that connects devices without the use of
physical cables or wires. It allows devices to communicate with each other and access the
internet or other network resources wirelessly.
1. Open Cisco Packet Tracer and start a new project.
46
DIVYA PANDEY (2023218743)
47
DIVYA PANDEY (2023218743)
6. Connect the routers : Select a “Automatic cable” and connect the routers .
48
DIVYA PANDEY (2023218743)
49
DIVYA PANDEY (2023218743)
PRACTICAL – 10
Aim :- Implement the Link State Routing algorithm by taking at least 6 nodes.
Also calculate the total cost of the shortest path.
Introduction :
The Link State Routing algorithm is a dynamic routing protocol used in computer networks
to determine the best path between nodes. It works by maintaining a map of the network
topology and calculating the shortest path to each node based on the link costs.
Program :
#include <iostream>
#include <vector>
#include <climits>
using namespace std;
#define N 6 // Number of nodes
void dijkstra(int graph[N][N], int src) {
int dist[N]; // Shortest distance from src to i
bool visited[N]; // True if vertex is processed
// Initialize distances and visited[]
for (int i = 0; i < N; i++) {
dist[i] = INT_MAX;
visited[i] = false;
}
dist[src] = 0; // Distance to itself is always 0
for (int count = 0; count < N - 1; count++) {
int u = -1;
int minDist = INT_MAX;
// Pick the unvisited vertex with the smallest distance
for (int i = 0; i < N; i++) {
if (!visited[i] && dist[i] <= minDist) {
minDist = dist[i];
50
DIVYA PANDEY (2023218743)
u = i;
} }
visited[u] = true;
// Update distances of adjacent vertices of u
for (int v = 0; v < N; v++) {
if (!visited[v] && graph[u][v] && dist[u] != INT_MAX
&& dist[u] + graph[u][v] < dist[v]) {
dist[v] = dist[u] + graph[u][v];
}
}
}
// Print results
cout << "Shortest path costs from Node " << src << ":" << endl;
int totalCost = 0;
for (int i = 0; i < N; i++) {
cout << "To Node " << i << " : " << dist[i] << endl;
totalCost += dist[i];
}
cout << "Total cost of shortest paths: " << totalCost << endl;
}
int main() {
// Example graph represented as adjacency matrix
// 0 means no direct link
int graph[N][N] = {
{0, 2, 0, 1, 0, 0},
{2, 0, 3, 2, 0, 0},
{0, 3, 0, 0, 7, 3},
51
DIVYA PANDEY (2023218743)
{1, 2, 0, 0, 1, 0},
{0, 0, 7, 1, 0, 2},
{0, 0, 3, 0, 2, 0}
};
int srcNode;
cout << "Enter source node (0 to " << N-1 << "): ";
cin >> srcNode;
if (srcNode < 0 || srcNode >= N) {
cout << "Invalid source node." << endl;
return 1;
}
dijkstra(graph, srcNode);
return 0;
}
Graph layout :
Node 0: connects to 1 (2), 3 (1)
Node 1: connects to 0 (2), 2 (3), 3 (2)
Node 2: connects to 1 (3), 4 (7), 5 (3)
Node 3: connects to 0 (1), 1 (2), 4 (1)
Node 4: connects to 2 (7), 3 (1), 5 (2)
Node 5: connects to 2 (3), 4 (2)
Graph diagram :
(2)
0 -------- 1
| |
(1) (3)
| |
52
DIVYA PANDEY (2023218743)
3 -------- 2
\ /\
(1) (7) (3)
\ / \
4 -------- 5
(2)
53