The Internet
This article introduces you to the basic concepts of the internet such as modems, routers, IP addresses, ports, etc.
Modems
To connect to the internet, you need to find an ISP (Internet Service Provider) to bring and install a wire into your home, and give you a box to plug the wire into. This box is called a modem and is used to convert the signal received by the wire into digital data and back. Once you have the modem in your home, you can plug your computer directly into it via an ethernet cable and your computer will have internet access.
Different types of modems
Ethernet cable
IP addresses
After the modem and the wires are installed at your home, the ISP also assigns you a number that is unique across the entire internet. This number is called an IP Address. With this address, anybody on the internet can send packets of data to your machine. There are two types of IP addresses, IPv4 and IPv6. IPv4 consists of 4 bytes (32 bits), IPv6 consistes of 16 bytes (128 bits). IP addresses are written and displayed in human-readable notations, such as 172.16.254.1 in IPv4, and 2001:db8:0:1234:0:567:8:1 in IPv6. Most computers on the internet use IPv4 because IPv6 is still far away from widespread adoption.
Ports
On your computer you can run several applications at the same time and all of those applications can use the internet. To know which application to send the packet to, all packets contain a 16-bit destination port number. There are 65536 total available ports. Any aplication can use any port, but there are some agreed upon standards for some ports. For example, all websites use the port 80 or 443.
An application that is programmed to listen for connections from the internet and provide a service is called a server. You can run (host) multiple servers on the same computer. A web server is an application that listens on ports 80 or 443 and sends a website whenever requested by your internet browser.
DNS
Whenever you use your internet browser to view websites, you are not connecting to IP addresses directly but their text representations such as google.com or superversus.com. These are called domain names or hostnames. Your browser converts them to an IP address with a process called DNS resolution. There is an agreed upon standard set of DNS servers which only exist to convert domains into IP addresses. DNS resolution works by sending a domain you wish to convert to these servers and getting an IP address back.
To stop the entire internet from overwhelming the DNS servers, ISP's save the result so next time someone tries to resolve the same domain, they stop the request and send the saved result instead.
Packets
A packet is a tiny chunk of data that is transmitted over the internet. All packets include a destination IP address and a destination port. When an application receives a packet, it needs to know who to send a reply packet to, so packets also include a source IP address and a source port.
Routers
Because there is a limited number of IPv4 addresses available, your ISP usually only gives you a single address to use. To allow multiple computers and phones to use the same IPv4 address, another box called a router is used to create a Local Area Network (LAN) at your home. Most modern modems can also act as a router, so a single box is usually sufficient even if you have multiple computers.
Local networks have their own private IP addresses (such as 192.168.1.63) to allow computers to send packets to eachther without the packet ever leaving the local network. The router also has its own private IP address, sometimes called a gateway address (such as 192.168.1.1), which is where the computer sends all packets to.
When a router receives a packet from the internet, it modifes the destination IP address on the packet from a public external IP to a private local IP via Network Address Translation (NAT). Some types of NAT's also modify the port which can cause problems in peer to peer connections.
Because the entire local network only has a single external address, it means whenever a packet is received by the router from the internet, it has to then decide which computer or phone to forward it to. Routers do this by checking the port the packet is sent to. If an application on a computer has previously sent a packet to the internet to a specific port and ip address, any packet that comes back from that ip address and the same port will get forwarded to that computer. You can also set some computers to always receive all packets for a specific port, which is called port forwarding. Port forwarding is usually used when there is a server running on a computer behind a NAT.
Different types of routers
Private IP addresses
Because routers assign private IP addresses for their own local networks, these private addresses can never be assigned by an ISP. As such, some addresses are reserved for private use only and can never be used by anybody on the internet. On IPv4 there are three ranges of such address. Most home routers use Class C addresses privately.
IP address range | Number of addresses | Class |
---|---|---|
10.0.0.0 – 10.255.255.255 | 16 777 216 | Class A |
172.16.0.0 – 172.31.255.255 | 1 048 576 | Class B |
192.168.0.0 – 192.168.255.255 | 65 536 | Class C |
Localhost and broadcast addresses
If you ever want to send a packet from one application running on your computer to another, you can do this by sending it to the localhost address. In IPv4, the localhost address is 127.0.0.1 which is also the same IP you get if you resolve the hostname "localhost" via DNS.
Sometimes you have a server running on your local network but you don't know the server's private IP address. You can send a packet to all computers in the local network and wait for the server to respond by sending it to a broadcast addres. In IPv4 it is 255.255.255.255.
Find your public IP
The easiest way to find your public address assigned to you by your ISP is to connect to an internet server and ask it what IP it sees you connecting from. There are several online websites that show you your publicly assigned IP address. If you search google for "what is my ip", google will show you your public IP.
Here are some websites that display just your public IP and nothing else. The IP will show on the top left side of your browser since there is nothing else on the page.
- icanhazip.com
- ipinfo.io/ip
- bot.whatismyipaddress.com
- api.ipify.org
- checkip.amazonaws.com
- wtfismyip.com
Find your private IP
Outside internet doesn't know what kind of a network you have at your home, so nobody knows what your private IP address is. To find your private IP, you need to get it from your router.
On windows you can do this by opening the command prompt (click on start and type in "cmd"), and typing "ipconfig" into the prompt.
Finding your private IP address
Network diagnostics
To find out how long it takes for a packet to travel to a server and back (round trip time), you can use the ping command. This is also a useful way of checking if the server is even reachable, although in some cases the network the server is on might reject ping packets but let through other traffic. Ping command automatically resolves any hostname into an IP address, so you can use a domain too.
You can also find out which routers the packet goes through on the internet when its sent to a destination by using the tracert or traceroute command. If the ping command times out, you can use traceroute to find out which router in the path drops it.
Latency (ping) to google's servers
Switches
If your Router doesn't have enough output ports to use, you can optionally plug in a box called a switch which essentially just extends the number of available ports to the router.
A network switch
Home networks
A typical home network consists of a modem, a router and optionally a switch. A router can also provide wifi access to the internet, which is essentially the same as if you connected to it via an ethernet cable.
Example of a home network
Mobile networks
When you get a SIM card for your smartphone, sometimes you also get 4G or 5G internet access on the phone. This is provided by giant cell towers placed around major cities which essentially act as routers for all the phones connected to them.
A cell tower