Pages

Wednesday, November 20, 2013

IP Networks and Subnets

What Do All Those Numbers Mean?

Your basic network device needs a couple pieces of information to be able to send and receive traffic.

First of all, it needs an address. As you can see in Internet Addressing, it can have a host name type of address. But it always has to have a numerical IP address. If it has a host name, that's just so that we can type it in and a computer can look up the numerical address.

Ok, so each device has to have an IP address. We will talk here about "IPv4", which is the standard set of IP protocols we've been living with for decades. In IPv4, IP addresses are 32 binary digits, but they are normally written as four decimal numbers separated by dots.

For example, my server at home is 192.168.1.4. And my client machine is 192.168.1.22.

You see how the first bunch of numbers are all the same? That's because the client and the server are on the same network. You can call it a "subnet" if you like. A subnet is basically a bunch of computers that can talk to each other directly without going through a router.

So the next piece of information each device needs is a "subnet mask". A subnet mask looks like an IP address, but it normally starts with 255, which a normal IP address would never start with. The computer can tell if another computer is on the same subnet by comparing it's own address with the other address, and seeing if the subnet part of the address is the same.

In computerese, that might look like:
 
if ((my_address & subnet_mask) == (his_address & subnet_mask)) then
    send_packet_directly()
else
    send_packet_to_gateway()

A good point to note is that we don't care if the other computer's subnet mask is the same as ours. We only use our own subnet mask to make the comparison.

How does this help? Well, if I have another server on my network with the address 192.168.23.14, the subnet mask will determine if they are on the same subnet, which means they can talk directly, or if they are on different subnets and have to talk through a router (also called a gateway).

In this example, if the subnet mask is 255.255.0.0, then they are on the same subnet. But more commonly, the subnet mask would be 255.255.255.0, and they would be on different subnets.

That leads to the third piece of information your device will usually need - a default gateway. The default gateway is an IP address of a router (or "gateway") that will forward traffic for us to different subnets.

You can have very complicated networks with multiple routers handling different subnets, or if you are viewing this at home from behind your broadband router, you probably have only that router to worry about.

Let's look at some examples:

For my client machine at home,
    IP address = 192.168.1.22
    Subnet mask = 255.255.255.0
    Default gateway = 192.168.1.1

The first value will vary, but almost all broadband routers default to the subnet mask and default gateway shown here.

Another example - a computer in a lab at a university
    IP address = 10.9.25.100
    Subnet mask = 255.255.0.0
    Default gateway = 10.9.1.1

And a final example, for a really tiny network with only two devices on it,
    IP address = 192.168.27.2
    Subnet mask = 255.255.255.252
    Default gateway = 192.168.27.1


Tuesday, November 19, 2013

Common Ports

Commonly used port numbers

I'll add more to the list, but to start with:

Port Service
22SSH (Secure Shell)
23FTP (File Transfer Protocol)
25SMTP (Simple Mail Transfer Protocol)
80HTTP (Hyper-Text Transfer Protocol)

Internet Addressing

What are those numbers you told me to put in to reach my Minecraft server?

Well, a Minecraft game session is basically a network service connection. And most network service connections need to know two things:
  1. Which server am I trying to connect to, and
  2. What specific service on that server am I trying to reach?
This applies to lots of network stuff, like email, web connections, and whatever else the Internet is used for. Seriously, web and email cover 99% of it now, anyway.

The first item above is either an IP address (a bunch of numbers) or a host name (like www.minecraft.net). People work better with names, so web browsers and email clients let you put in the host name instead of making you type in a bunch of numbers. But in most cases, either one will work.

The second item is a port number. Many times, the port number is implied by what we are trying to do. Web browser traffic, for instance, is almost always going to port 80, which is the standard port for the HTTP network service. For sending email, our email client knows to use port 25 for the SMTP network service.

When we need to give both parts, I mean when we need to give the port number in addition to the host name or IP address, we put a colon after the first part and we add the port number. There shouldn't be any spaces or anything else in there.

For example, our Minecraft server address is 192.168.1.22:25565

And to reach my blog, you can enter grassrootslearning.blogger.com:80 in your browser's address bar. The ":80" isn't needed, but it works.

Here are some topics for further reading:

Host Names

How are host names made up?

Well, first of all, host name strings are a nice way to represent a network server, so that we don't have to remember a lot of numbers. (See Internet Addressing)

Host names usually have letters, sometimes numbers, and dots. The dots are not just to make them easier to read, they are "canonical". What that means is that the dots separate parts of the host name into different sized groups.

Most of the host name that you see, for example the "blogger.com" part of "www.blogger.com", is the domain name of the host. A domain is a bunch of computer systems all assembled under the same organization. So, for instance, Google manages all the computers in the "blogger.com" domain (not to mention google.com and a few others).

The ".com" part of the domain name is also a bunch of computers in the same organization, but of course they're not all owned by one company. But there is an organization for each top-level domain, and they decide if you are allowed to have your domain be a part of their structure.

Most examples you will see of host names have three parts - the host itself (www, perhaps), the company domain, and the top-level domain. But you can actually have sub-domains and sub-sub-domains and so on. So Google might have a host name like host9999.antwerp.servers.google.com.

Perhaps you are thinking "wow, so www.google.com is a network server. That must be one big machine to handle so much traffic!". Well it could work that way, but there are some tricks that domain administrators can use to do resource pooling and load sharing, so www.google.com actually represents a whole bunch of servers. But don't worry about that part just yet.

You might be interested in:
  • IP Networks and Subnets
  • IP Routing
  • Dynamic Name Service (DNS)
  • Dynamic Host Configuration Protocol (DHCP)