Home Topic 3 Last Next


Explain how data is transmitted by packet switching.


Teaching Note:


Sample Question:



JSR Notes:


Through packet switching a file traveling through a network is broken up into pieces and those pieces each find their own best route through the pathways of the network, and the file is re-assembled at the other end.


An interesting, and awesome video showing how the Internet works, particularly, via packet switching.

Intro - Multiple Routing Analogies:

- A school team that is flying to a tournament has their flight cancelled at the last minute, and they have to reschedule all the members of the team on new flights. The orignal flight was direct from from Los Angeles (L.A.) to New York City (N.Y.C.). To re-book them as soon as possible, all ways of getting connecting flights from L.A. to N.Y.C. can be considered, and there are literally thousands of permutations.
- Some team members could fly L.A. to Chicago, and then on to N.Y.C.
- And still others will have to go L.A. to Phoenix, then Phoenix to Dallas, and then Dallas to N.Y.C.
- etc.
But all will ultimately meet up, all be-it at different times, in New York City.

- Taking a group of ISB students from school to CENTRAL World in 6 different taxis. Each taxi could potentially take a slightly, or even significantly different route.

Intro - Mac Network Utility Traceroute

Even before going any further, try running a traceroute of any website in Network Utility to see number of nodes a packet goes through. (This does not work behind the school firewall, so you could try this at home.) Here is a traceroute to this website from Bangkok. Curiously it goes to Hong Kong before ending up in Singapore, as you can see by the "hk" and "sg" domains used. My main hosting is through GoDaddy in America, but I pay for use of half a dozen or so "CDN" servers around the world, which keep a local copy of my website closer to, in this case, Thailand.


*** The structure and a lot of the content for this section come from the former IB CS curriculum "yellow and red" textbook "Computer Science Java Enabled, 2nd Edition, Andrew Meyenn, Richard Jones, pages 343 - 345.


Packet Switching

Firstly, recall the Definition of Data Packet

Recall that a data packet was defined already in 3.1.6. Packets are groups of data transmitted across a network. A data packet is typically fixed in length, and its structures is determined by the protocol being used. But the contents of the packet typically include:

- the data payload itself, and
- the header, which has "metadata" (i.e. data about the data) such as:
           - the source address,
           - destination address,
           - the packet number, to be used for reassembling the file in the correct order.
           - whether or not there is compression, and if so, what kind.
           - information for error checking (a bit more on this at the bottom of the page, and a lot more on this at 3.1.7.)
           - "TTL" Time to Live - a counter that decrememts each node that is visited (when it reaches 0 the packet is assumed to be lost and so is trashed.)

(This is just an example, and speifics depend on the specific protocol.)


Full Description of Packet Switching

Packet switching is a network transmission technique in which data is sent in individual fixed length groups called data packets. So a single file is broken up into individual packets, and each of those packets is transmitted separately. The key feature is that the individual pockets don't have to follow the same route, but can be sent over the best available link. Each packet is numbered, so when all packets reach their destination, they are reassembled in the correct order.

Each packet also has a "Time to Live" counter, which decrements as it passes through each node along the pathway. If the counter reaches zero, that packet is assumed to be lost, and the node discards that packed. Re-transmission of that particular packet will soon be requested. (Depending on the size of the network being used, the time to live could be as high as 256 hops.)

(At this point, make sure of understanding with a "stickies" file, broken up into packets, and demo of them going through various paths and nodes on the whiteboard.)

Packet Switching vs. Circuit Switching

Packet switching is in contrast to circuit switching, in which there is a fixed link to send the data transmission. That fixed line will be a dedicated connection which can permit transmission at a constant bit rate, with constant delays between nodes. So circuit switching is better for all streaming situations. But because it's dedicated, it costs a lot more. In fact, the costs may be charged for per day/month, so you are paying for the line even when it's not in use. And the other disadvantage of circuit switching, compared to packet switching, is it is subject to complete failure of a certain transmission, if the (single) link is broken.

Advantages of Packet Switching (for the Internet in particular)

1. If any one link is broken or unavailable during transmission, another link can be used, and the transmission can continue. (With circuit switching, if the link is broken, the link is broken.)

2. Congestion can be avoided, since more than one route can be used, rather than having to use one particular dedicated route. This makes the overall network faster.

3. Small delays can usually be tolerated, so there's no need for circuit switching. For example, e-mail transmission as compared to streaming content, and the majority of files which are transferred back and forth on the Internet. Think of a picture, for example; if a bunch of pixels of it take a few more milliseconds to arrive, big deal; you won't even notice.

4. Cheaper for individuals to use, since no need for dedicated lines and their cost.



Role of Nodes in Traffic Management

Connecting the wired and wireless links of a network are nodes. At each nodes is a router, which manages the data traffic. The router inspects each packet and routes it on to what it deems to be the best link, as it continues its journey. There are two factors to be considered by the routing algorithms: determining the shortest path, and determining free notes.

But network traffic management by routers involves not only ensuring that particular packets are passed on to an appropriate link, they must also manage the big picture, and assure that overall congestion of the network is avoided.


