CS 100 (Learn)CS 100 (Web)Module 03


TCP/IP (IP)

(direct YouTube link)

NOTE: If your internet access is restricted and you do not have access to YouTube, we have provided alternate video links.

TRANSCRIPT

Note: This video transcript has been slightly modified. Significant corrections are marked with strikethrough, and alternative wording has been placed in [square brackets] to correct some of the awkward or confusing phrasing in the videos.

In this video we're going to continue looking at our simplified view of how the internet layers work, and in particular, we're going to look at the middle layer which is known as TCP/IP.

Before we get too far into this, I want to [review] one of the core concepts of using this [layered] model. If you recall, we talked about a voice conversation message where the top two layers were the same as a postcard communication message.

I want to emphasize that the higher layers can communicate without any regard as to what's happening at the lower layers. [That is] really important with our model [and] how we construct messages and send them back and forth.

When we're talking about our middle layer of TCP/IP it doesn't matter if the lower layer is working over WiFi or ethernet or a cellular connection... it doesn't matter. Everything we're going to say now moving forward does not have to be concerned with [which] physical layer is [being] used.

Let's take a look at how the middle layer (TCP/IP) actually works.

I mentioned we're [using] a simplified [model]. The TCP/IP layer is actually two separate layers: the TCP layer, is a higher layer than the IP layer, but for all intents and purposes we're going to consider them the same layer (just for simplification).

Full disclosure: there is an alternative to TCP that is used in the real world known as UDP or User Datagram Protocol. We are not going to really discuss [it], but I just want to make sure you're aware that some of the technologies you use do not use TCP, although the vast majority of communication you use on the internet is actually TCP.

Internet Protocol

The first thing we're going to do is describe IP or the Internet Protocol, and that's literally what the internet is named after: [the] IP, [or] Internet Protocol.

In order to send a postcard in the real world, you need a destination address. Usually you have a return address that you sent it from. You need both of these to communicate on the internet [in the mail system], and to communicate on the internet, you need the same sort of idea.

This protocol requires that you have a sending address where it's coming from, and you need a destination address of where it's going to.

This address does not look like our normal addresses we use for mailing addresses... they use the specific scheme to keep track of all the different devices on the internet.

What does an IP address look like? It's four numbers, each number in the range from 0 to 255 so there's 256 possible numbers. Then you string them together, separated by period.

Currently, www.uwaterloo.ca is really the number 129.97.208.23.

If you launch your browser and you just type in 129.97.208.23, up comes the University of Waterloo [website].

That's not very convenient... we'll talk about a different way of addressing websites soon, but that is an example of how each computer or device on the internet has its own IP address.

Unfortunately, we are running out of IP addresses. If you count up the total number of devices that can be on the internet it is 256 x 256 x 256 x 256 which is approximately 4 billion different devices.

When the internet was first being conceived of, that seemed like a perfectly valid number of IP addresses. [However, we now are in] a world where each one of you may have multiple devices, and there's lots of hardware that connects all of the internet.

We have [surpassed] four billion devices, so they had to come up with a "plan B". There are two ways to address this problem.

The first is what they call IP version 6. The idea with IP version 6 is that you'd have a much longer IP address. This is the actual IP address of another computer at the University of Waterloo that uses the IP version 6 scheme [2620:101:f000:701:f87:e00b:4ea8:e0b3]. With the IP version 6 scheme, we can handle 340 trillion trillion trillion devices on the internet and that should serve humankind for a long time.

The alternative scheme is called NAT [... but more on this later].

So you [do not need to] type 192.97.208.23 into your web browser. You could just type in www.uwaterloo.ca.

There is a protocol named DNS for Domain Name System and what happens when you type in www.uwaterloo[.ca] is that your computer sends that request out to your local DNS server and it then returns back the actual IP address of what you're trying to connect to. It converts between a more user friendly human name to an actual IP address.

Your local DNS server may not know exactly where uwaterloo.ca is, so it may go to the .ca DNS server and [ask] "Hey, you're in Canada... do you know where this address is?" and then it may come back with the number. It may require more than one hop to a different DNS server, but eventually no matter what name you type in, it will come back [with the IP address].

There is an international body out there that decides who can get names. You cannot just go ahead and say "Hey, can I be microsoft.com?" What happens is, you can register a name for yourself so you can have your own custom or vanity name. Or, if you have a business [and] you want to start up [a website or use email] you can get your own name. You [can] register with an agency that associates your name with a real-world physical address.

This is a controversial topic. There are a lot of each country

This is a controversial topic: there are countries that control their own rules for how you can get a name (for example, if you want a .ca within Canada) There [are] other new top-level domains such as .edu [and] .org and each of these have their own rules for how you can obtain your own name.

At the end of the day though, your computer just types in a name At the end of the day though you don't have to really worry about this you type in a name and they

At the end of the day though, you don't have to worry about this... you just simply type in a name and your DNS server will resolve that to an IP address.

I mentioned that there [are] only four billion IP addresses out there... how do you get an IP address? There [are] two categories of IP addresses: there are fixed IP addresses, and big companies like Google and Microsoft have their own fixed IP addresses as well as organizations like the University of Waterloo. In fact, every number that starts with 129.97 is a University of Waterloo address. The University of Waterloo has that entire range.

