CN File
CN File
(EAEPC19)
PRACTICAL RECORD FILE
2023-24
Submitted by-
Branch: ECAM
Section: 1
Semester: 6
Configure and analyze bus, ring, star, mesh, and hybrid network
3. 16.01.2024
topology with wired v/s wireless networks.
THEORY:
Firstly, The OSI (Open Systems Interconnection) model is a conceptual framework that standardizes the
functions of a telecommunication or computing system. These layers enable different networking
technologies and protocols to work together seamlessly. It is divided into seven layers that work together
to carry out specialised network functions, allowing for a more systematic approach to networking. All
these 7 layers work collaboratively to transmit the data from one person to another across the globe.
The model was developed by the International Organization for Standardization (ISO), in the year 1984 to
provide a common understanding and reference for designing and implementing network architectures.
1. Physical Layer
Position: Bottom layer. (Layer 1)
Functionality: Deals with the physical connection between devices. It defines the hardware elements, such as
cables, connectors, and transmission media, as well as the electrical and optical signalling used to transmit raw
binary data.
Operation: It transforms binary data into electrical signals for transmission and vice versa. It deals with aspects
such as voltage levels, cable types, and modulation techniques.
3. Network Layer:
Position: Above the Data Link Layer. (Layer 7)
Functionality: Focuses on logical addressing, routing, and forwarding of data packets between devices on
different networks. It allows data to traverse multiple networks, making it a critical layer for internetwork
communication.
Operation: The Network Layer encapsulates data into packets, adding headers that include source and
destination IP addresses. Routers operate at this layer, using logical addressing to forward packets between
networks.
4. Transport Layer:
Position: Above the Network Layer. (Layer 7)
Functionality: Ensures endtoend communication, providing error detection, correction, and flow control. It is
responsible for breaking down large messages into smaller segments, managing their reliable delivery, and
reassembling them at the destination.
Operation: It adds a transport layer header to each segment, including information like source and destination
port numbers. Protocols like TCP provide reliable, connection-oriented communication, while UDP offers a
connectionless, lightweight option.
5. Session Layer:
Position: Above the Transport Layer. (Layer 7)
Functionality: Manages the establishment, maintenance, and termination of communication sessions between
applications. It handles session synchronization, dialog control, and token management to facilitate organized
and efficient communication.
Operation: It sets up, coordinates, and terminates sessions, providing synchronization points during data
exchange. Checkpointing and recovery mechanisms help manage ongoing sessions, ensuring data consistency.
6. Presentation Layer:
Position: Above the Session Layer. (Layer 7)
Functionality: Deals with data translation, encryption, and compression to ensure that information sent from
one system can be properly understood by the receiving system. It is responsible for data format conversion and
manages the syntax and semantics of the exchanged information.
Operation: Data is translated into a standard format for transmission. Compression reduces the amount of data,
and encryption secures sensitive information. This layer ensures that data from the application layer can be
properly interpreted by the receiving device.
7. Application Layer:
Position: Top layer. (Layer 7)
Functionality: Provides network services directly to endusers or applications. It includes protocols for tasks such
as email, file transfer, and remote login. This layer represents the interface between the network and the user's
software applications.
Operation: This layer interacts directly with end-user applications, facilitating network services such as file
transfers (FTP), email (SMTP), and remote login (SSH). It encapsulates application-specific data for transmission.
ENCAPSULATION AND DE-CAPSULATION PROCESS
Encapsulation and de-encapsulation are fundamental processes that occur at different layers of the OSI
(Open Systems Interconnection) model during the transmission of data over a network. These processes
play a crucial role in organizing and delivering information between devices.
Encapsulation Process:
It involves adding protocol-specific headers
and trailers to data as it moves down the
OSI model layers before transmission.
De-Encapsulation Process:
It involves stripping off the headers and
trailers added during encapsulation as data
moves up the OSI model layers upon
reception.
1. Application Layer:
Functionality: The topmost layer of the TCP/IP model is the Application Layer, which deals with communication
between applications and the network. It includes protocols such as HTTP (Hypertext Transfer Protocol), FTP
(File Transfer Protocol), SMTP (Simple Mail Transfer Protocol), and DNS (Domain Name System). This layer
handles user interfaces and data exchange between applications.
2. Transport Layer:
Functionality: The Transport Layer ensures end-to-end communication between devices. It is responsible for
segmenting and reassembling data into packets for transmission. The two main protocols at this layer are TCP
(Transmission Control Protocol) and UDP (User Datagram Protocol). TCP provides reliable, connection-oriented
communication with features like error detection, flow control, and retransmission of lost packets, while UDP
offers faster, connectionless communication without reliability mechanisms.
3. Internet Layer:
Functionality: The Internet Layer, also known as the Network Layer in the OSI model, is responsible for routing
packets across different networks to their destinations. It uses IP (Internet Protocol) to address and route
packets based on their IP addresses. The Internet Layer enables internetworking by connecting disparate
networks and facilitating the exchange of data between them.
4. Link Layer:
Functionality: The Link Layer, also referred to as the Network Interface Layer or Data Link Layer in the OSI
model, deals with the physical connection between devices on the same network segment. It includes protocols
such as Ethernet, Wi-Fi, and PPP (Point-to-Point Protocol), which define how data is formatted for transmission
over specific types of physical media. The Link Layer is responsible for addressing devices on the local network
and managing access to the physical medium.
THEORY:
Network devices are essential components of computer networks, facilitating communication and data exchange
between devices within a network and beyond. Routers intelligently direct data packets between different networks,
switches efficiently forward data within a local network, and hubs, though less common now, simply repeat signals
to connected devices. While modems enable digital communication over analog infrastructure, bridges connect
multiple LAN segments, and repeaters amplify signals to extend network reach. Additionally, network interface cards
(NICs) serve as interfaces between devices and the network, allowing computers to connect to and communicate
over the network by translating digital data from the computer into signals that can be transmitted over network
cables or wirelessly. Together, these devices form the infrastructure that powers modern communication and
connectivity.
2. Switch:
Switches are fundamental to local area networks (LANs) as they facilitate
communication among devices within the same network. Operating at the data link
layer (Layer 2) of the OSI model, switches use MAC addresses to efficiently forward data
packets to their intended destinations. Unlike hubs, which broadcast data to all
connected devices, switches intelligently learn the MAC addresses of connected devices
and build a MAC address table to make forwarding decisions. This results in improved
network performance by reducing unnecessary network traffic and collisions.
3. Hub:
Hubs, while less commonly used in modern networks, are basic networking devices that operate
at the physical layer (Layer 1) of the OSI model. They serve as simple signal repeaters,
broadcasting data received from one connected device to all other connected devices. Unlike
switches, hubs lack intelligence and do not differentiate between devices, leading to increased
network congestion and reduced efficiency. Due to their limitations, hubs have largely been
replaced by switches in most network deployments.
4. Modem:
Modems, short for modulator-demodulators, are devices that modulate analog signals from a
computer or network into digital signals for transmission over analog communication lines,
such as telephone lines or coaxial cables. On the receiving end, modems demodulate incoming
digital signals back into analog signals interpretable by the receiving device. They enable digital
communication over analog infrastructure and are commonly used for internet connectivity
over DSL (Digital Subscriber Line) or cable broadband connections.
5. Network Bridge:
Network bridges are devices that connect multiple network segments or LANs together
and forward traffic between them based on MAC addresses. Operating at the data link
layer (Layer 2) of the OSI model, bridges effectively extend a LAN by interconnecting
multiple LAN segments while maintaining a single logical network. Unlike routers, which
operate at the network layer and make forwarding decisions based on IP addresses,
bridges focus on MAC addresses and are commonly used to segment LANs, reduce
network congestion, and improve network performance.
6. Network Repeater:
Network repeaters are devices used to regenerate or replicate signals in a network, effectively
extending the distance a signal can travel without degradation. Operating at the physical layer
(Layer 1) of the OSI model, repeaters amplify signals before retransmitting them; allowing data
to traverse longer distances over network cables or media. They play a vital role in overcoming
signal attenuation and maintaining signal integrity in large networks or environments with long
cable runs, such as Ethernet LANs or fiber optic networks.
THEORY:
Network topology refers to the layout of devices and connections within a computer network. Wired
networks utilize physical cables like Ethernet or fiber optics to connect devices, commonly employing star,
bus, or ring topologies. These configurations offer reliability and high bandwidth but may lack mobility. In
contrast, wireless networks transmit data through radio waves, using infrastructure, ad-hoc, or mesh
topologies. While wireless networks provide mobility and easy setup, they may face interference and
security concerns. The choice between wired and wireless topologies depends on factors such as cost,
scalability, and specific network requirements.
CODE:
import networkx as nx
import matplotlib.pyplot as plt
# Create a bus network
bus_nodes = 6
bus_edges = [(1, 2), (2, 3), (3, 4), (4, 5), (5, 6)]
G_bus = nx.Graph(bus_edges)
plt.subplot(2, 3, 1)
nx.draw(G_bus, with_labels=False, node_color='r', edge_color='b')
plt.title('Bus Topology')
OUTPUT:
EXPERIMENT 4
AIM: To understand Error Detection and Correction using Hamming Code.
THEORY:
The Hamming code implements a simple error detection and correction scheme known as parity coding. Initially, a 4-
bit data vector is encoded into a 7-bit codeword, where specific bits (P1, P2, and P4) are used as parity bits to detect
errors. Subsequently, a random bit in the encoded data is flipped to simulate an error. Error correction is then
attempted by recalculating the parity bits and identifying the error position based on their values. Once the error
position is determined, the erroneous bit is corrected, and the decoded data is obtained. Parity coding works by
adding extra bits (parity bits) to the data, allowing the detection and correction of single-bit errors.
CODE:
data = [1 0 1 1]
% Initialize the encoded vector with zeros
encoded = zeros(1, 7);
THEORY:
Networking commands are essential tools used in command-line interfaces (CLI) to manage, monitor, and
troubleshoot computer networks. They provide users with the ability to retrieve detailed information about network
configuration, diagnose connectivity issues, and perform administrative tasks.
2. ping:
- Function: Send ICMP echo request packets to a specified destination to test network connectivity and measure
round-trip time.
- Usage: Used to check if a remote host is reachable and to diagnose network latency issues.
IPCONFIG:
PING:
TRACET:
EXPERIMENT 6
AIM: To simulate the Go Back N sliding window protocol for flow control.
THEORY:
The Go Back N sliding window protocol is a flow control mechanism used in data communication networks.
It operates by allowing the sender to transmit a window of frames consecutively without waiting for
acknowledgment from the receiver. The receiver acknowledges the receipt of frames up to a certain
sequence number, enabling the sender to slide the window forward. However, if an acknowledgment is
not received within a certain timeout period or if a frame is lost or corrupted, the sender retransmits all
frames starting from the one that was not acknowledged. This protocol efficiently utilizes network
resources by ensuring a steady flow of data while handling potential errors or network congestion
effectively.
CODE:
import random
n = int(input('Number of frames: '))
w = int(input('Window size: '))
pt = 1
flag = False
while not flag:
for i in range(pt, min(pt+w, n+1)):
print('Frame', i, 'transmitted')
s = random.randint(1, 10)
if s > 3:
print('PAK of frame', pt, 'received')
pt += w
if pt > n:
flag = True
else:
print('NAK of frame', pt, 'received')
for j in range(pt, min(pt+w, n+1)):
print('Frame', j, 'discarded')
i=n-w+1
while i <= n:
s = random.randint(1, 10)
if s > 4:
print('PAK of frame', i, 'received')
i += 1
else:
print('NAK of frame', i, 'received')
for j in range(1, n+1):
print('Frame', j, 'discarded')
for k in range(1, n+1):
print('Frame', k, 'transmitted')
break
OUTPUT:
EXPERIMENT 7
AIM: To simulate Selective Repeat ARQ sliding window protocol in python.
THEORY:
Selective Repeat Automatic Repeat reQuest (ARQ) is a sliding window protocol used in computer networks
to ensure reliable data transmission over unreliable channels. Unlike other ARQ protocols, such as Go-
Back-N, Selective Repeat ARQ retransmits only the packets that are damaged or lost, rather than
retransmitting the entire window. This reduces unnecessary retransmissions and improves efficiency. In
Selective Repeat ARQ, both sender and receiver maintain a window of sequence numbers to track the sent
and received packets. Upon receipt of packets, the receiver acknowledges them individually, allowing the
sender to retransmit only the missing or damaged packets. This protocol enhances network performance
by minimizing the impact of errors and congestion while maximizing throughput.
CODE:
import random
n = int(input('Enter the number of frames: '))
w = int(input('Window size: '))
pt = w + 1
flag = False
ext = 0
flag1 = False
flag2 = False
a = list(range(1, n+1))
for i in range(1, w+1):
print('Frame', a[i-1], 'transmitted')
while not flag:
s = random.randint(1, 10)
if s > 3:
print('PAK of frame', a[pt - w - 1], 'received')
else:
print('NAK of frame', a[pt - w - 1], 'received')
ext += 1
a.insert(pt - 1, a[pt - w - 1])
print('Frame', a[pt - 1], 'transferred')
if a[pt - 1] == n:
flag = True
pt += 1
k = pt - w
while not flag2:
test = random.randint(1, 17)
if flag1:
print('Frame', a[k - 1], 'transmitted')
flag1 = False
if test > 3:
print('PAK of frame', a[k - 1], 'received')
k += 1
else:
print('NAK of frame', a[k - 1], 'received')
flag1 = True
if k >= n + ext + 1:
flag2 = True
OUTPUT:
EXPERIMENT 8
AIM: To analyze Distance Vector Routing Protocol using Routing Information Protocol to configure a computer
network.
THEORY:
Distance Vector Routing Protocol, utilizing the Routing Information Protocol (RIP), operates on the
principle of exchanging routing information between neighboring routers within a computer network. Each
router maintains a table containing the distance (metric) to reachable network destinations and forwards
this information to its neighboring routers periodically. RIP employs the Bellman-Ford algorithm to
calculate the shortest path to each destination based on hop count. Despite its simplicity, RIP's periodic
updates and reliance on hop count can lead to slow convergence and potential routing loops in larger
networks. Nonetheless, in small-scale environments, where network topology changes infrequently, RIP
remains a straightforward and viable option for configuring routing tables and ensuring efficient data
transmission within the network. Its ease of implementation and minimal configuration overhead make it
particularly suitable for smaller networks or for educational purposes, providing a foundational
understanding of routing protocols. However, its limitations become apparent in larger, more dynamic
networks, where more sophisticated routing protocols such as OSPF or EIGRP are preferred for their faster
convergence and greater flexibility.
CODE:
import numpy as np
# Initialize network parameters
Nodes = 5 # Number of nodes in the network
Itr = 10 # Number of iterations for routing table updates
Maxhop = 15 # Maximum number of hops allowed
# Initialize routing tables for each node [Destination Node, Next Hop, Distance, Sequence Number]
rt = {}
for node in range(1, Nodes + 1):
rt[node] = np.array([[node, node, 0, 0]]) # Initialize with self-entry
OUTPUT: