Want to keep learning?

This content is taken from the Raspberry Pi Foundation & National Centre for Computing Education's online course, An Introduction to Computer Networking for Teachers. Join the course to learn more.

Hubs and Switches in Star Topologies

In this step, we will look at the role of a hub or a switch in a star network.

You will also learn more about how addresses and other fields are added to data that is sent, about the idea of encapsulation, and about how to build an Ethernet frame.

The Ethernet Hub

In the previous step you learned that bus topology was phased out in favour of star topology, which has a central connection point. Initially this was a hub. Each device connected to it using a dedicated UTP cable that linked into one of the hub’s ports.

On its way to the hub, a signal will have picked up some noise. As long as the noise does not cause the signal to cross a threshold level, the hub can recreate each bit, effectively removing the noise. This process is called regeneration. If there is too much noise, errors occur during regeneration: a binary 1 may be regenerated as a binary 0 or vice versa.

Hub regenerating a signal. A signal is sent from a PC to a Hub and onwards. The original signal from the PC is shown as a square wave representing bits 10010. By the hub the signal has become "original + noise". Where the signal was flat in the original signal, it is now moving up and down . However this signal never crosses a threshold (shown as a purple dashed line) between the heights that represented 1 and 0 in the original signal. After the hub the "regenerated signal" is the same as the "original signal".

The hub has no understanding of what the signals mean. It just sees them as electrical signals to be regenerated and sent to all other connected devices.

CSMA/CD

Unlike the wireless Aloha network, devices in a wired network can detect whether another device is transmitting data.

Before sending data, a device first determines whether anyone else is transmitting by checking for a carrier signal on the wire. If the wire is clear, the device starts to send its data. If the device detects another transmission, it waits until the wire is clear before trying again. However, another device may have also sensed the wire was clear and also started to transmit. This would cause a collision, so all the data would be corrupted. To combat this, each device monitors the wire while it is sending its data. If a collision is detected, all devices stop transmitting and wait a random time before retrying. This system of Carrier Sense, where there is Multiple Access to the cable and a Collision Detection system, is known as CSMA/CD. This allows multiple devices to access the same connecting media.

Fragmentation

To stop any one device hogging the wire by sending a large amount of data as one block, there is a rule that a device cannot send more that 1500 bytes of data in one go. Data larger than this must be split into smaller chunks that are sent separately — this is called fragmentation. Fragmentation gives the other devices a chance to slot in their transmissions in between, thus ensuring fair access to all devices.

A block of 4000 bytes of data being fragmented into  2 x 1500 byte and 1 x1000 byte chunks.

Ethernet protocol, MAC addresses and frames

A set of conventions and rules that govern the communications between devices is called a protocol. The 1500 byte limit, the CSMA/CD rules, and the need to send destination and recipient addresses are all part of the Ethernet protocol.

An Ethernet Frame, made up of a header, data, and a trailer. The header is made up of a Destination address (DA) with a width of 6 bytes, a Source address (SA) with a width of 6 bytes, and a Type of width 2 bytes. The data has a width of 46 to 1500 bytes. The trailer contains a FCS, with a width of 4 bytes.

The structure of the data sent via the physical media is called a frame. An Ethernet frame has five different sections, called fields, for the pieces of information necessary for transmission.

  • One field is for the data that is being transmitted.

  • Two fields contain the destination and source addresses, which are called MAC addresses (for ‘Media Access Control’). They are 48 bits long, and are usually referred to in hexadecimal notation, e.g. cd:f1:24:e4:89:a1.

  • The Type field is used to indicate what type of data the frame is carrying. You will learn more about this in a later step.

  • The Frame Check Sequence (FCS) is used to detect whether errors have occurred during transmission.

The actual process used to generate the FCS is called Cyclic Redundancy Check (CRC) and is a complex mathematical process beyond the scope of this course. However, it is similar in concept to a checksum: the sender adds the data values together as it sends, and appends this sum to the end of the data in the FCS. The receiver adds the data values together as they arrive and compares this sum to the appended one; a difference in the sums indicates an error. Try the class activity in the PDF attached to this step to see checksum in action.

The four non-data fields together ‘wrap around’ the data as the Ethernet Frame, in what is called encapsulation.

Ethernet Frame encapsulating the data. The frame is split up into sections labelled DA, SA, Type, Data and FCS. The text "Data" is surrounded by an additional yellow border.

Animation showing how a frame is encapsulated at the sending computer. Data comes from the "Computer data/address bus", into the Network interface card. A "Destination MAC address" also comes from this bus, in front of the data. A "Source MAC address" also appears in front of the destination MAC address. All three of these travel as a signal out of the network interface card (simultaneously leaving the computer). .

A signal consisting of the "Source MAC address", "Destination MAC address" and "Data" enters the Network interface card (which is part of the computer). The NIC MAC address comes from the "Computer data/address bus" and is compared with the "Destination MAC address". The "Source MAC address" and "Data" are then copied into the "Computer data/address bus"

Note that there are different frames for different media types, such as point-to-point, fibre-optics, dial-up, ADSL, wireless, 3G/4G/5G, etc.

Switch-based LANs

Unlike an Ethernet hub, a switch learns the address of each device connected to its ports by looking at the source addresses in the Ethernet frames it receives. It then builds a table, mapping each device to the port it is connected to, so that it can switch incoming frames to the correct device by looking at the destination address in the incoming frame. If the destination address is not in the switch’s table, the switch defaults to a hub behaviour and sends the frame out on all ports. Modern switches are capable of switching traffic between multiple ports simultaneously.

Animation showing the switch based star network in action. Six computers, labelled A, B, C, D, E and F are connected to ports 1 to 6 respectively of a Switch. Various computers show a message they want to send, with its source and destination letter given. These travel as signals to the switch, and after a short delay are sent out of the correct port to head to the computer matching the destination letter. The signals are shown as different colours to make this clear.

A network with a switch at the core and multiple devices connected in a star topology is called a Local Area Network, or LAN; the LAN may itself be connected to another network.

Next up

In the next section, you will take a quiz to review what you’ve learned about connections, hubs, switches, and Ethernet frames.

Questions

  • What happens to an electrical signal when the interference is so bad that the noise takes the signal over the threshold?
  • What happens when you plug a new device into a switch?

Share your ideas and answers in the comments section below.

Share this article:

This article is from the free online course:

An Introduction to Computer Networking for Teachers

Raspberry Pi Foundation