But you're just a regular citizen and you want to connect to a network, whether you're at Waterloo or Starbucks or at your home network. [At] each of [those locations] your device needs an IP address. Well, the way these "on the fly" or "temporary" IP addresses are doled out is known as DHCP which stands for Dynamic Host Configuration Protocol.

The idea is: your device (when it turns on) tries to connect to a network... it sort of sends a message out "Hey, I don't have an IP address... can I have IP address please?".

Then what happens is there's a DHCP server out there that has a bank of IP addresses that it can give out. It will give you an IP address that you can use, [which will] expire after a certain amount of time.

If you go to Starbucks, and Starbucks gives you an IP address... that's great, but an hour later when you're gone, someone else can get [and use] that same IP address. The DHCP server just keeps track of addresses it has available and doles them out as needed.

This is especially important for your mobile devices like your phone and laptops where you may connect to multiple different networks.

The last tricky piece I want to explain, which will really help your understanding of how communication on the internet works, is known as Network Address Translation [NAT]. When you connect to your home network or even Starbucks or places on campus, this system is used so that we don't run out of IP addresses.

How NAT actually works is a little complicated and I don't want to get bogged down in details, so what I'm going to do is give you analogy using physical addresses that will just give you an understanding of how it works.

Let's say we have an apartment building and that apartment building has a physical address [of] 555 Real St. It's [a] real physical address in our world.

[However,] there [are] a whole bunch of people who live inside the apartment building and they don't even know they [live] at 555 Real St. They all think they live at Imaginary Lane. One person might think they live at 100 Imaginary Lane and someone else might [think they] live at 101 Imaginary Lane.

[Consider this example:] You think you live at 101 Imaginary Lane, and then you want to send a postcard to your friend who lives at [789] Destination Ave.

You fill out your postcard: "Dear Bob at 789 Destination Ave.". [For] your return address, you put 101 Imaginary Lane and then you hand your postcard to the nice doorman who lives at [the] real street [address]: 555 Real St.

You say "Hey, doorman can you please deliver this postcard for me?" He says "No Problem!" and then what he does is he changes your return address to be 555 Real St. (unbeknownst to you). Then, he sends the postcard to Destination Ave. [Next, ] your friend at Destination Ave. [receives] your postcard. He sees your addresses is 555 Real St. and then [he] sends [another message] back to you.

When it arrives [at 555 Real St.], the doorman looks at your postcard it goes "Aha! This is [really for] my friend who lives at 101 Imaginary Lane. [He then] changes the [destination] address from [555] Real St. back to 101 Imaginary Lane and then passes the postcard on to you.

You were completely oblivious to this. The doorman was doing all of this managing for you. [This allows] hundreds or even thousands of computers [to] share the same physical address.

This is another way of getting around [our] problem of running out of IP addresses. When you go on your computer, you ask your computer "Hey, what's my IP address?" It might come up with an [address on] Imaginary Lane. In fact, if your IP address begins with 192.168, you are living on Imaginary Lane.

We've just discussed a few technical issues that help us understand how the internet works and how the Internet Protocol works, but let's actually talk about internet routing, because that's one of the core parts of the IP protocol.

Whenever your computer sends out a message, it has a destination IP address. Your computer sends [the message] to a local router and that router may send it to another router and another router and another router and eventually you'll reach the computer that it wants to reach. All of these individual routers are all connected together and are constantly sending millions of messages back and forth... back and forth.

That's how your message gets from one side of the world to another side of the world. How does this work? Well, let's discuss how it works in the real world.

[For example, if] you live in Kitchener/Waterloo and you want to send [a] postcard to someone in England. You fill out your postcard and you [put as the destination] someone's address in England and then you take it to your local mailbox. Someone picks up that postcard from the mailbox it takes it to a central depot.

[Someone at the depot] looks at the address and says "Oh, this one's going to England, so I [will] send that to the central Ontario dispatch".

I don't know how it actually works in the real world... I'm making this up, but we can imagine that it goes to a central Ontario dispatch, [where] someone looks at the address [and says] "Oh, this is going to England", so they [send] it to [the] Canada dispatch center. At the Canada dispatch center, they look at [the] address and [say] "Oh, this is going to England... well, let's put it on this boat that travels to England" and then it goes over the sea [(honk honk)] on some sort of big boat.

It [arrives in] England and then someone opens it up and goes "Ah, okay... well you want to go to London". [They then] give it to someone who delivers in that region. [The region] will [continue to get] smaller and eventually it will show up at someone's house.

This idea, [where] each person looks at the [destination address on the] postcard along the way [and] knows in general which direction the postcard has to go [is] complicated, but that's how all the network routers on the internet work.

Whenever you send out a message, each [router] sends it to another router that [will] get you closer and closer to your destination.

It's hard to visualize how all the routers in the world are connected. I stole this photo (and this is from 1999, so this is even a long time ago) but this is a visualization of many of the routers that exist in the real world and so you can see how you might start in one corner of this giant network and make your way through a whole bunch of different paths to your destination at the other side of the world.

In general, every message you send on the internet takes less than 50 hops (a hop goes from one router to another router). That's still a lot, but you can reach almost any computer from any other computer in the world within about 50 hops, and that's how all the messages on the internet get transmitted.