Category Archives: Internals

TCP and UDP the Backbone of Traffic

In the previous post we talked about the /etc/services file and how that told the computer what ports to use for what traffic.  In that file we saw lots of mentions of tcp and udp but there wasn’t anything that told you what those two abbreviations meant.

In the Internet, there’s different destinations for traffic and there’s also different kinds of traffic.  They’re designed for two different things.

When you send a letter by snail mail, you open up the mailbox, drop your letter in, and hope it gets there.  It usually makes it to its destination, but you have no way of making sure it does.

Mailbox

Mailbox

On the other hand, when you make a phone call, you know it connects (because you’re talking to the other guy) and it works until either you hang up or the connection cuts off for some reason.  You don’t always know why it got interrupted, just that something cut it off.

Telephone

Telephone

We can communicate two ways, each of them designed for some specific reason.

In the Internet, udp traffic is like the mailbox.  Its traffic that just flows across the Internet with no verification that it made it.  It’s used in case when it’s not really a huge deal if the connection doesn’t work.  Network Time Protocol is an example of udp traffic.  It isn’t great if the time update doesn’t make it, but it isn’t the end of the world either.

On the other hand, tcp traffic is like the telephone call.  In tcp traffic, a connection is created between two systems and it is kept alive as long as they need it.  It’s for when you really want your traffic to make it from one system to another.  E-mail  uses tcp, because as I said before, people really want their email.

Network Traffic

You’re on the network, surfing away on the web, and there’s data just flowing to your box.  Even right now, when you’re looking at this web page, there’s data heading to your system. It’s network traffic and if you think of it as a pipe, your system has that flowing in all the time.  Imagine it as a water pipe, like this picture:

Leaky Pipe

Leaky Pipe

We’ll pretend our pipe isn’t leaking, since that would mean we’re losing network traffic.  Our pipe brings us all kinds of traffic as we surf away, some of which we want and some of which we don’t.

How does the computer know what kind of traffic the pipe is bringing it?  Computers are mostly stupid, if you put legs on one and told it to walk off a cliff, it would happily do that. We have to tell the computer what kind of traffic to expect, either DNS or web traffic or email, or other kinds of traffic we’re not mentioning here.

Back to our pipe analogy because it’s a really useful way to think about the traffic. If before the pipe connects to us, it separates itself into different types of traffic, that would work, right?

Many Pipes

Many Pipes

We can attach those little pipes to the pipe in the first picture and that would separate out the traffic.

The way modern operating systems (Linux© included) handle this is with ports.  The pipe connecting you to the network has labeled ports and the different kinds of traffic go to the different ports.  Web traffic goes to port 80, e-mail to port 25, DNS to port 53, and there’s more. Each machine has 65,535 ports on it for traffic to use.

I know you’re asking the next question:  How does the computer know what kinds of port do what kind of traffic?  Well, there’s a file for that.   It’s called /etc/services.  If you more it, you can find see people reserve ports for different kinds of applications.

There’s also a website  that keeps track of assigned ports.

Next time we’ll talk about what tcp and udp in the /etc/services file mean.

 

Running out of time

In this post, I said that Linux keeps time by counting seconds. So, here’s a good question: Is there a number that Linux can’t count past? I mean, if you sat there and counted, you could keep going and going and going until you fell asleep. Linux doesn’t actually fall asleep, it keeps counting… until it can’t. We’ll call it the ‘Running out of Time’ problem.

It’s not like when the good guy runs out of time trying to stop the bomb and everything explodes.

Time is Running Out

Running out of Time

Your system isn’t going to explode! I promise. It just runs out of ways to keep counting.

Most systems today are 32 bit systems or 64 bit systems. That 32-bit (or 64-bit) refers to several different internal operations of your system. We’re going to talk about what it means in terms of numbers. If your system is a 32 bit system, that means the largest number it can store is 2^32. That’s 4294967296. That looks like a big number, doesn’t it? It seems like it’d take a while to count that high. If your system is a 64 bit system, the largest number it can store is 2^64. That’s 2^32 squared or 4294967296 squared. That’s.. a REALLY big number.

The running out of time problem has to do with 32 bit systems.  On January 19, 2038, the number of seconds from January 1, 1970 is going to be larger than 4294967296.  Your 32 bit system isn’t going to be able to count any higher than that and, well, interesting things will happen, or won’t happen.

Running out of Time

Running out of Time

Your 64-bit system doesn’t have that problem, since it can count so much higher than your 32-bit system.

Is there a solution for this problem? Well, no. There’s a lot of smart people working on it though. Those smart people don’t include Tony Stark or Dr. Strange or even Batman, but they’re going to figure it out. Hopefully before January 19, 2038.

Linux® Time

So let’s talk about Linux® and time again. We’ve talked about the calendar, we’ve talked about the Network Time Protocol, but let’s talk about how Linux® stores it.

Everyone seems to have their own way they want to write the date. In Europe, they like to lis t the date first but in America, they like to list the month first. Some people even like to list the year first. And that’s just the date. Now there’s the time! There is the standard of hour, minute, second, but what if you want to write year, hour, month, minute, day, and then seconds? There’s no reason you shouldn’t, right?

Well, keeping track of all of those choices isn’t something Linux® should have to do. Instead, it keeps time by counting seconds, and you can take those seconds and make them look however you want.

Linux® had to start counting seconds at some point, and they chose to start at January 1, 1970.  That’s weird, right?  Linux® wasn’t released until 1991, why did they choose 1970?

Well, I could spin an awesome story about how that’s the instant the first real computer was turned on, or that Iron Man first turned his suit on, or Batman decreed it to be the start of the new era (or new new era), but that would be wrong. The real story isn’t that it’s the birthday of Unix (the Operating System that Linux® mimics), the real story is that it looked pretty.

Computers used to keep time on the sixteenth of a second. This caused problems, because that meant the computer could only tell time for a couple of years before it couldn’t store it anymore. The decision was made that ‘gee, we should use seconds, that’ll work better’. (There was more discussion about this. Imagine the Avengers and the Justice League trying to agree on something.) Once that decision was made, they said ‘huh. Well, let’s start counting from January 1, 1970. That’s a nice round time. Even though it’s 1972 now, that’ll work great’.

And so that’s what they did, they started counting from January 1, 1970.  All Linux® time is stored like that, it just prints out the pretty time (in the format you want).    Check out the man page for date, it will tell you how.