All posts by computerexplained

Building blocks of Networking

Any computer network can be thought of as a collection of nodes that are interconnected using different sorts of links.

The devices such as routers, switches, your mobile phone, your laptop computer are the nodes in the network.

The cables and wireless mediums that are used to interconnect them are the links in the network.

In general there are two types of links. i.e. Wired and Wire-less.

1.2 Wired Links

1.2.1 Twisted Pair Cable

A Twisted Pair Cable (Source: wikipedia)

As the name suggested, two wires are twisted together to form a twisted pair cable. This is the most common form of network cable type.

These wires are twisted together to cancel out (induced currents are nearly equal) the noise currents induced in each of the wires due to the electromagnetic fields.

Twisted pair cables can be further classified into two categories depending upon their shielding.

Unshielded Twisted Pair (UTP)
UTP (Source: wikipedia)

The UTP cables are typically made with copper wires and insulated by colored insulation made from polyethylene. These twisted pairs are then covered with a polyethylene jacket.

Shielded Twisted Pair (STP)
S/FTP (Source: wikipedia)

These twisted pair cables can be further shielded with metal foils to prevent electromagnetic interference.

Depending upon the shielding type they can be further classified.

F/UTP, U/FTP and F/FTP (Source: wikipedia)
F/UTPFoiled outer Jacket/Unshielded twisted pair
U/FTPUnshielded outer Jacket/Foiled twisted pair
F/FTPFoiled outer Jacket/Foiled twisted pair
S/FTPShielded outer Jacket/Foiled twisted pair

