Packet switching

Martin McBride, 2017-10-07
Tags packet switching circuit switching
Categories networks network hardware

Here is a diagram of a simple star network. It shows computer A sending data to computer D:

Now what would happen if computer B also wanted to send data to computer D, a the same time? This isn't an unusual situation. D might be the file server, and the other computers might be reading and writing files to it all the time.

Networks use packet switching to cope with this.

Packet switching

The idea of packet switching is quite simple:

  • The sending computer A splits the data into "packets", usually about 512 bytes each.
  • It sends the packets across the network, one at a time.
  • The receiving computer D accepts all the packets, and joins them together.

If A and B try send data to D at the same, the will switch alternate between sending some packets from A and some packets from B. It will appear as if both sets of data are being transferred simultaneously.

Packet switching in mesh network

In a [[Mesh network topology|mesh network]], there are usually several different routes between any two computers on the network.

In that case, when data is transferred it is possible that some of the packets will take different routes through the network. Some packets from A to D might go directly, some might go via node E, some via node B, for example.

Packet switching is a feature of TCP/IP, that is used by the Internet and most local area networks.

Contents of a packet

What does a packet contain? The content is divided into two parts:

  • The header, containing information about the packet.
  • The payload, the actual data being transferred.

The header contains the following information:

  • The IP addresses of the source and destination of the packet.
  • The total number of packets in this communication. If a 1MByte file is being transferred, it might be split into a couple of thousand packets.
  • The sequence number of the packet. A unique number for each packet within this communication.
  • Error checking codes.

The sequence number is required because the packets might not arrive in the order they were sent. If different packets arrive by different routes, it is possible that some later packets will arrive before some of the earlier packets.

The information in the header allows the device receiving the packets to put them back together to recreate the data that was sent.

Circuit switching

An alternative to packet switching is circuit switching.

Consider the star network above. In a circuit switching network, if A wanted to send data to D, the switch would connect the two computers directly, and they would have dedicated use of the connection until they had finished the data transfer. If B wanted to send data to D, it would have to wait until A was finished.

The vast majority of modern networks use TCP/IP, which uses packet switching. Circuit switching is quite rare.

Older analogue phone lines used circuit switching - when you made a call, your phone would be directly connected to the person you were calling until the call ended. Modern services such as Skype send audio data over the Internet using packet switching.

Copyright (c) Axlesoft Ltd 2021