The Internet: Crash Course Computer Science #29

The Internet: Crash Course Computer Science #29

CrashCourse

0:03 Hi, I’m Carrie Anne, and welcome to CrashCourse Computer Science!

0:06 As we talked about last episode,

0:07 your computer is connected to a large, distributed network, called The Internet.

0:11 I know this because you’re watching a youtube video,

0:13 which is being streamed over that very internet.

0:16 It’s arranged as an ever-enlarging web of interconnected devices.

0:19 For your computer to get this video,

0:21 the first connection is to your local area network,

0:23 or LAN, which might be every device

0:25 in your house that’s connected to your wifi router.

0:28 This then connects to a Wide Area Network, or WAN,

0:30 which is likely to be a router run by your Internet Service Provider,

0:34 or ISP– companies like Comcast, AT&T or Verizon.

0:37 At first, this will be a regional router, like one for your neighborhood,

0:41 and then that router connects to an even bigger WAN,

0:43 maybe one for your whole city or town.

0:45 There might be a couple more hops,

0:47 but ultimately you’ll connect to the backbone of the internet made

0:50 up of gigantic routers with super

0:52 high-bandwidth connections running between them.

0:53 To request this video file from youtube,

0:55 a packet had to work its way up to the backbone, travel along that for a bit,

0:59 and then work its way back down to a youtube server that had the file.

1:03 That might be four hops up, two hops across the backbone,

1:05 and four hops down, for a total of ten hops.

1:08 If you’re running Windows, MacOS or Linux,

1:10 you can see the route data takes to different places

1:12 on the internet by using the traceroute program on your computer.

1:16 Instructions in the Doobly Doo.

1:18 For us here at the Chad& Stacey Emigholz Studio in Indianapolis,

1:21 the route to the DFTBA server in California goes through 11 stops.

1:25 We start at 192.168.0.1— thats the IP address for my computer on our LAN.

1:30 Then there’s the wifi router here at the studio,

1:32 then a series of regional routers, then we get onto the backbone,

1:36 and then we start working back down to the computer hosting “DFTBA dot com”,

1:40 which has the IP address 104.24.109.186.

1:43 But how does a packet actually get there?

1:47 What happens if a packet gets lost along the way?

1:50 If I type “DFTBA dot com” into my web browser,

1:52 how does it know the server’s address?

1:54 Those are our topics for today!

1:56 INTRO As we discussed last episode, the internet is a huge distributed network

2:09 that sends data around as little packets.

2:11 If your data is big enough, like an email attachment,

2:13 it might get broken up into many packets.

2:16 For example, this video stream is arriving

2:18 to your computer right now as a series of packets, and not one gigantic file.

2:23 Internet packets have to conform to a standard

2:26 called the Internet Protocol, or IP.

2:27 It’s a lot like sending physical mail through the postal system–

2:30 every letter needs a unique and legible address written on it,

2:33 and there are limits to the size and weight of packages.

2:36 Violate this, and your letter won’t get through.

2:39 IP packets are very similar.

2:40 However, IP is a very low level protocol– there isn’t

2:43 much more than a destination address in a packet’s header,

2:46 which is the metadata that’s stored in front of the data payload.

2:49 This means that a packet can show up at a computer,

2:51 but the computer may not know which application

2:53 to give the data to; Skype or Call of Duty.

2:56 For this reason, more advanced protocols were developed that sit on top of IP.

3:00 One of the simplest and most common is the User Datagram Protocol, or UDP.

3:05 UDP has its own header, which sits inside the data payload.

3:08 Inside of the UDP header is some useful, extra information.

3:12 One of them is a port number.

3:13 Every program wanting to access the internet will ask its

3:16 host computer’s Operating System to be given a unique port.

3:19 Like Skype might ask for port number 3478.

3:23 When a packet arrives to the computer,

3:25 the Operating System will look inside the UDP header and read the port number.

3:29 Then, if it sees, for example, 3478, it will give the packet to Skype.

3:34 So to review, IP gets the packet to the right computer,

3:37 but UDP gets the packet to the right program running on that computer.

3:41 UDP headers also include something called a checksum,

3:43 which allows the data to be verified for correctness.

3:46 As the name suggests, it does this by checking the sum of the data.

3:49 Here’s a simplified version of how this works.

3:52 Lets imagine the raw data in our UDP packet is 89 111 33 32 58 and 41.

