What’s a network switch ?

A switch is a device used in computer networks to connect multiple devices together within a single local area network (LAN). Its main role is to facilitate communication between different connected devices, such as computers, printers, servers, IP phones, etc.

It is a mini-computer which is made up of RAM, ROM, flash RAM, NVRAM, a microprocessor, connectivity ports and even an operating system.



RAM

RAM (Random Access Memory) contains the current configuration of the switch and temporarily stores the MAC address table, which is then processed by the microprocessor.

Microprocessor

The microprocessor is the heart of the switch, responsible for data processing, including switching and creating links between multiple devices.

External memories

External memories, such as flash RAM, ROM, and NVRAM (Non-Volatile RAM), store configuration files , different versions of the IOS , etc ...

Ports

The switch ports are the communication interfaces of the switch. There are several of them, generally 24 for a Cisco switch. Each port is associated with an LED which indicates its status and activity.



How does it work ?

Now how does a switch work to transfer information from one machine to another?

Suppose we have 4 machines: A, B, C and D connected to our switch in ports 1, 2, 3 and 4 as follows:



The switch only works with MAC addresses , so basically we have an empty MAC address table stored in RAM as soon as the switch starts up which looks like this : 

Transmitting data from machine A to machine B happens in the following steps:

  1. Machine A sends a frame to machine B

    1. Once this frame arrives at port 1 (which is the one linked to A), the switch reads the source MAC address and stores it in the MAC address table
    2. The table then becomes

  2. The switch reads the destination MAC address and looks for it in the table, if it is not in the table, it broadcasts to all the active machines connected to the switch except the source one.

    1. If the port linked to the machine we want is active, it sends a response frame from which the switch reads the MAC address we were looking for (@B)
  3. Once done, it records the MAC address of B in the table.

This process repeats until the switch reaches what is called "MAC address table stability", that is to say it knows all the MAC addresses of the connected machines and has no more need to broadcast.

Starting and configuring a switch

When it comes to booting a switch, the process is similar to that of a traditional computer system:

  1. POST (Power-On Self Test): The switch performs proper functioning tests on all hardware.
  2. Loading IOS (Internetwork Operating System): The switch operating system is loaded.
  3. Loading the configuration. At this stage we have two cases:
    1. Either the switch already has a startup configuration defined and stored in NVRAM
    2. Either the switch is blank and it is up to us to define the startup configuration when it goes to setup mode

Switch configuration

The configuration of a switch is done through different modes, such as user mode, privileged mode and global configuration mode, which allows access to specific configuration modes, such as interface mode, routing mode, line mode, etc.

And to do all this of course you must first connect the switch with the machine via the console cable and open a terminal emulator

💡 It should be noted that the only machine that can configure the switch is the one connected to it by a console cable, the others are only hosts.