Hardware & Networking Lab (ALL PRACTICAL)
Hardware & Networking Lab (ALL PRACTICAL)
➔There are two important network architectures, the OSI reference model and the
The OSI model has seven layers. The principles that were applied to arrive at the seven
layers can be briefly summarized as follows:
1. A layer should be created where a different abstraction is needed.
2. Each layer should perform a well-defined function.
3. The function of each layer should be chosen with an eye toward defining internationally
standardized protocols.
4. The layer boundaries should be chosen to minimize the information flow across the
interfaces.
5. The number of layers should be large enough that distinct functions need not be thrown
together in the same layer out of necessity and small enough that the architecture does
not become unwieldy.
LAYER 1 : The PHYSICAL LAYER deals with transmission of individual bits from one node to another
over a physical medium.
The main functions of the physical layer are as follows:-
●It defines the physical characteristics and functions of the physical devices and interfaces so that
transmission can occur. It states the number of pins in each of the Z devices as well as the purpose of
each pin.
●It lays out the transmission medium and type of signal for transmitting the bits, i.e., electrical pulses,
optical pulses or radio signals.
LAYER 2
The DATA LINK LAYER converts the raw transmission facilit provided by the physical layer to a
reliable and error-free link.
The main functions of the data link layer are as follows
It breaks up the stream of bits into data frames having sizes from a few hundred to a few thousand bytes.
It ensures distribution of the frames to the different systems. For this, it adds a head to the frame
containing the address of the sender and the [Link] case of reliable connection, this layer ensures
that the receiver sends an retransmission is done. It also has mechanisms to identify duplicate frames.
The data link layer ensures flow control of transmission so that a fast sender does not drown a slow
receiver.
In the case of broadcast networks, this layer also controls access to the shared channel.
→
LAYER 3: The NETWORK LAYER controls the source to destination delivery of data packets across
multiple hops (nodes). It controls the operation of the subnet.
The main functions of the network layer are as follows
It is responsible for routing packets from the source host to the destination host. The routes can be based
upon static tables that are rarely changed, or they can be
the upper layer in a standardized format. It deals with the syntax and the semantics of
the messages.
The main functions of the presentation layer are as follows:-
●It encodes the messages from the user dependent format to the common format and
vice versa, for communication among dissimilar systems.
●It is responsible for data encryption and decryption of sensitive data before they are
transmitted over common channels.
●It is also responsible for data compression. Data compression is done at the source to
reduce the number of bits to be transmitted. It reduces the storage space and increases
the file transfer rate. It is particularly useful for transmission of large multimedia files.
It is responsible for routing packets from the source host to the destination host. The routes can be
based upon static tables that are rarely changed, or they can be automatically updated depending upon
network conditions.
The data link layer assigns the physical address locally. When the data packets are routed to remote
locations, a logical addressing scheme is required to differentiate between the source system and the
destination system.
→ LAYER 4: The TRANSPORT LAYFR is responsible for delivery of an entire message from an
application program on the source device to a similar application program on the destination device.
The main functions of the transport layer are as follows:-
It delivers a message from a specific process of one computer to a specific process in another computer.
The transport layer adds a port address to the header of the data packet.
It divides a message into smaller segments such that each segment contains a sequence number along
with the port address. It ensures that the segments arrive correctly at the receiver's end and then
reassembles [Link] provides an error-free point-to-point channel for both connectionless and
connection-oriented services.
→ LAYER 5: The SESSION LAYER is responsible for establishing, managing, synchronizing and
terminating sessions between end-user application processes.
The main functions of the session layer are as follows:-
It works as a dialog controller. It allows the systems to communicate in either half-duplex or full-duplex
mode of communication.
It is responsible for token management. Through this, it prevents the two users to simultaneously
attempt the same critical operation.
It synchronizes communication. It adds synchronization points or checkpoints in data streams for long
communications.
the upper layer in a standardized format. It deals with the syntax and the semantics of the messages.
The main functions of the presentation layer are as follows:-
●It encodes the messages from the user dependent format to the common format and vice versa, for
communication among dissimilar systems.
●It is responsible for data encryption and decryption of sensitive data before they are transmitted over
common channels.
●It is also responsible for data compression. Data compression is done at the source to
reduce the number of bits to be transmitted. It reduces the storage space and increases
the file transfer rate. It is particularly useful for transmission of large multimedia files.
topmost layer of the OSI model. It specifies the interfaces and supports services to the end users for
network access.
➔LAYER 7 : The APPLICATION LAYER is checkpoints are successfully received and acknowledged.
In case of any failures, only the streams after the checkpoints have to be re-transmitted.
The main functions of the application layer are as follows:-
●It provides a virtual network terminal through which a user can log on to the remote
host on the network.
●It provides facilities so that a user can access and retrieve files in a remote computer
for local usage, as well as manage and store files on a remote computer from the local
computer.
●It provides email services.
●It helps to retrieve global information and services by providing access to distributed
database resources.
➔TCP/IP means Transmission Control Protocol and Internet Protocol. It is the network
model used in the current Internet architecture as we Protocols are a set of rules which
govern every possible communication over a network. These protocols describe the
movement of data between the source and destination or the internet. They also offer
simple naming and addressing schemes.
FIG : PROTOCOLS AND NETWORKS IN THE TCP/IP MODEL INITIALLY
Network Access Layer/Host -to -Network Layer :
➔A network layer is the combination of the Physical layer and Data Link layer defined
in the OSI reference model.
➔It defines how the data should be sent physically through the network.
➔This layer is mainly responsible for the transmission of the data between two devices
➔The functions carried out by this layer are encapsulating the IP datagram into frames
➔The protocols used by this layer are ethernet, token ring, FDDI, X.25, frame relay.
Transport Layer :
➔The transport layer is responsible for error-free, end-to-end delivery of data from the
source host to the destination host. It corresponds to the transport layer of the OSI model.
●Transmission Control Protocol, TCP − It is a reliable connection-oriented protocol that transmits data
from the source to the destination machine without any error. A connection is established between the
peer entities prior to transmission. At the sending host, TCP divides an incoming byte stream into
segments and assigns a separate sequence number to each segment. At the receiving host, TCP reorders
the segments and sends an acknowledgment to the sender for correct receipt of segments. TCP also
manages flow control so that a fast sender does not overwhelm a slow receiver.
●User Datagram Protocol, UDP−
It is a message-oriented protocol that provides a simple unreliable, connectionless, unacknowledged
service. It is suitable for applications that do not require TCP’s sequencing, error control or flow control.
It is used for transmitting a small amount of data where the speed of delivery is more important than
the accuracy of delivery.
●Stream Control Transmission Protocol, SCTP
It combines the features of both TCP and UDP. It is message oriented like the UDP, which provides a
reliable, connection-oriented service like TCP. It is used for telephony over the Internet.
Application Layer :
1. This is the top most layer of TCP/IP model.
2. It is used for interaction between user and application.
3. There are several protocols used by the application layer for user interaction such as:
HTTP, SNMP, SMTP, DNS, TELNET, FTP etc.
➔HTTP: HTTP stands for Hypertext transfer protocol, it allows the user to interact with
world wide web through the browser application. HTTP can be used to transfer
various types of data such as plain text, audio, video etc.
➔FTP: FTP stands for File Transfer Protocol. This protocol is used for transmitting files
merge_sort_packets(left_half)
merge_sort_packets(right_half)
i=j=k=0
while i < len(left_half) and j < len(right_half):
if left_half[i].seq_no < right_half[j].seq_no:
packets[k] = left_half[i]
i += 1
else:
packets[k] = right_half[j]
j += 1
k += 1
OUTPUT:-
Unordered Packets (Network Access Layer):
[[Seq: 105, Data: Payload_E], [Seq: 101, Data: Payload_A], [Seq: 104, Data:
Payload_D], [Seq: 102, Data: Payload_B], [Seq: 103, Data: Payload_C]]
Sorted Packets (Transport Layer - Reassembly):
[[Seq: 101, Data: Payload_A], [Seq: 102, Data: Payload_B], [Seq: 103, Data:
Payload_C], [Seq: 104, Data: Payload_D], [Seq: 105, Data: Payload_E]]
Introduction:
data structures are primarily categorized into two types based on how the data
elements are organized and accessed: Linear and Non-Linear data structures.
# Push elements
[Link]('A')
[Link]('B')
[Link]('C')
# Pop element
removed = [Link]()
print("Popped element:", removed)
print("Stack after pop:", stack)
Output:
Stack after pushes: ['A', 'B', 'C']
Popped element: C
Stack after pop: ['A', 'B']
Applications:
✓ Undo/Redo functions in word processors.
✓ Expression Evaluation (converting infix to postfix).
✓ Function Call Management (Recursion stack).
print("Root:", [Link])
print("Left Child:", [Link])
print("Right Child:", [Link])
Output:
Root: 1
Left Child: 2
Right Child: 3
Applications:
✓ Trees: Used in File Systems (folders/subfolders), Organization Charts,
and HTML DOM (Document Object Model).
✓ Graphs: Used in Social Networks (Facebook/LinkedIn connections),
Google Maps (finding shortest paths), and Recommendation Engines.
Conclusion: hence,. Successfully creating the linear and non linear data
stractures with its example.
Practical No.4
Introduction:
Sorted Array with Binary Search
A sorted array is a data structure where elements are stored in a particular order
(ascending or descending).
Binary Search is a fast searching technique that works only on sorted arrays.
Instead of scanning every element, it repeatedly divides the array into two parts
and searches efficiently.
Working Principle:
Binary search uses the middle index:
o If key == arr[mid] → element found
o If key < arr[mid] → search in left half
o If key > arr[mid] → search in right half
Advantages:
o Faster than linear search
o Reduces search space by half each time
o Efficient for large datasets
Time Complexity:
o Best Case: O(1)
o Worst Case: O(log n)
Program:
#include <stdio.h>
int main() {
int arr[] = {1, 3, 5, 7, 9, 11, 13}; // sorted array
int n = sizeof(arr) / sizeof(arr[0]);
int key = 7;
if (result != -1)
printf("Element found at index: %d", result);
else
printf("Element not found");
return 0;
}
Output:
Element found at index: 3
Conclusion: Hence,. Choose the appropriate data structures to solve given
problem successfully.
Practical No.5
Main Functions:
-Transmits data in the form of electrical, optical, or radio signals
-Defines hardware elements and transmission media
-Controls data rate and synchronization
-Specifies voltage levels and physical connections.
Network Topologies
Network topology refers to the layout or arrangement of devices in a network.
Types of Network Topologies:
1. Bus Topology
-All devices connected to a single backbone cable
-Simple and low cost
-If the main cable fails, entire network stops
2. Star Topology
-All devices connected to a central hub/switch
-Easy to manage and troubleshoot
-Failure of central device affects the whole network
3. Ring Topology
-Devices connected in a circular manner
-Data travels in one direction
-Break in the ring can stop communication
4. Mesh Topology
-Every device is connected to every other device
-Highly reliable and secure
-Expensive and complex
5. Tree Topology
-Combination of star and bus topology
-Hierarchical structure
-Easy to expand
6. Hybrid Topology
-Combination of two or more topologies
-Flexible and scalable
Conclusion: Hence,. Studied the various physical layer components and different
topologies of networking.
Practical No.6
Aim: To study OSI reference model and TCP/IP reference model with
respect to protocol suite.
INTRODUCTION:
OSI Model: It has 7 layers Physical layer, Data Link layer, Network layer,
Transport layer, Session layer, Presentation layer, and Application layer. Each
layer performs its task independently.
TCP/IP Model: It has 5 layers named as Physical layer, Data Link Layer,
Network layer, Transport layer, and Application layer. It can also be used as a
communications protocol in a private computer network.
OSI Model
The OSI (Open Systems Interconnection) Model is a 7-layer conceptual
framework used to understand and design network communication. Each layer
has a clearly defined function and works independently of the others.
1. Physical Layer
Transmits raw bits over physical media.
• Deals with cables, connectors, voltages, signals
• Converts digital data into electrical/optical signals
o Defines hardware specifications (NICs, hubs, repeaters)
o Handles data rate, modulation, and physical topology
2. Data Link Layer
Provides reliable node-to-node data transfer.
• Uses MAC addresses for device identification
• Performs error detection and correction (Frame Check Sequence)
• Breaks data into frames
• Manages access to the physical medium (Ethernet, switches)
3. Network Layer
Handles logical addressing and routing of packets.
• Uses IP addresses for routing decisions
• Determines the best path to the destination
• Manages packet forwarding and routing tables
• Supports routers and Layer 3 protocols (IP, ICMP)
4. Transport Layer
Ensures reliable or fast delivery of data.
• Uses TCP (reliable) and UDP (fast, connectionless)
• Handles segmentation and reassembly of data
• Provides flow control (sliding window)
• Ensures error recovery and end-to-end communication
5. Session Layer
Establishes, manages, and terminates sessions.
• Controls dialog between devices (duplex/half-duplex)
• Maintains session checkpoints and recovery
• Handles session authentication and reconnection
• Used in RPC, SQL sessions, NetBIOS
6. Presentation Layer
Translates, encrypts, and formats data.
• Converts data formats (encoding/decoding)
• Applies encryption and decryption (SSL/TLS)
• Handles compression for efficient transmission
• Makes data readable for the application layer
7. Application Layer
Provides services to end-user applications.
• Supports protocols like HTTP, FTP, SMTP, DNS
• Provides network services such as email, web access, file transfer
• Interacts directly with user applications
• Identifies communication partners and resource availability
TCP/IP Model
The TCP/IP (Transmission Control Protocol/Internet Protocol) Model is a 5-
layer practical networking framework used for real-world communication,
especially on the Internet. It defines how data is packaged, addressed,
transmitted, routed, and received across networks.
1. Physical Layer
Transmits raw bits over physical media.
• Deals with physical hardware: cables, signals, connectors
• Converts digital data into electrical/optical/radio signals
• Defines data transmission rate and physical topologies
• Supported devices include hubs, repeaters, and NICs
2. Data Link Layer
Provides node-to-node communication and framing.
• Uses MAC addresses for device identification
• Responsible for framing, error detection (FCS), and flow control
• Handles access to the transmission medium (Ethernet, Wi-Fi)
• Switches operate at this layer
3. Network (Internet) Layer
Handles logical addressing and packet routing.
• Uses IP addressing (IPv4/IPv6)
• Determines the best path to destination
• Performs packet routing and fragmentation
• Includes protocols: IP, ICMP, ARP, RARP
4. Transport Layer
Provides end-to-end communication and reliability.
• Uses TCP for reliable, connection-oriented communication
• Uses UDP for fast, connectionless, low-overhead delivery
• Handles segmentation, sequencing, and reassembly
• Provides error detection, correction, and flow control
5. Application Layer
Provides network services to end-user applications.
• Supports protocols like HTTP, FTP, SMTP, DNS, DHCP, SNMP
• Responsible for data formatting and communication services
• Directly interacts with user applications
• Handles resource sharing, remote file access, email, web browsing
Conclusion: Hence,. Studied OSI and TCP/IP reference model with respect to
protocol suite.
Practical No.7
Aim: Write a program for Hamming code generation for error detection
and correction.
Key Points:
• Developed by Richard Hamming
• Uses parity bits for error detection and correction
• Detects up to 2-bit errors
• Corrects 1-bit error
• Parity bits placed at positions 1, 2, 4, 8...
• Widely used in networking and memory systems
Program:
#include <stdio.h>
#include <math.h>
r = calculateParityBits(m);
int total = m + r;
// Error detection
int received[30];
printf("\n\nEnter received code:\n");
for (i = 1; i <= total; i++) {
scanf("%d", &received[i]);
}
int errorPos = 0;
if (parity != 0) {
errorPos += pos;
}
}
if (errorPos == 0) {
printf("\nNo error detected.\n");
} else {
printf("\nError detected at position: %d\n", errorPos);
received[errorPos] ^= 1; // correct the error
printf("Corrected Code:\n");
for (i = 1; i <= total; i++) {
printf("%d ", received[i]);
}
}
return 0;
}
Output:
Enter number of data bits: 4
Enter data bits:
1011
Aim: Write a program for error detecting code using CRC CCIT (16 bits).
Introduction (CRC–CCITT)
Cyclic Redundancy Check (CRC) is a popular error detection technique used in
data communication to detect accidental changes in transmitted data. CRC works by
treating data as a binary polynomial and dividing it by a fixed generator
polynomial. The remainder obtained is appended to the data before transmission.
One common standard is CRC-CCITT (16-bit), which uses the polynomial 0x1021
(x¹⁶ + x¹² + x⁵ + 1). It is widely used in protocols like X.25 and HDLC.
Key Points:
▪ CRC stands for Cyclic Redundancy Check
▪ CRC-CCITT uses 16-bit polynomial (0x1021)
▪ Detects burst errors efficiently
▪ Used in protocols like HDLC
▪ More reliable than parity and checksum methods
Program:
#include <stdio.h>
#include <string.h>
while (*data) {
crc ^= (*data << 8);
for (int i = 0; i < 8; i++) {
if (crc & 0x8000)
crc = (crc << 1) ^ POLY;
else
crc <<= 1;
}
data++;
}
return crc;
}
int main() {
char data[100];
if (verify == crc)
printf("No error detected.\n");
else
printf("Error detected in data.\n");
return 0;
}
Output:
Enter data string: HELLO
CRC-CCITT (16-bit) value: 34D2
No error detected.
Introduction:
To study network IP and configuration commands, use tools like ipconfig
(Windows) or ifconfig/ip (Linux) to display IP addresses, subnet masks, and
default gateways. Essential commands include ping for connectivity,
tracert/traceroute to trace paths, and netstat for active connections. These
utilities diagnose, configure, and monitor network health, crucial for
troubleshooting TCP/IP networks.
Introduction:
Cisco Packet Tracer is a free, powerful network simulation tool used to design,
configure, and troubleshoot networks. To study, download it via the Cisco
Networking Academy. Perform labs by dragging devices (routers, switches,
PCs) onto the workspace, connecting them, and using Simulation Mode to
visualize packet flow.
Conclusion: Hence,. Studied the packet tracer and to be performing with there
steps.