3:57 Before the packet is sent, the transmitting computer calculates the checksum

4:02 by adding all the data together: 89 plus 111 plus 33 and so on.

4:07 In our example, this adds up to a checksum of 364.

4:11 In UDP, the checksum value is stored in 16 bits.

4:14 If the sum exceeds the maximum possible value,

4:17 the upper-most bits overflow, and only the lower bits are used.

4:20 Now, when the receiving computer gets this packet,

4:22 it repeats the process, adding up all the data.

4:25 89 plus 111 plus 33 and so on.

4:28 If that sum is the same as the checksum sent in the header, all is well.

4:32 But, if the numbers don’t match,

4:33 you know that the data got corrupted at some point in transit,

4:36 maybe because of a power fluctuation or faulty cable.

4:39 Unfortunately, UDP doesn’t offer any mechanisms to fix the data,

4:42 or request a new copy– receiving programs are alerted to the corruption,

4:46 but typically just discard the packet.

4:48 Also, UDP provides no mechanisms to know if packets are

4:51 getting through– a sending computer shoots the UDP packet off,

4:54 but has no confirmation it ever gets to its destination successfully.

4:58 Both of these properties sound pretty catastrophic,

5:00 but some applications are ok with this, because

5:03 UDP is also really simple and fast.

5:05 Skype, for example, which uses UDP for video chat,

5:08 can handle corrupt or missing packets.

5:10 That’s why sometimes if you’re on a bad internet connection,

5:12 Skype gets all glitchy– only some of the UDP

5:14 packets are making it to your computer.

5:16 Skype does the best it can with the data it does receive correctly.

5:17 But this approach doesn’t work for many other types of data transmission.

5:20 Like, it doesn’t really work if you send an email,

5:22 and it shows up with the middle missing.

5:24 The whole message really needs to get there correctly!

5:26 When it “absolutely, positively needs to get there”,

5:29 programs use the Transmission Control Protocol,

5:31 or TCP, which like UDP, rides inside the data payload of IP packets.

5:37 For this reason, people refer to this combination of protocols as TCP/IP.

5:41 Like UDP, the TCP header contains a destination port and checksum.

5:45 But, it also contains fancier features, and we’ll focus on the key ones.

5:49 First off, TCP packets are given sequential numbers.

5:52 So packet 15 is followed by packet 16, which is followed by 17, and so on...

5:56 for potentially millions of packets sent during that session.

5:58 These sequence numbers allow a receiving computer

6:00 to put the packets into the correct order,

6:02 even if they arrive at different times across the network.

6:04 So if an email comes in all scrambled,

6:07 the TCP implementation in your computer’s operating

6:09 system will piece it all together correctly.

6:12 Second, TCP requires that once a computer has correctly received a packet–

6:15 and the data passes the checksum– that it send back an acknowledgement,

6:18 or “ACK” as the cool kids say, to the sending computer.

6:21 Knowing the packet made it successfully,

6:23 the sender can now transmit the next packet.

6:25 But this time, let’s say, it waits,

6:27 and doesn’t get an acknowledgement packet back.

6:29 Something must be wrong If enough time elapses,

6:32 the sender will go ahead and just retransmit the same packet.

6:35 It’s worth noting that the original packet might have actually gotten there,

6:38 but the acknowledgment is just really delayed.

6:40 Or perhaps it was the acknowledgment that was lost.

6:42 Either way, it doesn’t matter, because the receiver has those sequence numbers,

6:46 and if a duplicate packet arrives, it can be discarded.

6:49 Also, TCP isn’t limited to a back

6:51 and forth conversation– it can send many packets,

6:54 and have many outstanding ACKs, which increases bandwidth significantly,

6:57 since you aren’t wasting time waiting for acknowledgment packets to return.

7:01 Interestingly, the success rate of ACKs,

7:03 and also the round trip time between sending and acknowledging,

7:06 can be used to infer network congestion.

7:08 TCP uses this information to adjust how aggressively

7:11 it sends packets– a mechanism for congestion control.

7:14 So, basically, TCP can handle out-of-order packet delivery,

7:17 dropped packets– including retransmission– and even throttle

7:21 its transmission rate according to available bandwidth.

7:24 Pretty awesome!

7:25 You might wonder why anyone would use UDP when TCP has all these nifty features.

7:29 The single biggest downside are all those acknowledgment packets–

