Let’s build our own Local Area Network now that we’ve learned about some networking hardware. Your actual network journey starts from this tutorial.
You and your best friend Hermione are both interested in networking. You have knowledge of some networking devices and how to connect them using cables and connectors. You want to connect your two desktop computers and Hermione’s laptop. You draw the diagram below and show it to Hermione.
This type of small network is called LAN Network. LAN is an abbreviation for local area networks. A network is a collection of two or more connected computers, whereas a LAN is a network that is contained within a small geographic area, typically within the same building. LANs are commonly used in home WiFi networks and small business networks. Although LANs can be quite large, it is usually more accurate to classify them as wide area networks (WAN) or metropolitan area networks (MAN) if they take up multiple buildings (MAN).
A device could be linked to two other devices using one twisted-pair CAT-5 cable and two RJ-45 connectors for each connection. You have not drawn the RJ-45 connector in the diagram(Relax, we know you’re lazy!).
And she is right. Networking entails far more than haphazardly stringing cables around. Before you start pulling lines all over the place, you need to figure out what you’re connecting, where everything is going to be, and how to network it all together. So you draw the diagram below and make a list of the devices you’ll need to build your own network.
Yes, You will use a router to connect all the devices together. This is basically what routers do. As we have previously mentioned, a router connects two or more networks or subnetworks. Its primary functions are to manage traffic between these networks by forwarding messages to their intended IP addresses and to allow multiple devices to use the same Internet connection.
The Internet(capital i) and an internet(small i) are not the same thing. The term “Internet” refers to the vast interconnected networks that we use to send data around the world. The term “internet” refers to the connection of at least two intranets via a router. And we are building only one network, not even two. So can we use the router?
Yes, we can. A router can function independently of the Internet by establishing a local area network on which connected devices can communicate. This enables shared services such as file sharing and shared printers to be used even when there is no Internet connection, within the LAN.
However, routers are expensive. Instead of a router, you can use hubs or switches(as you only want to create your own LAN). We have not yet introduced these two networking devices. We will go over them in this tutorial.
What is HUB?
Hubs enable us to connect the various machines we want on our network, such as computers and printers. It simply copies an incoming signal to all of its other ports and broadcasts it. A hub is also known as a repeater because it repeats the incoming signal without the use of digital intelligence. It has no memory or processor.
Broadcasting Broadcasting is the process of sending data to all systems regardless of the intended recipient. Broadcast communications can have a significant impact on overall network performance on busy networks.
Here’s what a hub looks like inside:
A hub is a dumb device because it does not understand network data and does not know about or store MAC addresses. It simply repeats incoming signals across all ports without altering the signal before broadcasting it.
Because a hub simply transmits signals as they are received and has no real understanding of network data, it makes no changes to the source MAC address. It retains the source MAC address as it was when the packet was received. Why the source MAC address is so important will be discussed later.
A hub receives incoming signals and distributes them to all other ports. When multiple devices begin sending signals, the hub’s constant repetition causes heavy traffic and collisions. A collision occurs when two signals collide, resulting in an error. The sending network device must take a step back and wait for the signal to be sent again.
A hub is essentially an electrical repeater. It takes any signal that comes in and sends it to all of the other ports.
A hub lacks processors, which means it has no real understanding of network data. It is not aware of MAC addresses or frames. It recognizes an incoming networking signal as purely electrical and forwards it.
What is a Frame?
We knew you’d notice, Hermione. In our next tutorial, we will talk about frames. However, in this tutorial, we will discuss it briefly to demonstrate the significance of MAC Address.
Protocols are used by network devices to communicate effectively. In simple words, protocols mean a set of guidelines or rules for network communication. These protocols address issues such as how quickly data can be transmitted and how data is structured when it is sent. Most protocols specify a message size limit, which means that messages must be separated into separate packages and labeled with information about where the message came from and where it’s going.
Network messages come in two kinds of packages: frames and packets..
Frame Protocol #1
A frame is a logical structure of bits that organizes network traffic so that every device can read the information contained within it. A packet is a structure that exists within the frame. It’s the real meat of the frame. Packet contains the data that needs to be sent.
The Destination MAC address is the hardware address of the next network device to which the packet is traveling.
The Source MAC address is the hardware address of the last device that sent the frame.
When we are networking, whether it is our custom network or the big Internet, the address we are most interested in is the MAC Address. Most of the time, we are unaware of this. For example, an IP Address actually retrieves a MAC Address in order for our data to reach its destination.
That discusses the frame for the time being. We’ll go over it in the next tutorial.
The Switch
A network switch is a physical device that operates at the Open Systems Interconnection (OSI) model’s Data Link layer — Layer 2. It receives packets sent by devices connected to its physical ports and forwards them to the devices to which the packets are intended.
Switches are a common component of Ethernet, Fibre Channel, Asynchronous Transfer Mode (ATM), and InfiniBand networks, among others. Most switches today, however, use Ethernet.
Do not worry about the Open Systems Interconnection (OSI) model’s Data Link layer — Layer 2. We’ll talk about it when the time comes.
How Do Switches Function?
A switch sends frames, and only sends them where they need to go. Switches avoid collisions by storing and forwarding intranet frames. Switches can do this by using the frame’s MAC address. Instead of repeating the signal across all ports, it forwards it to the device that requires it.
Switches think in terms of frames
A switch reads the signal as a frame and uses the frame’s information to send it to its intended destination. A switch contains processors, RAM, and ASICS. This means it can properly process network data. It understands MAC addresses and frames, so it can deal with any incoming networking signal intelligently. It can determine where the signal should go and deal with it accordingly. A switch, like a hub, allows us to connect the various machines we want on our networks, such as computers and printers.
Here’s a look inside a switch:
The way hubs and switches handle signals differs significantly. A switch can process signals in the form of frames and understands MAC addresses. A switch can store packets and forward them to their destinations rather than repeating incoming signals on all ports.
Switches store MAC addresses in a lookup table to keep the frames flowing smoothly. A switch intelligently directs traffic between systems by only sending packets to their intended destination. This is accomplished by keeping track of the MAC addresses of the NICs plugged into each port. For switches to identify different ports and devices, MAC addresses must be unique or highly unlikely to be repeated, which is why manually setting a MAC address can have unexpected consequences in a switched network. Switches typically have a large number of MAC addresses reserved in their MAC address table. When forwarding a frame, the switch first searches the MAC address table for the outgoing port’s destination MAC address. If the outgoing port is found, the frame is forwarded rather than broadcasted, reducing the number of broadcasts.
Take your coding skills to the next level with our comprehensive guides, “Python Beginner to Advanced” and “Java Beginner to Advanced.” Whether you’re diving into Python or mastering Java, these books provide step-by-step guidance and in-depth knowledge to elevate your programming expertise.
How Do Switches Acquire Mac Addresses?
Because a switch is intelligent, it can generate the MAC address table automatically. The following section will show how a switch learns MAC addresses.
We have three computers and a switch in the middle. Every computer has a MAC address. They are abbreviated as AAA, BBB, and CCC in the below diagram for simplicity.
Assuming Computer A is going to send something to Computer B, consider the following:
Computer A will generate an Ethernet frame with a source MAC address (AAA) and a destination MAC address(BBB). Because the switch has a MAC address table, the following will occur:
The switch will generate a MAC address table and learn only from source MAC addresses. It has only recently discovered that computer A's MAC address is on interface 1. This information will now be added to its MAC address table. However, the switch currently has no idea where computer B is located. There is only one option left: flood this frame out of all of its interfaces except the one from which it originated. This Ethernet frame will be received by computers B and C.
Because computer B recognizes its MAC address as the destination of this Ethernet frame, computer Computer B will respond to computer A by creating an Ethernet frame and sending it to the switch. The switch will now learn the MAC address of computer B. The computer C will just discard the frame as it does not match its MAC Address. The switch now knows both MAC addresses(A and B) and can "switch" instead of flooding Ethernet frames the next time.
That concludes our story. Except for the first flooded frame, Computer C will never see any frames between Computer A and B.
Another point worth mentioning is that the switch’s MAC address table employs an aging mechanism for dynamic entries. If Computer A and B’s MAC addresses are not updated within their aging time, they will be deleted to make room for new entries, which means frames between Computer A and B will be flooded to Computer C again if A wants to transfer information to B.