The Packet Switching Protocol TCP/IP

Packet switching protocols establish the rules for node-to-node communication across a network. The Internet has established TCP/IP is the default standard protocol for packet switching. TCP/IP is a combination of two separate protocols, TCP, and IP.

Transmission Control Protocol, TCP, is a transport level protocol, in which transportation of data across links is controlled, ensuring that data arrives at its destination and is assembled into the correct order. In particular, it is a transport level protocol of the OSI model. (Analogy: Amazon truck driver.)

The Internet Protocol, IP part of TCP/IP defines the format of packets and provides an addressing system. It is a network layer OSI protocol. (Analogy: packaging department at the Amazon warehouse.)

IP Addresses

Part of IP is the addressing of devices with "IP addresses". Typical computer users don't interact with these address; rather we use their associated World Wide Web addresses, which we type into browsers. So, for example, www.johnrayworth.info actually has the IP address DNS (Domain Name Servers) look after the linking of IP addresses to domain names behind the scenes.

The version 4 of IP protocol, called IPv4, uses four bytes for each address.
And the version 6 of IP protocol, called IPv6, uses sixteen bytes for each address.

An IP address is binary numbers but usually we see IPv4 represented in decimal, or IPv6 represented in hexadecimal, which are both easier for human readers.

: 32-bit addresses, so     2 ^ 32,   or    ~4 billion    possible IP addresses
or, ~4 000 000 000 different devices that are uniquely addressable

Example IPv4 addresses in decimal:

: 128-bit addresses, so     2 ^ 128,   or   4 billion x 4 billion x 4 billion x 4 billion    different IP address
or, 256 000 000 000 000 000 000 000 000 000 000 000 000 different devices that are uniquely addressable

Example IPv6 address in hexadecimal:


Packet Errors

A crucial part of any networking protocol is how is deals with potential errors.

One possible source of error is collisions, in which the same link is attempted to be used by two packets at the same time. In such a case, the router will communicate with the sender of the packets and the packets will be resent.

But data integrity errors can also occur, particularly as a result of interference, either from other wires, or various other electromagnetic sources. So upon arrival at its destination, a data packet is checked to see if there had been any error in transmission - there are checks to see if what was intended to be sent is what was received; this is done, for example via check bits, or parity checking. (There is more on these error checking algorithms back in 3.1.7). If an error is found, the destination router will request a resend.

Obviously the higher the error rate the slower the performance of the transmission.




- In packet switching a file is broken up into packets of a fixed length and each packet is transmitted separately.

- Each packet includes a packet number for reordering at the destination.

- Each packet has a counter which decrements as it passes through a node, and if it gets lost, then after a certain number of hops, the packet is trashed.

- Packet errors can occur as result of collisions or interference; retransmission is requested in these cases.

- Packet switching is suitable when small delays can be tolerated (i.e. email transmission), or the complete transmission doesn't have to happen all together.


And back to the assessment statement:

Ultimately you should be prepared to explain, in summary, this concept in a 5-6 mark kind of an answer. But you should also be prepared to address certain parts of it - in the same way that some of my homework questions will pin-point important concepts.






JSR Notes - FORMER CURRICULUM - 6.4.3 Describe packet switching.:

Once again, lots of good stuff in the text, but I’ll focus you a bit here.

First the analogy. You're in O2 stadium after a concert, with 99 of your friends (...yes, 99. Think Facebook.) There are two ways you can try to make it to the meeting point outside. Option 1: All hold hands, and go together (imagining that many other large groups are doing the same thing...) "Nope, no letting go of hands. Just wait for that group to pass..." etc.
Option 2: Everyone just go as quickly as they can, whatever route they choose, squeezing in and out of people along the way, and re-assemble back at the meeting point. (And the sad part of this analogy: "Anyone who doesn't make it there in 5 minutes, we're leaving without you!")

(Actually, analogies of traffic from one part of town to another is more accurate, or even the way a "peloton" of cyclists in a race splits up some times. But the analogy above is a bit more fun.)

Certainly you should be aware of the various things that need to be in each packet and why. But the big thing here is what the teaching note focuses in on: the “switching” in packet switching. Yes, in packet switching the data is grouped into small packets which are sent. But the reason that they are divided up into smaller groups in the first place is that those packets can then switch the route that they are taking depending on traffic in given routes. In fact, theoretically, even with a very large file being downloaded to your computer the packet switching way could have each and every packet following a different route.

And in terms of the possible routes a packet can take, it’s almost infinite. The analogy of flying from New York to LA is a good one; there is not just one direct way to do that trip; you can literally come up with tens of thousands of different routes through major airports and minor along the way, but always be going in a Westerly direction. Doing a “traceroute” in the Network utility of the Mac OS is an interesting visual way to see just how many “hops” there can be from node to node as a packet finds its way (or not) to its destination.

And that’s the other teaching note not to forget: Packets can indeed get “lost”; that’s why the “time to live” information is decremented as it makes its way around.