Categories of Twisted Pair Cables (CAT#)

Twisted pair cables can be grouped into few categories (that’s why they are called CAT cables) based on criteria such as signal bandwidth, attenuation, and cross-talk.

CAT12 pair copper UTP (Old telephone cables)
CAT5The most widely used type in LAN. 100Mbps-1000Mbps data transfer rate.
CAT6Standardized cable for Gigabit ethernet. Backward compatible for many CAT types.
Few CAT cables and their Usages.

Registered Jack (RJ) used in Twisted Pair Cables

Registered Jack is a standardized telecommunication interface. RJ11, RJ14, and RJ25 are the most widely used interfaces in RJ connector family. Few RJ connector types are mentioned below.

RJ Connectors (Source: wikipedia)

RJ11 – Widely used in landline telephone networks. Although there are 4 contact positions in this jack only 2 of them are used.

RJ14 – 4 Contact positions are used, i.e. It has 2 separate lines.

RJ45 – 8 Contact positions are used, i.e. It has 4 separate lines. Most commonly used in ethernet with CAT5/CAT6 cable types.

Cabling/Wiring Standards in Twisted Pair Cables

A typical twisted pair cable has 4 twisted pairs. These pairs have 4 distinct colors. In each twisted pair one wire is solid colored while the other one is stripped in the same color.

568A and 568B are the two main cabling standards to tell which order the wiring should be carried out with the RJ5 interface.

568A – Green pair is used to transmit signals, while Orange pair is used to receive. Others are unused.

568B – Orange pair is used to transmit signals, while Green pair is used to receive. Others are unused.

Colored Pairs of Wires (Source: wikipedia)

Cable types based on which two nodes are connected

Straight through and Cross-over cables are used based on the two-node (device) types connected. There are two types of nodes (devices).

Data Terminal Equipment (DTE): Nodes that act as a source or destination for data. (eg: Personal computers, Printers and Routers, etc.)

Data Circuit-terminating(communicating) Equipment (DCE): Nodes that are used to establish, maintain and terminate communication network sessions between a source and its destination. (eg: Modems, Hubs, and Switches, etc.)

Straight Through Cable: Both ends are either 568A or 568B.

Used to connect a DTE type node with a DCE. (Different type nodes)

Cross-over Cable: One end is 568A while the other end is 568B.

Used to connect a either two DTE type nodes or two DCE type nodes. (Same type nodes)

In modern nodes (devices) have the function called Auto MDI-X for ports. If this is enabled for a port in either side of the two connected nodes, two nodes will work perfectly regardless of the cable or node type is by configuring the connection wires automatically.

1.2.2 Coaxial Cable

Coaxial Cable (Source:

Coaxial has a plastic jacket on the outside. There is only one wire (centre core) with a layer of insulation (dielectric insulator) made of plastic and other materials. The dielectric insulator is then wrapped with a metallic shield.

Coaxial cables are wildly used as TV antenna signal cables, video and voice transferring cables and in computer networks.

Most commonly RF connectors (F Connectors) are used with coaxial cables.

Coaxial F Connectors (Source:

1.2.3 Optical Fiber Cables

Fiber optic cables can be used to transmit data in very high bandwidths for longer distances. Signals can travel for longer distances with lesser amounts of loss compared to metal wires. A major drawback of metal cables is electromagnetic interference. On the other hand, fiber optics are immune to electromagnetic interference.

Small Form-factor Pluggable (STP) is a compact transceiver used to connect optical fiber ends which can be used for both data and telecommunication.

1.3 Wire-less Links

Selected ranges of the electromagnetic spectrum are used in data communication as wireless guided medias. Commonly used such ranges are Radio, Microwave and Infrared.

1.3.1 Radio Signals (RF)

Radio signals have a lesser frequency compared to other ranges. These signals are used in radio communications, video and audio transmission, and data communication.

1.3.2 Mobile Signals

Mobile signals are widely used in mobile phones for voice and data communication. There are many generations of technologies such as 2G, 3G, 4G and 5G etc.

1.3.3 Infrared (IR)

IR is widely used for short distance data transmission between mobile devices, in remote controllers, short distance wireless video transmission etc.

1.3.4 Bluetooth

Bluetooth is one technology that uses microwaves for data communication. Bluetooth is widely used in wearables, mobile devices, audio devices.

1.3.5 Wi-Fi

Wi-Fi is the most widely used trusted wireless media in the world. Wi-Fi uses microwaves for communication.

1.3.6 Near Field Communication (NFC)

Short-range (10cm or lesser) wireless link with really low transmission bandwidth. Widely used in smartphones and e-payment systems.

Here let’s see different types of nodes (devices) that are used to create computer networks first.

2.1 Network Interface Card (NIC)

In earlier times the computer motherboards has not shipped with network interfaces. Therefore, a separate card called “Network interface card” needed to be pluged through the PCI slot of the motherboard to allow the computer to connect to a computer network. One of the earlierst types of NIC had a inbuilt modems with RJ11 interface, where the normal telephone line can be used to connect to the internet via dial up connections.

Nowadays most widely used network interface cards have the RJ45 interface letting it connect to a Ethernet network.

Generally, a NIC can be considered as a separate card which can be plugged to a motherboard to obtain different network interfaces.

A network interface

2.2 Network Hub (Layer 1 – Physical Layer)

Hubs are known as a layer 1 (the electronic signals), broadcasting type device. Hub is used to connect multiple Ethernet devices together to make a single network segment. When one device which is connected to the Hub sends a message, the hub broadcast that message to every connected device into the Hub.

This diagram show what happens in Layer 1

2.3 Switch (Layer 2 – Link Layer)

Switches can be introduced as a more advanced version of the Hub. Switches are used to connect devices in the same network. Switches are typically considered to be layer 2 devices ( can process only mac addresses). Unlike hubs, the switches can forward the packets to the relevant destination port. But more advanced switches can process data at layer 3 incorporating routing functionalities.

This diagram shows what happens in Layer 2

Layer 2 devices can read and process MAC addresses. Layer 2 devices maintain a table of records with the information of which device (MAC address) is accessible from which interface. This table is known as MAC table or CAM table.

When a network packet is received from one interface, the switch compares the destination MAC address with the MAC table to find the relevant interface to forward the packet. If there is a match in the MAC table, the switch will simply forward the packet to that interface.

If there is no match in the MAC table, the packet will simply broadcast to all the interfaces except for the interface in which the packet received.

Scenario 1: Device A is going to send a packet to Device B.

Device A sets the source MAC address as MAC-A and destination MAC address as MAC-B and moves the packet to the physical layer. The physical layer encodes the packet into signals and sends the signals out from the interface. (Let’s forget about IP addresses for now. We will later see how IP addresses are useful in routing)

The signals are propagated through the link (wire) and Switch 1 receives the signals from the interface0. The physical layer decodes those signals and then the packet moves up to Layer 2. In there the destination MAC address (MAC-B) is compared against the MAC table and finds that the packet needs to be forwarded internally to interface1. The switch encodes the packet again and puts the packet out from interface 1 as electronic signals.

The signals are then received from the interface of Device B. Then the signal is decoded and move to Layer 2. In Layer 2, Device B compares the destination MAC of the received packet with its own MAC address. If that does not match the packet is simply discarded there. But in here since both of them match, the packet moved to the higher layers and the message is received to Device B’s operating system.

Scenario 2: Device A is going to send a packet to Device B. But let’s assume that Switch 1’s MAC table has not the matching entry yet.

The same thing in Scenario 1 happens till Layer 2 of Switch 1. In there, since there is no matching entry in the MAC table, the switch will broadcast the same packet through all the interfaces except for the interface0. Eventually, Device B, Device C, and Device D will receive the packet. But in Layer 2 of those devices, when they compare the destination MAC address to their own MAC addresses only Device B will move the packet to the operating system. Other devices will simply discard the packets.

2.3 Router (Layer 3 – Network Layer)

The router is a more advanced version of the switch. Routers are layer 3 devices ( can process IP addresses ). Routers are used to connect logically or physically different networks. Routers are intelligent enough to read the destination address of the packets and forward them to the relevant network.

This diagram shows what happens in Layer 3

Layer 3 can read and understand the IP address of the received packets. This Layer has a table called Routing Table. The Routing table has records describing network destination IP address, netmask and relevant interface. The Routing table may contain the records with the same network destination IP address but with different netmasks.

Once layer 3 receives a packet, it compares the destination IP address against the Routing table records. The router performs a bitwise AND operation between the destination IP address of the packet and all the netmasks of the routing table.

  1. If the router finds a match for the result from network destination IP addresses, it forwards the packet to the relevant interface.
  2. If the router finds more than one match, the packet will be forward to the interface with the longest netmask.
  3. If there is no match, the packet will be forward to the default interface (Gateway).

Let’s have a look at few scenarios to understand what happens in each layer. That will give you a clear overall understanding.

Scenario 1: Device C is going to send a packet to Device E.

When the Network layer (Layer 3) of Device C received a packet from the Operating system (Top layers) to be sent to Device E, the following IP addresses are set to the packet.

Source IP AddressDestination IP Address
IP address of Device C
IP address of Device E
IP addresses of the packet

Then the packet is passed to the Link Layer (Layer 2) to set the relevant MAC addresses.

Source MAC addressDestination MAC address
MAC address of Device C
MAC address of interface 0
of the Router 1
MAC addresses of the packet

Here you can see the destination MAC address is set as the interface 0 of Router 1. Within a subnet, the routing happens using MAC addresses. But our destination device is sitting on a different network. Therefore, the packet should be moved out from the source device’s subnet. For that reason, interface 0 of router 1 is set as the destination MAC address.

Then the packet moves to the Physical layer of device C and then the signals are propagated through the link.

The signals are first received by the first switch. Then, as explained in Switch section above, after comparing the destination MAC with MAC table of that switch the packet is forwarded to the interface towards the the switch 1.

The signals are then received by the interface 2 of switch 1. The destination MAC address is again compared against the MAC table of switch 1 and then the packet is forwarded to the interface 3 of Switch 1.

The physical layer of Router 1 decodes and moves the packet to the Link layer. The link layer finds the destination MAC address of the received packet is same as the MAC address of the interface. Therefore, the packet is moved to the Network layers.

The network layer reads the destination IP address of the packet and do a bitwise AND operator against every netmask in the Routing table. (bitwise AND operator) =

From the routing table, we can see that the second entry matches with the calculated network address. So router decides to move the packet through the interface associated with IP address (interface 1)

The packet is moved to the Link layer again. From there, the source MAC address is set as the MAC address of interface 2 and the destination as device E’s MAC address.

Source MAC addressDestination MAC address
MAC address of interface 1
of the Router 1
MAC address of Device E
New MAC addresses of the packet

Then the packet is moved to the physical layer and encodes the packet into signals and propagated through the link.

After that, the signals are received by the next switch and the packet is forwarded to the relevant interface as described few times before.

When the packet is received from the physical layer of Device E. That is moved to the Link layer. From there, once again after comparing the destination MAC address, the packet is moved to the network layer. In the network layer the destination IP address is compared and the device E finds the packet is sent to device E. Therefore, the packet is moved to top layers (eventually the operating system) for processing.