# Packet Switching
## What is Packet Switching
Packet switching is a method of data transmission in which data is divided into small units called packets, each packet is routed independently through the network, and the packets are reassembled at the destination. Unlike circuit switching where a dedicated path is reserved for the entire session, packet switching allows multiple communications to share the same network resources. Each packet carries addressing information so that routers can forward it toward its destination. The internet is based on packet switching.
## How Packet Switching Works
The sending application passes data to the Transport layer, which divides it into segments. The Network layer wraps each segment in a packet containing the source IP address, destination IP address, and other control information. Each packet is forwarded from router to router through the network. At each router the destination IP address is examined and the packet is forwarded toward the destination based on the router's routing table. Different packets from the same communication may take different paths through the network. At the destination all packets are collected and reassembled into the original data stream.
## Store and Forward
Most packet-switched networks use store-and-forward switching. When a packet arrives at a router, the router receives the entire packet, stores it in a buffer, examines the destination address, and then forwards it to the appropriate next hop. This introduces a small delay at each hop but allows the router to check the packet for errors before forwarding it.
## Advantages of Packet Switching
Packet switching makes very efficient use of network resources because bandwidth is shared among many communications. When one communication is idle, other communications can use the available bandwidth. The network is resilient because packets can be routed around failed links. Packet switching scales well to support large numbers of simultaneous communications. It is well suited to the bursty nature of data traffic.
## Disadvantages of Packet Switching
Packet switching introduces variable delay because packets may be queued at routers when the network is congested. Different packets from the same communication may arrive out of order if they take different paths. There is no guarantee of bandwidth for any particular communication. These characteristics make packet switching less suitable for real-time applications that require consistent low latency, though modern networks use Quality of Service mechanisms to improve performance for such applications.
## Datagram vs Virtual Circuit
In datagram packet switching each packet is routed independently based on its destination address and packets may take different paths. This is how the internet works with IP. In virtual circuit packet switching a logical path called a virtual circuit is established before data transmission. All packets follow the same path but the path is established through a signaling process rather than by reserving physical resources. ATM and MPLS use virtual circuit concepts.Back to Subject