This blog post is similar to my posts under “One Minute MVS” which aim to provide basic knowledge to understand a topic.
I struggled to understand some of the networking concepts. There is a lot of documentation on the internet, but it did not cover the basics.
The concepts below are based on Ethernet and physical connections. Other connection types such as wireless can be used just as well, but I find the Ethernet picture simple to understand.
What is a router?
A router is used
- to convert from one network protocol to another protocol
- to connect bits of network together.
Broadband router
I have broadband to my house, it comes from my telecom’s provider.
- There is a broadband protocol for the connection to the telephone exchange, for example it connects using my house phone number, not IP address.
- It converts from broadband to wireless and Ethernet protocols for my various devices around the house.
- I can connect my laptop to the router, and connect to other devices around the house, on a different network.
What is a switch?
Think of a self contained office. An Ethernet switch is a box with physical sockets for plugging Ethernet cables into. Each person’s computer has a unique address (known as a MAC). Each computer is connected by an Ethernet cable to a physical port on the Ethernet switch. If your computer wants to send information to another computer in the office it sends a request to the Ethernet switch, saying send this information to this MAC address. The switch knows which physical port matches the MAC, and sends the data down the cable plugged into the physical port.
With the configuration described so far, a computer cannot get to the outside internet.
What is hub?
A hub is a very dumb switch, it sends the incoming data to all devices, it is not smart enough to work out which devices to send the data to. It is used when there are a small number of connections.
Does each device need a unique IP address?
Within a network or sub network, each device needs a unique IP address. My laptop has IP address 192.168.1.1 within my network. My neighbour’s laptop has the same IP address within her network. They are on totally separate networks and do not interact, and so they can each have the same IP address.
Each device connected to the internet needs a unique IP address, so the back-end systems can send the data to your device.
A router can be clever and make each device attached to the internet look like a unique device
- A server has a fixed IP and port, so client applications can find it.
- Each time a client machine starts, it can be given a different IP address, and when it connects to a server it can use a different port.
- The server usually does not care what IP address and port the client uses.
If the IP the address of my laptop is 192.168.1.1, this is an internal address and cannot be used on the internet. My router has external address 7.7.7.1.
The router can do some clever mapping
- If I try to connect from my laptop source address 192.168.1.1 port 100 to the outside world, the router can change the source address to 7.7.7.1 port 206, so looking like a port on the router.
- If I try to connect from my laptop address 192.168.1.1 with a different port, 200, to the outside world, the router can change this address to 7.7.7.1 port 209
- If I try to connect from my server with a different address 192.168.1.16 port 100 to the outside world, the router can change this address to 7.7.7.1 port 208.
As far as the internet is concerned requests have come from address 7.7.7.1 with three different ports. When the replies come back, the router maps them back to the internal addresses and ports. The ports numbers 206, 209 and 208 could have been any free port on the router. Tomorrow I may get different numbers.
What is a router – routing
In my house the broadband is on a cable. This is plugged into a router. My red Ethernet switch is also plugged into the router, and my blue Ethernet switch is plugged into another physical socket on the router.
When data from the internet arrives, there are routing rules which say
- If the traffic is destined for the red switch, then send it to the red switch.
- If the traffic is destined for the blue switch, then send it to the blue switch.
- If the traffic is destined for any of the following list of addresses, send it on the broadband cable.
- Otherwise send it on the broadband cable.
At the far end of the broadband cable is a telephone exchange. This is different sort of router which says if the traffic is for the phone number 01856…. then send to to my house.
The next level of detail
Each computer in the switch is given an IP address, such as 192.168.22.5, another might be 192.168.22.6, where the last number changes with the different computers.
The router has configuration information saying data for 192.168.22.* send it to the red switch.
The blue Ethernet switch has addresses 10.1.1.*
My router has 3 connections, one for broadband, one for the red switch, and one for the blue switch.
If you physically pick up my switch. All of the Ethernet cables coming out of it are part of a subnet. They all have a similar IP address (192.168.1.*), they are in the same subnet.
My router has the following definitions
- The physical port to the router, has address 192.168.22.25
- The physical port to the blue router has address 10.1.1.6
- The physical port to my broadband router is address 192.168.1.222
The top part of these addresses are all different. They are different subnets.
Router routing
If we have a configuration like
Where internet traffic comes into A for the laptop
For sending data to the laptop with IP address 1.1.1.1, you can configure the network
- On router A. Send traffic for 1.1.1.* to router B. If B is not available send traffic for 1.1.1.* to router C. This provides dual path, or a backup route.
- On router B. Send traffic for 1.1.1.* to router D.
- On router C. Send traffic for 1.1.1.* to router D.
Similarly you can configure router D to say to get to the internet you can go via B or C.
Addresses
You could have a configuration like
Where …
- the red circle has a laptop connected directly to the router. All of the addresses begin with B. The router end of the connection has an address B.2, where B could be 10.1.1, or 192.168.1 etc
- the blue circle has an Ethernet switch (SW1) attached to the router. All of the elements have an address A…. where A is different to B. The numbers after A are all different; a laptop with address A.3, a laptop with address A.6, the connection to the router has address A.2, and the router end of the connection has address A.8
- the green circle is is similar to the blue circle, it uses switch SW2. The value of C is different to A and to B.
- the yellow circle has the connection to the internet. I is the external address of the router and may be something like 9.8.7.23
Let A be 10.1.1 B be 10.2.2 and C be 10.3.3. I could pick any values as long as A, B and C are different, and different to any addresses on the internet.
Within the routing tables in the router I could have
- All traffic for the address 10.2.2.9 (B.9), send down 10.2.2.2 (B.2). I could also say any traffic for address starting 10.2.2.* send down 10.2.2.2 (B2).
- All traffic for the address 10.1.1.* , send down 10.1.1.2 (A.2). This is a range of addresses.
- All traffic for the address 10.3.3.* , send down 10.3.3.8 (C.2). This is a range of addresses.
If I decide to change 10.2.2.* to 11.2.2.* I have to change all of the laptops and the switch within the blue subnet, and the router’s routing tables to reflect the change.
Technological advances
It used to be that a router and switch were hardware devices. These days many routers are just computers running Linux with lots of Ethernet ports.