7:32 it doubles the number of messages on the network,

7:35 and yet, you're not transmitting any more data.

7:38 That overhead, including associated delays,

7:40 is sometimes not worth the improved robustness,

7:43 especially for time-critical applications,

7:45 like Multiplayer First Person Shooters.

7:47 And if it’s you getting lag-fragged you’ll definitely agree!

7:50 When your computer wants to make a connection to a website,

7:53 you need two things- an IP address and a port.

7:55 Like port 80, at 172.217.7.238.

8:00 This example is the IP address and port for the Google web server.

8:03 In fact, you can enter this into your browser’s address bar,

8:05 like so, and you’ll end up on the google homepage.

8:07 This gets you to the right destination,

8:09 but remembering that long string of digits would be really annoying.

8:13 It’s much easier to remember: google.com.

8:15 So the internet has a special service that maps these domain names to addresses.

8:19 It’s like the phone book for the internet.

8:21 And it’s called the Domain Name System, or DNS for short.

8:25 You can probably guess how it works.

8:26 When you type something like “youtube.com” into your web browser,

8:30 it goes and asks a DNS server– usually

8:33 one provided by your ISP– to lookup the address.

8:35 DNS consults its huge registry, and replies with the address...

8:39 if one exists.

8:40 In fact, if you try mashing your keyboard,

8:42 adding “.com”, and then hit enter in your browser,

8:44 you’ll likely be presented with an error that says DNS failed.

8:48 That’s because that site doesn’t exist,

8:49 so DNS couldn’t give your browser an address.

8:52 But, if DNS returns a valid address, which it should for “youtube.com”,

8:56 then your browser shoots off a request over TCP for the website’s data.

9:00 There’s over 300 million registered domain names,

9:02 so to make that DNS Lookup a little more manageable,

9:06 it’s not stored as one gigantically long list,

9:08 but rather in a tree data structure.

9:11 What are called Top Level Domains, or TLDs, are at the very top.

9:15 These are huge categories like .com and .gov.

9:17 Then, there are lower level domains

9:19 that sit below that, called second level domains;

9:22 Examples under .com include google.com and dftba.com.

9:25 Then, there are even lower level domains,

9:28 called subdomains, like images.google.com, store.dftba.com.

9:32 And this tree is absolutely HUGE!

9:35 Like I said, more than 300 million domain names,

9:37 and that's just second level domain names, not all the sub domains.

9:41 For this reason, this data is distributed across many DNS servers,

9:44 which are authorities for different parts of the tree.

9:47 Okay, I know you’ve been waiting for it...

9:49 We’ve reached a new level of abstraction!

9:57 Over the past two episodes, we’ve worked up from electrical signals on wires,

10:01 or radio signals transmitted through the air in the case of wireless networks.

10:05 This is called the Physical Layer.

10:07 MAC addresses, collision detection,

10:08 exponential backoff and similar low level protocols that mediate access

10:12 to the physical layer are part of the Data Link Layer.

10:15 Above this is the Network Layer, which is where all the switching

10:18 and routing technologies that we discussed operate.

10:20 And today, we mostly covered the Transport layer, protocols like UDP and TCP,

10:25 which are responsible for point to point data transfer between computers,

10:28 and also things like error detection and recovery when possible.

10:31 We’ve also grazed the Session Layer– where protocols like

10:34 TCP and UDP are used to open a connection, pass information back and forth,

10:38 and then close the connection when finished– what’s called a session.

10:42 This is exactly what happens when you, for example,

10:44 do a DNS Lookup, or request a webpage.

10:47 These are the bottom five layers of the Open System Interconnection (OSI) model,

10:51 a conceptual framework for compartmentalizing

10:53 all these different network processes.

10:55 Each level has different things to worry about and solve,

10:58 and it would be impossible to build one huge networking implementation.

11:02 As we’ve talked about all series,

11:03 abstraction allows computer scientists and engineers to be

11:06 improving all these different levels of the stack simultaneously,

11:09 without being overwhelmed by the full complexity.

11:12 And amazingly, we’re not quite done yet… The OSI model has two more layers,

11:16 the Presentation Layer and the Application Layer,

11:18 which include things like web browsers,

11:21 Skype, HTML decoding, streaming movies and more.

11:23 Which we’ll talk about next week.

11:25 See you then.

Study with Looplines Download Captions Watch on YouTube