What is Switching?
Switching is the process of transferring data packets from one device to another in a network,
or from one network to another, using specific devices called switches. A computer user
experiences switching all the time for example, accessing the Internet from your computer
device, whenever a user requests a webpage to open, the request is processed through
switching of data packets only.
Switching takes place at the Data Link layer of the OSI Model. This means that after the
generation of data packets in the Physical Layer, switching is the immediate next process in
data communication.
Introduction to Switch
A switch is a hardware device in a network that connects and helps multiple devices
share a network without their data interfering with each other.
What is Network Switching?
A switch is a dedicated piece of computer hardware that facilitates the
process of switching i.e., incoming data packets and transferring them to
their destination. A switch works at the Data Link layer of the OSI Model.
A switch primarily handles the incoming data packets from a source
computer or network and decides the appropriate port through which the
data packets will reach their target computer or network. A switch decides
the port through which a data packet shall pass with the help of its
destination MAC(Media Access Control) Address.
The switching process involves the following steps:
Frame Reception: The switch receives a data frame or packet from a computer
connected to its ports.
MAC Address Extraction: The switch reads the header of the data frame and
collects the destination MAC Address from it.
MAC Address Table Lookup: Once the switch has retrieved the MAC Address, it
performs a lookup in its Switching table to find a port that leads to the MAC Address
of the data frame.
Frame Transition: Once the destination port is found, the switch sends
the data frame to that port and forwards it to its target computer/network.
Types of Switching
There are types of switching methods:
Circuit Switching
Packet Switching
Virtual circuit switching
Circuit Switching: In this type of switching, a connection is established
between the source and destination. This connection receives the complete
bandwidth of the network until the data is transferred completely.
This approach is better than message switching as it does not involve
sending data to the entire network, instead of its destination only.(landline)
Packet Switching: This technique requires the data to be broken down into smaller
components, data frames, or packets. These data frames are then transferred to their
destinations according to the available resources in the network at a particular time.
This switching type is used in modern computers and even the Internet. Here, each
data frame contains additional information about the destination and other information
required for proper transfer through network components.(web pages, internet)
Virtual-Circuit Packet Switching: In Virtual-Circuit Packet switching, a logical
connection between the source and destination is made before transmitting any data.
These logical connections are called virtual circuits. Each data frame follows these
logical paths and provides a reliable way of transmitting data with less chance of data
loss.(Phone call to landline)
Data Link Controls (Detailed Explanation)
The Data Link Layer is Layer 2 in the OSI model. It provides node-to-node delivery of
frames and ensures reliable communication over the physical layer.
1. Framing (Data Encapsulation)
Framing is the process of encapsulating data into frames, with added control information for
transmission.
🔹 Purpose:
Defines start and end of each frame.
Prevents mixing of data from multiple frames.
Supports error control and synchronization.
2. Flow Control
Flow control ensures that the sender doesn't overwhelm the receiver by sending data faster
than it can process.
🔹 Key Concepts:
Receiver has limited buffer space.
Without flow control, data may be lost or corrupted.
🔹 Protocols:
🔸 A. Stop-and-Wait Protocol
Sender sends one frame, waits for acknowledgment before sending the next.
Pros:
Simple
Easy error recovery
Cons:
Poor efficiency on long-distance links
🔸 B. Sliding Window Protocol
Allows multiple frames to be sent before acknowledgment.
Uses sequence numbers, window size, and ACKs.
Advantages:
Efficient
Suitable for high-speed links
3. Error Detection and Correction
Ensures the accuracy of transmitted data. Errors may arise due to noise, interference, etc.
🔍 A. Error Detection Methods
1. Parity Check
Adds a parity bit (0 or 1) to make total 1s either even or odd.
Checks for single-bit errors.
Example:
Data: 1010001 → Even Parity → Parity bit = 1 → Sent: 10100011
Limitation: Fails to detect even-numbered bit errors.
The 1’s complement of a binary number is obtained by flipping all its bits. 0 becomes 1,
and 1 becomes 0. Positive numbers remain unchanged whereas negative numbers are
represented by taking the 1’s complement of their positive counterparts.
For example, in 8-bit notation:
+9 is represented as 00001001.
-9 is represented as 11110110, which is the 1’s complement of 00001001.
Examples:
Input: s = “0111”
Output: 1000
Explanation: Each bit is flipped, i.e. 0 becomes 1, and 1 becomes 0.
The 2’s complement of a binary number is obtained by finding the 1’s
complement (flipping all bits) and then adding 1 to the result. In 2’s complement
representation
Input: s = “0111”
Output: 1001
Explanation: Find 1’s complement -> 1000, then add 1 -> 1000 + 1 = 1001
2. Checksum
Data is divided into equal segments (e.g., 16 bits).
All segments added using 1’s complement arithmetic.
Result’s complement is the checksum.
Example (16-bit):
Data 1: 10110011 10101010
Data 2: 01110101 11110000
Sum + complement = 11111111 11111111 → No error
Used in: TCP/IP protocols
3. Cyclic Redundancy Check (CRC)
Treats the frame as a binary polynomial.
Sender divides data by a generator polynomial (G(x)).
Remainder is the CRC (appended to frame).
Receiver re-divides the received frame by G(x).
Example Generator Polynomial: G(x) = x^3 + x + 1 → 1011
Reliable for: burst errors, single-bit, and double-bit errors.
🧠 B. Error Correction Method
4. Hamming Code
Allows detection and correction of single-bit errors.
Uses redundant (parity) bits placed at positions that are powers of 2 (1, 2, 4, 8...).
🔹 Formula to find number of parity bits (r):
2r≥m+r+12^r \geq m + r + 12r≥m+r+1
Where:
m = data bits
r = redundant bits
🔹 Example:
For 4 data bits, at least 3 parity bits are needed.
Positions: P1, P2, D1, P4, D2, D3, D4
Parity bits cover combinations of data bits.
Correction:
On receiving, parity bits are rechecked.
If any parity fails, the binary result gives the error bit position.
Summary Table:
Technique Type Detects Corrects Used In
Parity Bit Error Detection Single-bit ❌ Simple systems
Checksum Error Detection Most errors ❌ TCP/IP
Burst + multiple
CRC Error Detection ❌ Ethernet, storage
errors
Hamming Error Memory (RAM),
1-bit, detects 2-bit ✔️(1-bit)
Code Correction communication
Would you like me to create diagrams for:
Sliding Window Protocol
Framing with Bit Stuffing
Hamming Code Example with Bit Positions
Let me know and I’ll generate visuals to complement the theory!