Chapter 3


By Nikhila Sattala
15 mins read

In the world of networking, there used to be two main approaches: classful and classless. Initially, the internet relied on Classful networks, which divided IP addresses into three classes: A, B, and C. However, this system didn't distribute addresses efficiently. To accommodate the internet's rapid growth, a more flexible method called Classless Inter-Domain Routing (CIDR) was introduced. Unlike classful networks, CIDR doesn't rely on predefined classes and allows for a more efficient allocation of IP addresses.

In this training, we'll delve into CIDR networks, hosts, and subnet masks.
Communication within the same network
As you have seen in the previous Networking section, the "Application Server" (where the whole business logic of your web app will be running), needs to communicate with "Database".

So, how can we make them communicate with each other?

One simple way is to connect these two servers using an ethernet cable and establish communication between them. Well this might work.

Now imagine your application has a huge traffic, you require five application servers that runs in parallel to handle such a huge traffic, then you need to connect all those five application servers with one Database though five ethernet cables.

So now guess will this setup work as you expect?
This setup might work, of course with lot of hacks and tricks, but this is not the way things are connected in the real world network infrastructure.

The drawback with the above setup are:
  1. Your Database server not only handles its regular database tasks but also becomes responsible for managing network traffic among multiple application servers. This can lead to network congestion, increased latency, and potential performance bottlenecks.
  2. Also there arises scalability issues with this setup, as you can connect only as many application servers as there are ethernet ports available on your database server.
  3. As your infrastructure expands, troubleshooting and monitoring become even more complex without central point for managing network traffic

And this is a common problem that occurs where multiple devices in a LAN wants to communicate with each other, not just specific to our network setup.

To address such issues and make network connectivity efficient among the devices that exists in the same network, a basic networking concept called "Layer-2 (L2) Switching" was brought up.

Now that we understood the need of L2 Switching, let us see in detail what is it, how does it work?
L2 Switching

Here L2 refers to the second layer of OSI model, that we have learnt in our Computer Science Fundamentals course.

This L2 communication relies on MAC addresses assigned to the Ethernet interfaces of a device.

As you learnt in previous sections, MAC addresses are like unique names or addresses assigned to the network adapters / ethernet interface (the hardware that handles network connections) of a device. This address is hardwired into the network adapter by the manufacturer.

Just as each house on a street has a unique street address, every network adapter has a unique MAC address.

The switch's software maintains a MAC address table that maps the MAC addresses of all the Ethernet interfaces (of all the devices) that are connected the ports of the switch using Ethernet cables. MAC address table looks something like this (observe "Mac address" and "Ports" columns in the below table)

2960-1#show mac address-table
          Mac Address Table
Vlan    Mac Address       Type        Ports
----    -----------       --------    -----
   1    00ld.70ab.5d60    DYNAMIC     Fa0/2
   1    00le.f724.al60    DYNAMIC     Fa0/3
Total Mac Addresses for this criterion: 2

How does a Switch work ?

Let us try to understand the functionality of the switch using a simple example of your office, where suppose there are four members in your team working in one department. You want each one of your computer to communicate with the other three computer.

As we discussed earlier, we cannot use Ethernet cables to connect each computer with other three computers. Instead, a Switch will be placed in your office, such that all your four computers, connect to different ports of the Switch through an Ethernet cable as shown below.
  • 1
    Device A sends data
    When a team member sends data to another team member, a data frame consisting of source and destination MAC addresses and IP addresses will be sent into the Ethernet cable from the sender’s computer.
  • 2
    Switch receives data
    The switch receives this data frame on the port where the sender is connected.

    Here's where the switch's intelligence comes into play:-
    It examines the destination MAC address in the frame. The switch from its MAC table, knows exactly which port is associated with that destination MAC address.
  • 3
    Switch sends data to Device B
    Switch then forwards the data frame to that port. Eventually it reaches the destination computer through the Ethernet cable.
Finally, what does a switch do?

A switch is responsible for Layer-2 communication, which is basically, forwarding data frames between devices within the same local network.

For example, all the systems in the network can communicate with each other through a Switch.

Communication of Servers in the same private network
The same L2 switching logic works in our private network of our web app. The application server communicates with database server through a switch.

Not just, application and database servers, any device that is configured in can communicate with any other device until both the source and destination devices are in the same network. This internally happens through a Switch.
Virtual Switch in Cloud Environments

As we learnt in our "Evolution of Cloud Computer" module, cloud platforms will internally configure virtual switches for the virtual servers/instances to communicate with each other, when they are created in the same network. We don't need to explicitly create a switch for instances to communicate in cloud platforms like AWS.