<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title>Layman's Guide to Computing - Season 03</title><link href="https://ngjunsiang.github.io/laymansguide/" rel="alternate"></link><link href="https://ngjunsiang.github.io/laymansguide/feeds/season-03.atom.xml" rel="self"></link><id>https://ngjunsiang.github.io/laymansguide/</id><updated>2019-09-21T08:00:00+08:00</updated><entry><title>Issue 39: Caches and caching</title><link href="https://ngjunsiang.github.io/laymansguide/issue039.html" rel="alternate"></link><published>2019-09-21T08:00:00+08:00</published><updated>2019-09-21T08:00:00+08:00</updated><author><name>J S Ng</name></author><id>tag:ngjunsiang.github.io,2019-09-21:/laymansguide/issue039.html</id><summary type="html">&lt;p&gt;Your computer and browser speed up a lot of lookups by caching information that is unlikely to change from the last view. When the same information is requested, your computer or browser will first look in the cache to find that information, and retrieve it from cache if it is there, otherwise it will load the information (and store it in cache if allowed to). There are usually ways to bypass a cache if the information is stale or no longer&amp;nbsp;correct.&lt;/p&gt;</summary><content type="html">&lt;p&gt;&lt;strong&gt;Previously:&lt;/strong&gt; When a webpage document loads (Stage 1), it is processed by the web browser, which then
loads other requested resources, such as stylesheets, images, and scripts (Stage 2). Scripts and other interactive code may then request more resources (data fetches, images, icons, data, etc) which are then loaded subsequently (Stage 3, 4, 5,&amp;nbsp;…).&lt;/p&gt;
&lt;p&gt;Last issue, I showed you using Developer Tools how a webpage is loaded in stages, and how that contributes to latency alongside &lt;span class="caps"&gt;DNS&lt;/span&gt; querying and data routing. We saw that it could add up to a few seconds of latency, which would be unbearable for a lot of people (first-world&amp;nbsp;problems!).&lt;/p&gt;
&lt;p&gt;Searching for anything takes time. Need to fill out a form? You need to search for a pen first. Need to call someone? Before speed dial and contacts apps existed, You used to need to look up a number in order to dial it. If you do it often enough, you would make sure you always had a pen with you, or you would write the number somewhere convenient for you to see so you don’t need to hunt for&amp;nbsp;it.&lt;/p&gt;
&lt;p&gt;Computers use the same trick, and it is called &lt;strong&gt;caching&lt;/strong&gt;. Any information it needs repeatedly which is unchanging is stored in a &lt;strong&gt;cache&lt;/strong&gt;. What kind of caches does a computer use to reduce network&amp;nbsp;latency?&lt;/p&gt;
&lt;h2&gt;&lt;span class="caps"&gt;DNS&lt;/span&gt;&amp;nbsp;cache&lt;/h2&gt;
&lt;p&gt;When you load a webpage or service and send requests to it, the first thing that happens is the &lt;span class="caps"&gt;DNS&lt;/span&gt; query. Once your &lt;span class="caps"&gt;OS&lt;/span&gt; knows the &lt;span class="caps"&gt;IP&lt;/span&gt; address to send requests to, it doesn’t make sense for it to keep querying the hostname, does it? &lt;span class="caps"&gt;IP&lt;/span&gt; addresses don’t change that quickly! The computer stores the hostnames and associated &lt;span class="caps"&gt;IP&lt;/span&gt; addresses in the &lt;span class="caps"&gt;DNS&lt;/span&gt; cache. You can view the &lt;span class="caps"&gt;DNS&lt;/span&gt; cache on a Windows &lt;span class="caps"&gt;PC&lt;/span&gt; by opening Command Prompt and&amp;nbsp;typing &lt;code&gt;ipconfig /displaydns&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img alt="The DNS cache" src="https://ngjunsiang.github.io/laymansguide/issue039_01.jpg" /&gt;&lt;br /&gt;
&lt;small&gt;The output&amp;nbsp;of &lt;code&gt;ipconfig /displaydns&lt;/code&gt;&lt;br /&gt;
(I used Powershell instead of Command Prompt,
but it will look the same in Command Prompt.)&lt;/small&gt;&lt;/p&gt;
&lt;p&gt;The computer always goes to the &lt;span class="caps"&gt;DNS&lt;/span&gt; cache first. If it can’t find the hostname (e.g. facebook.com) in the &lt;span class="caps"&gt;DNS&lt;/span&gt; cache, it will perform a lookup, then store the hostname and associated &lt;span class="caps"&gt;IP&lt;/span&gt; address in &lt;span class="caps"&gt;DNS&lt;/span&gt; cache. This information is stored for a day, then discarded, just in case the information has been&amp;nbsp;refreshed.&lt;/p&gt;
&lt;p&gt;Sometimes, this causes problems. A company or service may be in the process of moving servers and thus changing &lt;span class="caps"&gt;IP&lt;/span&gt; addresses. If the move didn’t go smoothly, your computer may be stuck with the wrong &lt;span class="caps"&gt;DNS&lt;/span&gt; information for some hosts. Or sometimes something just goes wrong with the &lt;span class="caps"&gt;DNS&lt;/span&gt; query and you are stuck with bad&amp;nbsp;information.&lt;/p&gt;
&lt;p&gt;When this happens, tech support will usually just flush the &lt;span class="caps"&gt;DNS&lt;/span&gt; cache to remove all information from it (yes, the bad with the good). On Windows, you can do so by opening Command Prompt and&amp;nbsp;typing &lt;code&gt;ipconfig /flushdns&lt;/code&gt;.&lt;/p&gt;
&lt;h2&gt;Browser&amp;nbsp;cache&lt;/h2&gt;
&lt;p&gt;Notice that the first time your web browser loads any page you haven’t visited before, it often takes quite a while, but subsequent loads are really fast? That’s because we now skip a &lt;span class="caps"&gt;DNS&lt;/span&gt; query (grabbing the &lt;span class="caps"&gt;IP&lt;/span&gt; address from the &lt;span class="caps"&gt;DNS&lt;/span&gt; cache instead). Each time we do a lookup to retrieve a file or piece of information from the server, we can skip the &lt;span class="caps"&gt;DNS&lt;/span&gt;&amp;nbsp;query!&lt;/p&gt;
&lt;p&gt;The caching trick isn’t applied only to the &lt;span class="caps"&gt;IP&lt;/span&gt; address; many elements you see on the page have been cached: the document itself, images, scripts, stylesheets, … most of the elements from &lt;a href="https://ngjunsiang.github.io/laymansguide/issue038.html"&gt;Issue 38&lt;/a&gt;) are cacheable, and the browser will cache&amp;nbsp;it.&lt;/p&gt;
&lt;p&gt;How long does the browser cache these files? It depends &amp;#8230; I know it’s not an answer you like since it means more things to learn about, but I’ll keep it&amp;nbsp;short.&lt;/p&gt;
&lt;p&gt;Remember this? It’s the response header we saw from &lt;a href="https://ngjunsiang.github.io/laymansguide/issue008.html"&gt;Issue 8&lt;/a&gt;) on &lt;span class="caps"&gt;HTTP&lt;/span&gt; error&amp;nbsp;codes:&lt;/p&gt;
&lt;p&gt;&lt;img alt="HTTP response header" src="https://ngjunsiang.github.io/laymansguide/issue008_01.png" /&gt;&lt;br /&gt;
&lt;em&gt;A response header from&amp;nbsp;Hypothes.is&lt;/em&gt;    &lt;/p&gt;
&lt;p&gt;See the line that&amp;nbsp;says &lt;code&gt;Cache-Control: no-cache&lt;/code&gt;? That is the server, hypothes.is, asking my browser not to cache this response (because the next time it makes the same &lt;span class="caps"&gt;API&lt;/span&gt; request, the response might be&amp;nbsp;different).&lt;/p&gt;
&lt;p&gt;The server can also set a&amp;nbsp;different &lt;code&gt;Cache-Control&lt;/code&gt; time, especially for resources that are used repeatedly on pages (such as logos and headers). On heavily accessed sites, these resources may have&amp;nbsp;a &lt;code&gt;Cache-Control&lt;/code&gt; time of up to a&amp;nbsp;year!&lt;/p&gt;
&lt;p&gt;If you want to bypass the cached version of the page and force a full reload, you can do so on most browsers using the&amp;nbsp;hotkey &lt;code&gt;Ctrl-F5&lt;/code&gt; instead&amp;nbsp;of &lt;code&gt;F5&lt;/code&gt;.&lt;/p&gt;
&lt;h2&gt;Flushing the browser&amp;nbsp;cache&lt;/h2&gt;
&lt;p&gt;The browser typically stores cached files and data until it exceeds the storage limit set in the browser, at which point it will begin ejecting the oldest files. You can force the browser to remove these files through a menu setting usually named something like “Clear browsing data” or just “Clear&amp;nbsp;data”.&lt;/p&gt;
&lt;p&gt;On some sites, especially internet banking sites, you may be asked to flush your cache after you log out; they are asking you to clear cached files and cookies stored in the browser, especially if you are on a public computer or some device that is not your own. the hotkey for doing so (if you are on a laptop) is&amp;nbsp;usually &lt;code&gt;Ctrl-Shift-Del&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Issue summary:&lt;/strong&gt; Your computer and browser speed up a lot of lookups by caching information that is unlikely to change from the last view. When the same information is requested, your computer or browser will first look in the cache to find that information, and retrieve it from cache if it is there, otherwise it will load the information (and store it in cache if allowed to). There are usually ways to bypass a cache if the information is stale or no longer&amp;nbsp;correct.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;And Season 3’s a wrap! I know I may have mentioned that I don’t intend to write howtos in this newsletter, but clearing the cache is something I google for so often, and I see many others googling for it too, that I figured it might help to include a bit of info for those who want to know. At worst, many more people now know how to force-reload a page …&amp;nbsp;😅&lt;/p&gt;
&lt;h2&gt;What I’ll be covering&amp;nbsp;next&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Next season:&lt;/strong&gt; I’ve talked so much about networks: how they work and what they do, and then used that to build up to an explanation for “why is the internet so slow?”. It’s not a complete explanation yet—that will still take awhile—but I think we’re off to a good&amp;nbsp;start.&lt;/p&gt;
&lt;p&gt;As I wrote Season 3, it gradually became clear to me that before I start writing about cloud computing, I’m going to need to talk about data first. Computers ultimately store everything in binary,&amp;nbsp;like &lt;code&gt;010101011100101000100101&lt;/code&gt;, so how do they use something so basic to represent everything from text to images to audio to videos and more? and how do they set up a system for storing and retrieving this information&amp;nbsp;easily?&lt;/p&gt;
&lt;p&gt;I’m not going to talk about binary and hex numbers much if at all; I don’t think it’s relevant for a newsletter like this. But since so many things are measured in bits and bytes, it’s impossible to escape that discussion. I want to build the issues up to answer questions I’ve been getting, like “why do my &lt;span class="caps"&gt;JPG&lt;/span&gt; files have this weird fuzz”, and “why are my audio files so large”, and “can I make this zip file smaller by putting it in another zip file”, and “why do I get these weird rectangles or question marks in my web browser”, and many more&amp;nbsp;:)&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Sometime in the future:&lt;/strong&gt; What&amp;nbsp;is:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;booting up? [Issue&amp;nbsp;15]&lt;/li&gt;
&lt;li&gt;a cookie? [Issue&amp;nbsp;8]&lt;/li&gt;
&lt;li&gt;&lt;del&gt;a cache? [Issue 8]&lt;/del&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class="caps"&gt;XSS&lt;/span&gt;? [Issue&amp;nbsp;8]&lt;/li&gt;
&lt;li&gt;a &lt;span class="caps"&gt;CDN&lt;/span&gt;? [Issue&amp;nbsp;8]&lt;/li&gt;
&lt;li&gt;Unicode? And what does it have to do with emoji? [Issue&amp;nbsp;8]&lt;/li&gt;
&lt;li&gt;those &amp;#8216;\r\n’s in the &lt;span class="caps"&gt;HTTP&lt;/span&gt; request packet [Issue&amp;nbsp;12,17]?&lt;/li&gt;
&lt;li&gt;a good reason developers write code and give it away for free online? [Issue&amp;nbsp;21]&lt;/li&gt;
&lt;li&gt;&lt;span class="caps"&gt;ASCII&lt;/span&gt;? [Issue&amp;nbsp;23]&lt;/li&gt;
&lt;li&gt;compiling code into an application [Issue&amp;nbsp;26]?&lt;/li&gt;
&lt;li&gt;firmware? [Issue&amp;nbsp;34]&lt;/li&gt;
&lt;li&gt;What is &lt;span class="caps"&gt;HTML&lt;/span&gt; [Issue&amp;nbsp;38]&lt;/li&gt;
&lt;/ul&gt;</content><category term="Season 03"></category><category term="cache"></category></entry><entry><title>Issue 38: Loading a web page</title><link href="https://ngjunsiang.github.io/laymansguide/issue038.html" rel="alternate"></link><published>2019-09-14T08:00:00+08:00</published><updated>2019-09-14T08:00:00+08:00</updated><author><name>J S Ng</name></author><id>tag:ngjunsiang.github.io,2019-09-14:/laymansguide/issue038.html</id><summary type="html">&lt;p&gt;When a webpage document loads (Stage 1), it is processed by the web browser, which&amp;nbsp;then&lt;/p&gt;</summary><content type="html">&lt;p&gt;&lt;strong&gt;Previously:&lt;/strong&gt; Data packets hop from server to server. The more hops a packet must undergo, the longer the latency. The slower the servers along the route, the longer the latency as&amp;nbsp;well.&lt;/p&gt;
&lt;p&gt;Last issue, I showed the route taken by data packets being sent to google.com, and to baidu.com. We don’t know what is in those data packets (yet), so in this issue I want to show you just how many requests/responses are involved in loading a webpage. I’ll be doing so using a tool that is available in Chrome and Firefox, which you might have accidentally opened before when you pressed some unknown hotkey combination, and wondered if you broke your browser. This tool is called &lt;strong&gt;Developer Tools&lt;/strong&gt;, and it opens any time you right-click something in a webpage and then click &amp;#8216;Inspect Element&amp;#8217;, or if you press&amp;nbsp;the &lt;code&gt;Ctrl-Alt-I&lt;/code&gt; hotkey. It shows you what the backend of a webpage looks like, and today we’ll look at one of its&amp;nbsp;features.&lt;/p&gt;
&lt;h2&gt;Loading a Github&amp;nbsp;webpage&lt;/h2&gt;
&lt;p&gt;The Github repository where I keep my laymansguide files can be viewed on a webpage, and it looks like&amp;nbsp;this:&lt;/p&gt;
&lt;p&gt;&lt;img alt="Github page for laymansguide" src="https://ngjunsiang.github.io/laymansguide/issue038_01.png" /&gt;&lt;br /&gt;
&lt;em&gt;Github page for&amp;nbsp;laymansguide&lt;/em&gt;    &lt;/p&gt;
&lt;p&gt;Loading this page with the Network tab of Developer Tools open produces this&amp;nbsp;report:&lt;/p&gt;
&lt;p&gt;&lt;img alt="Developer Tools showing network activity while loading a Github page" src="https://ngjunsiang.github.io/laymansguide/issue038_02.png" /&gt;&lt;br /&gt;
&lt;em&gt;Developer Tools, Network&amp;nbsp;view&lt;/em&gt;    &lt;/p&gt;
&lt;p&gt;This is a summary of the network activity that is happening while the page is loading. The top ribbon, showing time in milliseconds (ms) and a series of horizontal lines, is what is known as a &lt;em&gt;waterfall chart&lt;/em&gt;. (You can also see this chart in the rightmost column below the&amp;nbsp;ribbon.)&lt;/p&gt;
&lt;p&gt;Each line represents the loading of a resource—anything that the page requests while it is loading. Lines stacked on top of each other represent resources that are being loaded simultaneously (ideal), while lines joined end-to-end represent resources that are being loaded in tandem, one after the other (not&amp;nbsp;ideal).&lt;/p&gt;
&lt;p&gt;The resource list below it shows the resources that were loaded. You see that all kinds of files are needed: documents, stylesheets, scripts, image files (svg, gif, jpeg, png, webp), icons (.ico), and more. The vertical blue line represents the point where the web browser has loaded and processed the main document (first item in the resource list). The vertical red line represents the point where the webpage is considered to be loaded (able to display its main content), while secondary resources are still loading in the&amp;nbsp;background.&lt;/p&gt;
&lt;p&gt;Why can’t they all be loaded simultaneously to save time? Sit down and I’ll tell you a story&amp;nbsp;…&lt;/p&gt;
&lt;h2&gt;Timeline of a loading&amp;nbsp;webpage&lt;/h2&gt;
&lt;p&gt;In the beginning was The Void. And&amp;nbsp;then:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;code&gt;laymansguide&lt;/code&gt; loads (0–673 ms), because a request was sent for it when I asked my web browser to&amp;nbsp;load &lt;code&gt;https://github.com/ngjunsiang/laymansguide&lt;/code&gt;. This is the first resource in the&amp;nbsp;list.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;laymansguide&lt;/code&gt; is a webpage, an &lt;span class="caps"&gt;HTML&lt;/span&gt; (HyperText Markup Language) file, which I will explain in a future issue. Inside, it contains lines like these, isolated here for your reading&amp;nbsp;pleasure:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;stylesheet&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;https://github.githubassets.com/assets/frameworks-2e9090135c22aad5f56c2f72dcba7880.css&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;stylesheet&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;https://github.githubassets.com/assets/github-cbb49d8cd46cbc8c522a95d52b21ab53.css&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;https://github.githubassets.com/images/search-key-slash.svg&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="na"&gt;alt=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;mr-2 header-search-key-slash&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;include-fragment&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;my-2&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;img&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="na"&gt;alt=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;Loading&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;https://github.githubassets.com/images/spinners/octocat-spinner-32.gif&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="na"&gt;width=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;32&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="na"&gt;height=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;32&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&amp;lt;/include-fragment&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;avatar&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;https://avatars3.githubusercontent.com/u/45561895?s=40&amp;amp;amp;v=4&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
[...]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Lines like these in the document are interpreted by the web browser. They tell the browser that more resources are needed, and where they need to be loaded from (either through&amp;nbsp;the &lt;code&gt;"href="&lt;/code&gt; addresses or&amp;nbsp;the &lt;code&gt;"src="&lt;/code&gt; addresses). The web browser then sends more requests for these files. That is why you only see them loading &lt;strong&gt;after&lt;/strong&gt; the document has loaded: my web browser has to receive and process the document first to know where to retrieve these&amp;nbsp;files.&lt;/p&gt;
&lt;p&gt;The stylesheets (files that end&amp;nbsp;in &lt;code&gt;.css&lt;/code&gt;) tell the document how to style elements in the page. I won’t elaborate on that in detail here, perhaps in a different season of&amp;nbsp;laymansguide.&lt;/p&gt;
&lt;p&gt;The images are … well, images. More on them in a future season about data&amp;nbsp;types.&lt;/p&gt;
&lt;p&gt;The scripts, ah, that’s something to go into. While stylesheets and images are just information to be inserted into the page, scripts are actually code, usually Javascript&amp;nbsp;code.&lt;/p&gt;
&lt;p&gt;This code does animations, calculation of time conversions, and many other things, including loading more resources. I’m not going to paste the whole script here, I don’t want to chase my readers away … okay, maybe just a couple of lines. The last script file that is&amp;nbsp;loaded, &lt;code&gt;github-bootstrap-747cdfeb.js&lt;/code&gt;, is a companion script file for the Bootstrap&lt;sup id="fnref:1"&gt;&lt;a class="footnote-ref" href="#fn:1"&gt;1&lt;/a&gt;&lt;/sup&gt; framework that Github uses to simplify their webpage code. It has the following&amp;nbsp;lines:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="k"&gt;[...]&lt;/span&gt;
&lt;span class="na"&gt;const e&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;function(e) {const t = document.createElement(&amp;quot;img&amp;quot;)&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
&lt;span class="w"&gt;                       &lt;/span&gt;&lt;span class="na"&gt;return t.className&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;&amp;quot;emoji&amp;quot;&lt;/span&gt;&lt;span class="na"&gt;}(this);&lt;/span&gt;
&lt;span class="na"&gt;e.src&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;this.getAttribute(&amp;quot;fallback-src&amp;quot;) || &amp;quot;&amp;quot;,this.appendChild(e)&lt;/span&gt;
&lt;span class="k"&gt;[...]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;This creates&amp;nbsp;an &lt;code&gt;img&lt;/code&gt; element&amp;nbsp;named &lt;code&gt;e&lt;/code&gt;, styles it according to the style&amp;nbsp;class &lt;code&gt;emoji&lt;/code&gt;, then associates it with the address retrieved&amp;nbsp;from &lt;code&gt;fallback-src&lt;/code&gt;, and finally it gets appended to another element in the page through the&amp;nbsp;function &lt;code&gt;appendChild&lt;/code&gt;. That’s right, this code inserts emojis, so&amp;nbsp;the &lt;code&gt;laymansguide&lt;/code&gt; document has to retrieve those emoji image files first. Before this script plays, the page won’t even know that those emojis are&amp;nbsp;necessary.&lt;/p&gt;
&lt;p&gt;And now we come to the last part of the waterfall, where additional resources requested by scripts and other things are loaded. It’s not worth going through them in detail, we won’t learn much more from that. So let’s&amp;nbsp;summarise.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Issue summary:&lt;/strong&gt; When a webpage document loads (Stage 1), it is processed by the web browser, which then
loads other requested resources, such as stylesheets, images, and scripts (Stage 2). Scripts and other interactive code may then request more resources (data fetches, images, icons, data, etc) which are then loaded subsequently (Stage 3, 4, 5,&amp;nbsp;…).&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;&lt;strong&gt;Bonus content:&lt;/strong&gt; I tried this with the Baidu homepage, which looks like&amp;nbsp;this:&lt;/p&gt;
&lt;p&gt;&lt;img alt="Baidu homepage" src="https://ngjunsiang.github.io/laymansguide/issue038_03.png" /&gt;&lt;br /&gt;
&lt;em&gt;Baidu&amp;nbsp;homepage&lt;/em&gt;    &lt;/p&gt;
&lt;p&gt;and the network activity from loading&amp;nbsp;it:&lt;/p&gt;
&lt;p&gt;&lt;img alt="Developer Tools showing network activity while loading Baidu homepage" src="https://ngjunsiang.github.io/laymansguide/issue038_04.png" /&gt;&lt;br /&gt;
&lt;em&gt;Developer Tools, Network&amp;nbsp;view&lt;/em&gt;    &lt;/p&gt;
&lt;p&gt;It takes slightly longer (about 400 ms longer) to load, but most of that time is from loading a&amp;nbsp;single &lt;code&gt;gif&lt;/code&gt;. I wont examine the elements here, in the season on the internet cloud, I’ll explain more what some of these elements&amp;nbsp;do.&lt;/p&gt;
&lt;p&gt;So far, we have identified 3 sources of&amp;nbsp;latency:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;span class="caps"&gt;DNS&lt;/span&gt; resolving (&lt;a href="https://ngjunsiang.github.io/laymansguide/issue029.html"&gt;Issue 29&lt;/a&gt;)), which translates the domain names in the requests to &lt;span class="caps"&gt;IP&lt;/span&gt; addresses that we can request data&amp;nbsp;from,&lt;/li&gt;
&lt;li&gt;Data packet routing (&lt;a href="https://ngjunsiang.github.io/laymansguide/issue037.html"&gt;Issue 37&lt;/a&gt;)), which adds to latency with each hop through yet another&amp;nbsp;gateway,&lt;/li&gt;
&lt;li&gt;Webpage loading (this issue), where documents or scripts that are loaded may request yet more&amp;nbsp;resources.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;All of these layers of information gathering can add up to a few seconds of latency—a big turnoff for folks who have come to expect near-instantaneous response from apps. And often, our pages don’t appear to take that long to load, do&amp;nbsp;they?&lt;/p&gt;
&lt;p&gt;In the next issue, the season finale, I’ll explain one common trick for making anything appear faster: it is called &lt;strong&gt;caching&lt;/strong&gt;.&lt;/p&gt;
&lt;h2&gt;What I’ll be covering&amp;nbsp;next&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Next issue:&lt;/strong&gt; What are caches? What is&amp;nbsp;caching?&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Sometime in the future:&lt;/strong&gt; What&amp;nbsp;is:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;booting up? [Issue&amp;nbsp;15]&lt;/li&gt;
&lt;li&gt;a cookie? [Issue&amp;nbsp;8]&lt;/li&gt;
&lt;li&gt;a cache? [Issue&amp;nbsp;8]&lt;/li&gt;
&lt;li&gt;&lt;span class="caps"&gt;XSS&lt;/span&gt;? [Issue&amp;nbsp;8]&lt;/li&gt;
&lt;li&gt;a &lt;span class="caps"&gt;CDN&lt;/span&gt;? [Issue&amp;nbsp;8]&lt;/li&gt;
&lt;li&gt;Unicode? And what does it have to do with emoji? [Issue&amp;nbsp;8]&lt;/li&gt;
&lt;li&gt;those &amp;#8216;\r\n’s in the &lt;span class="caps"&gt;HTTP&lt;/span&gt; request packet [Issue&amp;nbsp;12,17]?&lt;/li&gt;
&lt;li&gt;a good reason developers write code and give it away for free online? [Issue&amp;nbsp;21]&lt;/li&gt;
&lt;li&gt;&lt;span class="caps"&gt;ASCII&lt;/span&gt;? [Issue&amp;nbsp;23]&lt;/li&gt;
&lt;li&gt;compiling code into an application [Issue&amp;nbsp;26]?&lt;/li&gt;
&lt;li&gt;firmware? [Issue&amp;nbsp;34]&lt;/li&gt;
&lt;li&gt;What is &lt;span class="caps"&gt;HTML&lt;/span&gt; [Issue&amp;nbsp;38]&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="footnote"&gt;
&lt;hr /&gt;
&lt;ol&gt;
&lt;li id="fn:1"&gt;
&lt;p&gt;&lt;a href="https://getbootstrap.com/docs/4.3/getting-started/introduction/"&gt;Bootstrap&lt;/a&gt; is a &lt;a href="https://ngjunsiang.github.io/laymansguide/issue014.html"&gt;front-end&lt;/a&gt;) &lt;a href="https://ngjunsiang.github.io/laymansguide/issue018.html"&gt;framework&lt;/a&gt;) that makes it easy to create webpages. By loading a standard Bootstrap stylesheet and (optionally) a Bootstrap script, any front-end developer can add common elements (e.g. popovers, navigation bars, tooltips, cards, …) with fewer lines of code than if they wrote it from scratch.&amp;#160;&lt;a class="footnote-backref" href="#fnref:1" title="Jump back to footnote 1 in the text"&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;</content><category term="Season 03"></category><category term="document"></category></entry><entry><title>Issue 37: Traceroute–Google Maps for data packets</title><link href="https://ngjunsiang.github.io/laymansguide/issue037.html" rel="alternate"></link><published>2019-09-07T08:00:00+08:00</published><updated>2019-09-07T08:00:00+08:00</updated><author><name>J S Ng</name></author><id>tag:ngjunsiang.github.io,2019-09-07:/laymansguide/issue037.html</id><summary type="html">&lt;p&gt;The process of forwarding data packets from server to server takes time. Each hop a data packet takes adds to the latency. The more hops a packet must undergo, the longer the latency. The slower the servers along the route, the longer the latency as&amp;nbsp;well.&lt;/p&gt;</summary><content type="html">&lt;p&gt;&lt;strong&gt;Previously:&lt;/strong&gt; Latency is the time duration between a ping packet being sent out and its response being received. It is an indication of how far away a target server&amp;nbsp;is.&lt;/p&gt;
&lt;p&gt;Last issue, we saw that the latency for google.com&amp;#8217;s servers was almost 8× shorter than that for baidu.com&amp;#8217;s servers. Let&amp;#8217;s see&amp;nbsp;why.&lt;/p&gt;
&lt;h2&gt;traceroute&lt;/h2&gt;
&lt;p&gt;I use the commandline application (&lt;a href="https://ngjunsiang.github.io/laymansguide/issue015.html"&gt;Issue 15&lt;/a&gt;)) &lt;code&gt;traceroute&lt;/code&gt; to display the entire route taken by the data packet. The commandline prompt in Linux usually starts with&amp;nbsp;a &lt;code&gt;$&lt;/code&gt;, so any text you see after a&amp;nbsp;beginning &lt;code&gt;$&lt;/code&gt; in the same line is the command I am using. Everything that follows is the output from&amp;nbsp;the &lt;code&gt;traceroute&lt;/code&gt; application.&amp;nbsp;the &lt;code&gt;-T&lt;/code&gt; option&amp;nbsp;tells &lt;code&gt;traceroute&lt;/code&gt; to use &lt;span class="caps"&gt;TCP&lt;/span&gt; packets to trace the path of our data&amp;nbsp;packets.&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;$&lt;span class="w"&gt; &lt;/span&gt;traceroute&lt;span class="w"&gt; &lt;/span&gt;-T&lt;span class="w"&gt; &lt;/span&gt;google.com
traceroute&lt;span class="w"&gt; &lt;/span&gt;to&lt;span class="w"&gt; &lt;/span&gt;google.com&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="m"&gt;74&lt;/span&gt;.125.24.138&lt;span class="o"&gt;)&lt;/span&gt;,&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;30&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;hops&lt;span class="w"&gt; &lt;/span&gt;max,&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;60&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;byte&lt;span class="w"&gt; &lt;/span&gt;packets
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;_gateway&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="m"&gt;192&lt;/span&gt;.168.1.1&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;.971&lt;span class="w"&gt; &lt;/span&gt;ms&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;.959&lt;span class="w"&gt; &lt;/span&gt;ms&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;.951&lt;span class="w"&gt; &lt;/span&gt;ms
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;.128.104.27.unknown.m1.com.sg&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="m"&gt;27&lt;/span&gt;.104.128.1&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="m"&gt;4&lt;/span&gt;.577&lt;span class="w"&gt; &lt;/span&gt;ms&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="m"&gt;4&lt;/span&gt;.579&lt;span class="w"&gt; &lt;/span&gt;ms&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="m"&gt;4&lt;/span&gt;.572&lt;span class="w"&gt; &lt;/span&gt;ms
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;3&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="m"&gt;43&lt;/span&gt;.245.104.65&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="m"&gt;43&lt;/span&gt;.245.104.65&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="m"&gt;3&lt;/span&gt;.868&lt;span class="w"&gt; &lt;/span&gt;ms&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="m"&gt;3&lt;/span&gt;.865&lt;span class="w"&gt; &lt;/span&gt;ms&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="m"&gt;3&lt;/span&gt;.854&lt;span class="w"&gt; &lt;/span&gt;ms
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;4&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="m"&gt;5&lt;/span&gt;.246.65.202.unknown.m1.com.sg&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="m"&gt;202&lt;/span&gt;.65.246.5&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="m"&gt;6&lt;/span&gt;.396&lt;span class="w"&gt; &lt;/span&gt;ms&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="m"&gt;3&lt;/span&gt;.829&lt;span class="w"&gt; &lt;/span&gt;ms&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="m"&gt;3&lt;/span&gt;.799&lt;span class="w"&gt; &lt;/span&gt;ms
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;5&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="m"&gt;37&lt;/span&gt;.246.65.202.unknown.m1.com.sg&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="m"&gt;202&lt;/span&gt;.65.246.37&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="m"&gt;18&lt;/span&gt;.766&lt;span class="w"&gt; &lt;/span&gt;ms&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="m"&gt;18&lt;/span&gt;.761&lt;span class="w"&gt; &lt;/span&gt;ms&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="m"&gt;5&lt;/span&gt;.129&lt;span class="w"&gt; &lt;/span&gt;ms
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;6&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="m"&gt;134&lt;/span&gt;.246.65.202.unknown.m1.com.sg&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="m"&gt;202&lt;/span&gt;.65.246.134&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="m"&gt;8&lt;/span&gt;.222&lt;span class="w"&gt; &lt;/span&gt;ms&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;221&lt;/span&gt;.246.65.202.unknown.m1.com.sg&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="m"&gt;202&lt;/span&gt;.65.246.221&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="m"&gt;3&lt;/span&gt;.928&lt;span class="w"&gt; &lt;/span&gt;ms&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="m"&gt;3&lt;/span&gt;.901&lt;span class="w"&gt; &lt;/span&gt;ms
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;7&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="m"&gt;72&lt;/span&gt;.14.222.102&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="m"&gt;72&lt;/span&gt;.14.222.102&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="m"&gt;3&lt;/span&gt;.882&lt;span class="w"&gt; &lt;/span&gt;ms&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="m"&gt;3&lt;/span&gt;.705&lt;span class="w"&gt; &lt;/span&gt;ms&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="m"&gt;3&lt;/span&gt;.661&lt;span class="w"&gt; &lt;/span&gt;ms
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;8&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="m"&gt;209&lt;/span&gt;.85.243.27&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="m"&gt;209&lt;/span&gt;.85.243.27&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="m"&gt;3&lt;/span&gt;.621&lt;span class="w"&gt; &lt;/span&gt;ms&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;74&lt;/span&gt;.125.252.107&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="m"&gt;74&lt;/span&gt;.125.252.107&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="m"&gt;4&lt;/span&gt;.638&lt;span class="w"&gt; &lt;/span&gt;ms&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;72&lt;/span&gt;.14.238.42&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="m"&gt;72&lt;/span&gt;.14.238.42&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="m"&gt;4&lt;/span&gt;.621&lt;span class="w"&gt; &lt;/span&gt;ms
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;9&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="m"&gt;108&lt;/span&gt;.170.254.227&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="m"&gt;108&lt;/span&gt;.170.254.227&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="m"&gt;4&lt;/span&gt;.180&lt;span class="w"&gt; &lt;/span&gt;ms&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;108&lt;/span&gt;.170.240.241&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="m"&gt;108&lt;/span&gt;.170.240.241&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="m"&gt;4&lt;/span&gt;.071&lt;span class="w"&gt; &lt;/span&gt;ms&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;108&lt;/span&gt;.170.240.242&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="m"&gt;108&lt;/span&gt;.170.240.242&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="m"&gt;4&lt;/span&gt;.059&lt;span class="w"&gt; &lt;/span&gt;ms
&lt;span class="m"&gt;10&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="m"&gt;72&lt;/span&gt;.14.236.242&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="m"&gt;72&lt;/span&gt;.14.236.242&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="m"&gt;4&lt;/span&gt;.882&lt;span class="w"&gt; &lt;/span&gt;ms&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;216&lt;/span&gt;.239.57.50&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="m"&gt;216&lt;/span&gt;.239.57.50&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="m"&gt;4&lt;/span&gt;.771&lt;span class="w"&gt; &lt;/span&gt;ms&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;216&lt;/span&gt;.239.50.192&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="m"&gt;216&lt;/span&gt;.239.50.192&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="m"&gt;5&lt;/span&gt;.476&lt;span class="w"&gt; &lt;/span&gt;ms
&lt;span class="m"&gt;11&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="m"&gt;72&lt;/span&gt;.14.233.43&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="m"&gt;72&lt;/span&gt;.14.233.43&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="m"&gt;9&lt;/span&gt;.760&lt;span class="w"&gt; &lt;/span&gt;ms&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;72&lt;/span&gt;.14.233.27&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="m"&gt;72&lt;/span&gt;.14.233.27&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="m"&gt;4&lt;/span&gt;.700&lt;span class="w"&gt; &lt;/span&gt;ms&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="m"&gt;4&lt;/span&gt;.665&lt;span class="w"&gt; &lt;/span&gt;ms
&lt;span class="m"&gt;12&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;*&lt;span class="w"&gt; &lt;/span&gt;*&lt;span class="w"&gt; &lt;/span&gt;*
&lt;span class="m"&gt;13&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;*&lt;span class="w"&gt; &lt;/span&gt;*&lt;span class="w"&gt; &lt;/span&gt;*
&lt;span class="m"&gt;14&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;*&lt;span class="w"&gt; &lt;/span&gt;*&lt;span class="w"&gt; &lt;/span&gt;*
&lt;span class="m"&gt;15&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;*&lt;span class="w"&gt; &lt;/span&gt;*&lt;span class="w"&gt; &lt;/span&gt;*
&lt;span class="m"&gt;16&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;*&lt;span class="w"&gt; &lt;/span&gt;*&lt;span class="w"&gt; &lt;/span&gt;*
&lt;span class="m"&gt;17&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;*&lt;span class="w"&gt; &lt;/span&gt;*&lt;span class="w"&gt; &lt;/span&gt;*
&lt;span class="m"&gt;18&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;*&lt;span class="w"&gt; &lt;/span&gt;*&lt;span class="w"&gt; &lt;/span&gt;*
&lt;span class="m"&gt;19&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;*&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;74&lt;/span&gt;.125.24.138&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="m"&gt;74&lt;/span&gt;.125.24.138&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="m"&gt;4&lt;/span&gt;.572&lt;span class="w"&gt; &lt;/span&gt;ms&lt;span class="w"&gt; &lt;/span&gt;*
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Wall of numbers and text! Whoa, scary! It’s all right, I’ll throw that output into Google Sheets and prettify it a&amp;nbsp;bit:&lt;/p&gt;
&lt;p&gt;&lt;img alt="prettified traceroute output for google.com" src="https://ngjunsiang.github.io/laymansguide/issue037_01.png" /&gt;&lt;br /&gt;
&lt;em&gt;The traceroute output for google.com,&amp;nbsp;prettified&lt;/em&gt;    &lt;/p&gt;
&lt;p&gt;&lt;code&gt;traceroute&lt;/code&gt; sends 3 &lt;span class="caps"&gt;TCP&lt;/span&gt; packets, tracing the path they take to the destination &lt;span class="caps"&gt;IP&lt;/span&gt; address. Each time the data packet gets forwarded to another gateway, it is considered a&amp;nbsp;‘hop’.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;traceroute&lt;/code&gt; also helps us do a &lt;strong&gt;reverse &lt;span class="caps"&gt;DNS&lt;/span&gt; lookup&lt;/strong&gt;; a &lt;span class="caps"&gt;DNS&lt;/span&gt; query is when you want to find out the &lt;span class="caps"&gt;IP&lt;/span&gt; address associated with a hostname, a &lt;strong&gt;reverse &lt;span class="caps"&gt;DNS&lt;/span&gt; lookup&lt;/strong&gt; helps you find out which hostname is associated with an &lt;span class="caps"&gt;IP&lt;/span&gt; address. &lt;span class="caps"&gt;IP&lt;/span&gt; addresses with successful reverse &lt;span class="caps"&gt;DNS&lt;/span&gt; lookups have the hostname shown for easier reading; those that didn’t will have only the &lt;span class="caps"&gt;IP&lt;/span&gt; address shown. Some servers are configured to&amp;nbsp;block &lt;code&gt;traceroute&lt;/code&gt; packets (done by the &lt;a href="https://ngjunsiang.github.io/laymansguide/issue034.html"&gt;firewall&lt;/a&gt;)), and thus return no information; these are represented by asterisks&amp;nbsp;(&lt;code&gt;*&lt;/code&gt;) in the&amp;nbsp;output.&lt;/p&gt;
&lt;p&gt;As the data packets are sent from my router&amp;nbsp;(&lt;code&gt;_gateway&lt;/code&gt; in the output) to the first &lt;span class="caps"&gt;ISP&lt;/span&gt; gateway&amp;nbsp;(&lt;code&gt;27.104.128.1&lt;/code&gt;), they don’t always take the same path to the destination. Some of the internet servers along the path are programmed with algorithms that will send the data packets to a group of servers. This group of servers are configured to work together to share the packet-routing load. Two data packets sent through the same internet server may end up getting routed to different places along the&amp;nbsp;route.&lt;/p&gt;
&lt;p&gt;Notice that each hop has a latency associated with it. This is the time taken for the server to decode the packet, figure out what is the next destination, and send it forward. This will often not happen immediately. The data packet joins a queue of other data packets waiting to be dispatched; when the server is under a heavy load, with many data packets waiting to be dispatched (perhaps a whole deluge of Google searches are happening?), the waiting time can rise to hundreds of milliseconds or even a few seconds! (Simply unbearable&amp;nbsp;…)&lt;/p&gt;
&lt;p&gt;Let’s look&amp;nbsp;the &lt;code&gt;traceroute&lt;/code&gt; output for&amp;nbsp;baidu.com:&lt;/p&gt;
&lt;p&gt;&lt;img alt="prettified traceroute output for baidu.com" src="https://ngjunsiang.github.io/laymansguide/issue037_02.png" /&gt;&lt;br /&gt;
&lt;em&gt;The traceroute output for baidu.com,&amp;nbsp;prettified&lt;/em&gt;    &lt;/p&gt;
&lt;p&gt;Notice&amp;nbsp;that:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;More of the servers along the way&amp;nbsp;are &lt;code&gt;traceroute&lt;/code&gt;-friendly&lt;/li&gt;
&lt;li&gt;The data packets take fewer hops to reach baidu.com&amp;nbsp;…&lt;/li&gt;
&lt;li&gt;But they take longer, because some of the servers along the way have really high latency (almost 300 milliseconds; that’s slower than human reaction&amp;nbsp;time)&lt;/li&gt;
&lt;li&gt;My &lt;span class="caps"&gt;ISP&lt;/span&gt; is M1, but sometimes the packets can go through other &lt;span class="caps"&gt;ISP&lt;/span&gt; servers as well.&lt;sup id="fnref:1"&gt;&lt;a class="footnote-ref" href="#fn:1"&gt;1&lt;/a&gt;&lt;/sup&gt; Hop 7 goes through Starhub’s internet&amp;nbsp;servers.&lt;/li&gt;
&lt;/ol&gt;
&lt;hr /&gt;
&lt;p&gt;And that, in two images, is why Baidu’s latency is so much higher: the latency for some of their servers is much&amp;nbsp;higher.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Issue summary:&lt;/strong&gt; The process of forwarding data packets from server to server takes time. Each hop a data packet takes adds to the latency. The more hops a packet must undergo, the longer the latency. The slower the servers along the route, the longer the latency as&amp;nbsp;well.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;I didn’t have much writing space (or readers’ mind space, I wager) to show what the entire route of a data packet looks like when I was describing how the Internet (and packet routing) works. I hope this big-picture post puts everything into clearer perspective now&amp;nbsp;:)&lt;/p&gt;
&lt;p&gt;We’ve looked at how data packets weave their way through the Internet, and next issue I want to shed some light on when/how data packets are&amp;nbsp;sent.&lt;/p&gt;
&lt;h2&gt;What I’ll be covering&amp;nbsp;next&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Next issue:&lt;/strong&gt; Loading a web&amp;nbsp;page&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Sometime in the future:&lt;/strong&gt; What&amp;nbsp;is:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;booting up? [Issue&amp;nbsp;15]&lt;/li&gt;
&lt;li&gt;a cookie? [Issue&amp;nbsp;8]&lt;/li&gt;
&lt;li&gt;a cache? [Issue&amp;nbsp;8]&lt;/li&gt;
&lt;li&gt;&lt;span class="caps"&gt;XSS&lt;/span&gt;? [Issue&amp;nbsp;8]&lt;/li&gt;
&lt;li&gt;a &lt;span class="caps"&gt;CDN&lt;/span&gt;? [Issue&amp;nbsp;8]&lt;/li&gt;
&lt;li&gt;Unicode? And what does it have to do with emoji? [Issue&amp;nbsp;8]&lt;/li&gt;
&lt;li&gt;those &amp;#8216;\r\n’s in the &lt;span class="caps"&gt;HTTP&lt;/span&gt; request packet [Issue&amp;nbsp;12,17]?&lt;/li&gt;
&lt;li&gt;a good reason developers write code and give it away for free online? [Issue&amp;nbsp;21]&lt;/li&gt;
&lt;li&gt;&lt;span class="caps"&gt;ASCII&lt;/span&gt;? [Issue&amp;nbsp;23]&lt;/li&gt;
&lt;li&gt;compiling code into an application [Issue&amp;nbsp;26]?&lt;/li&gt;
&lt;li&gt;firmware? [Issue&amp;nbsp;34]&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="footnote"&gt;
&lt;hr /&gt;
&lt;ol&gt;
&lt;li id="fn:1"&gt;
&lt;p&gt;Remember that internet servers are supposed to cooperate with each other and forward data packets properly according to Internet Protocol (&lt;a href="https://ngjunsiang.github.io/laymansguide/issue027.html"&gt;Issue 27&lt;/a&gt;)). That is how the Internet can continue running smoothly. If servers stop obeying this protocol, the Internet will no longer be a connected space, but will become segregated depending on which servers are willing to forward data packets to each other.&lt;br/&gt;
For instance, if China blocks some web services (Facebook, Twitter, et al), then packets from those services cannot be routed through China’s servers.&amp;#160;&lt;a class="footnote-backref" href="#fnref:1" title="Jump back to footnote 1 in the text"&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;</content><category term="Season 03"></category></entry><entry><title>Issue 36: Latency</title><link href="https://ngjunsiang.github.io/laymansguide/issue036.html" rel="alternate"></link><published>2019-08-31T08:00:00+08:00</published><updated>2019-08-31T08:00:00+08:00</updated><author><name>J S Ng</name></author><id>tag:ngjunsiang.github.io,2019-08-31:/laymansguide/issue036.html</id><summary type="html">&lt;p&gt;Latency is the time duration between a ping packet being sent out and its response being received. It is an indication of how far away a target server&amp;nbsp;is.&lt;/p&gt;</summary><content type="html">&lt;p&gt;Previously: VPNs link devices that are not within the same network using an encrypted tunnel that prevents gateways from snooping on the data packet as it passes&amp;nbsp;en-route.&lt;/p&gt;
&lt;p&gt;In the past two issues, I looked at the basics of web filtering: how data packets are detected (by snoopers or gateways), and how they are protected (by&amp;nbsp;encryption).&lt;/p&gt;
&lt;p&gt;In the next few issues, I’ll look at speed: what causes internet speed to be slow or fast. This issue, we look at&amp;nbsp;latency.&lt;/p&gt;
&lt;h2&gt;Latency&lt;/h2&gt;
&lt;p&gt;In business, the idea of “turnover time” refers to the amount of time taken to complete a process or fulfill a request. With so many businesses relying on the Internet these days, latency is a big part of this turnover time. Simply put, latency is the time duration between a device sending out a request and the same device receiving a&amp;nbsp;response.&lt;/p&gt;
&lt;p&gt;You can see how a long latency will result in long waiting time in an app; if the app has to complete many requests to obtain all the data it needs, it can take a long while before the app is able to even start processing the data, let alone displaying&amp;nbsp;it.&lt;/p&gt;
&lt;h2&gt;Internet latency: an&amp;nbsp;illustration&lt;/h2&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;ping&amp;nbsp;(n.)&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;1835, imitative of the sound of a bullet striking something sharply. Meaning “short, high-pitched electronic pulse” is attested from 1943. As a verb from 1855; in computer sense is from at least 1981. Related: &lt;em&gt;Pinged;&amp;nbsp;pinging.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;In &lt;span class="caps"&gt;WWII&lt;/span&gt;, a ping is a sound pulse emitted by submarines to detect other submarines and undersea objects. The sound pulse bounces off hard surfaces, such as the ocean floor, or other submarines, and returns to the submarine as an echo, giving it an audio report of what is around it. The longer the time gap between the ping and its echo, the further away the object is. It is called a ping because, well, it &lt;em&gt;sounds like a ping&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;An internet ping does not sound like a ping, but it serves a different function through a similar idea. By sending out a data packet to a target server, and measuring the time it takes to get a response, it can “gauge the distance” that the device is away from the target&amp;nbsp;server.&lt;/p&gt;
&lt;p&gt;On any laptop, you can measure the latency of any server using a commandline application (&lt;a href="https://ngjunsiang.github.io/laymansguide/issue015.html"&gt;Issue 15&lt;/a&gt;))&amp;nbsp;called &lt;code&gt;ping&lt;/code&gt;. Here, I will show you the output&amp;nbsp;from &lt;code&gt;ping&lt;/code&gt; while it pings two different&amp;nbsp;servers.&lt;/p&gt;
&lt;p&gt;The commandline prompt in Linux usually starts with&amp;nbsp;a &lt;code&gt;$&lt;/code&gt;, so any text you see after a&amp;nbsp;beginning &lt;code&gt;$&lt;/code&gt; in the same line is the command I am using. Everything that follows is the output from&amp;nbsp;the &lt;code&gt;ping&lt;/code&gt; application.&amp;nbsp;the &lt;code&gt;-c 20&lt;/code&gt; option&amp;nbsp;tells &lt;code&gt;ping&lt;/code&gt; to measure the latency statistics from sending 20 packets of data to the specified&amp;nbsp;server.&lt;/p&gt;
&lt;p&gt;Compare&amp;nbsp;this:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;$&lt;span class="w"&gt; &lt;/span&gt;ping&lt;span class="w"&gt; &lt;/span&gt;-c&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;20&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;google.com
PING&lt;span class="w"&gt; &lt;/span&gt;google.com&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="m"&gt;74&lt;/span&gt;.125.24.100&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;56&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="m"&gt;84&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;bytes&lt;span class="w"&gt; &lt;/span&gt;of&lt;span class="w"&gt; &lt;/span&gt;data.
&lt;span class="m"&gt;64&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;bytes&lt;span class="w"&gt; &lt;/span&gt;from&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;74&lt;/span&gt;.125.24.100&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="m"&gt;74&lt;/span&gt;.125.24.100&lt;span class="o"&gt;)&lt;/span&gt;:&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;icmp_seq&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;ttl&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;46&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;time&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;19&lt;/span&gt;.5&lt;span class="w"&gt; &lt;/span&gt;ms
&lt;span class="m"&gt;64&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;bytes&lt;span class="w"&gt; &lt;/span&gt;from&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;74&lt;/span&gt;.125.24.100&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="m"&gt;74&lt;/span&gt;.125.24.100&lt;span class="o"&gt;)&lt;/span&gt;:&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;icmp_seq&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;ttl&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;46&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;time&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;37&lt;/span&gt;.9&lt;span class="w"&gt; &lt;/span&gt;ms
&lt;span class="m"&gt;64&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;bytes&lt;span class="w"&gt; &lt;/span&gt;from&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;74&lt;/span&gt;.125.24.100&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="m"&gt;74&lt;/span&gt;.125.24.100&lt;span class="o"&gt;)&lt;/span&gt;:&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;icmp_seq&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;3&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;ttl&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;46&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;time&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;40&lt;/span&gt;.0&lt;span class="w"&gt; &lt;/span&gt;ms
&lt;span class="o"&gt;[&lt;/span&gt;…&lt;span class="w"&gt; &lt;/span&gt;TRUNCATED&lt;span class="w"&gt; &lt;/span&gt;…&lt;span class="o"&gt;]&lt;/span&gt;
---&lt;span class="w"&gt; &lt;/span&gt;google.com&lt;span class="w"&gt; &lt;/span&gt;ping&lt;span class="w"&gt; &lt;/span&gt;statistics&lt;span class="w"&gt; &lt;/span&gt;---
&lt;span class="m"&gt;20&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;packets&lt;span class="w"&gt; &lt;/span&gt;transmitted,&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;20&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;received,&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;%&lt;span class="w"&gt; &lt;/span&gt;packet&lt;span class="w"&gt; &lt;/span&gt;loss,&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;time&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;48ms
rtt&lt;span class="w"&gt; &lt;/span&gt;min/avg/max/mdev&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;19&lt;/span&gt;.484/33.354/50.181/7.413&lt;span class="w"&gt; &lt;/span&gt;ms
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;with&amp;nbsp;this:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;$&lt;span class="w"&gt; &lt;/span&gt;ping&lt;span class="w"&gt; &lt;/span&gt;-c&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;20&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;baidu.com
PING&lt;span class="w"&gt; &lt;/span&gt;baidu.com&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="m"&gt;39&lt;/span&gt;.156.69.79&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;56&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="m"&gt;84&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;bytes&lt;span class="w"&gt; &lt;/span&gt;of&lt;span class="w"&gt; &lt;/span&gt;data.
&lt;span class="m"&gt;64&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;bytes&lt;span class="w"&gt; &lt;/span&gt;from&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;39&lt;/span&gt;.156.69.79&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="m"&gt;39&lt;/span&gt;.156.69.79&lt;span class="o"&gt;)&lt;/span&gt;:&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;icmp_seq&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;ttl&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;41&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;time&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;329&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;ms
&lt;span class="m"&gt;64&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;bytes&lt;span class="w"&gt; &lt;/span&gt;from&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;39&lt;/span&gt;.156.69.79&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="m"&gt;39&lt;/span&gt;.156.69.79&lt;span class="o"&gt;)&lt;/span&gt;:&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;icmp_seq&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;ttl&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;41&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;time&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;355&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;ms
&lt;span class="m"&gt;64&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;bytes&lt;span class="w"&gt; &lt;/span&gt;from&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;39&lt;/span&gt;.156.69.79&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="m"&gt;39&lt;/span&gt;.156.69.79&lt;span class="o"&gt;)&lt;/span&gt;:&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;icmp_seq&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;3&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;ttl&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;41&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;time&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;276&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;ms
&lt;span class="o"&gt;[&lt;/span&gt;…&lt;span class="w"&gt; &lt;/span&gt;TRUNCATED&lt;span class="w"&gt; &lt;/span&gt;…&lt;span class="o"&gt;]&lt;/span&gt;

---&lt;span class="w"&gt; &lt;/span&gt;baidu.com&lt;span class="w"&gt; &lt;/span&gt;ping&lt;span class="w"&gt; &lt;/span&gt;statistics&lt;span class="w"&gt; &lt;/span&gt;---
&lt;span class="m"&gt;20&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;packets&lt;span class="w"&gt; &lt;/span&gt;transmitted,&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;20&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;received,&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;%&lt;span class="w"&gt; &lt;/span&gt;packet&lt;span class="w"&gt; &lt;/span&gt;loss,&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;time&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;24ms
rtt&lt;span class="w"&gt; &lt;/span&gt;min/avg/max/mdev&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;275&lt;/span&gt;.903/340.161/391.440/30.893&lt;span class="w"&gt; &lt;/span&gt;ms
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;What we are interested in is the last line. Notice that the average time between a ping packet to google.com and its response packet is 50 milliseconds, while that for baidu.com is 391 milliseconds. That is almost an 8×&amp;nbsp;difference!&lt;/p&gt;
&lt;p&gt;What accounts for this difference? Stay tuned for the next issue of Layman’s Guide to Computing!&amp;nbsp;;)&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Issue summary:&lt;/strong&gt; Latency is the time duration between a ping packet being sent out and its response being received. It is an indication of how far away a target server&amp;nbsp;is.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;I promised one idea a week, and I am sticking to that promise. Remember how the Internet works: packets being forwarded from gateway to gateway. You can probably guess what might account for the latency difference from this, but I am still saving the juicy details for next&amp;nbsp;issue.&lt;/p&gt;
&lt;h2&gt;What I’ll be covering&amp;nbsp;next&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Next issue:&lt;/strong&gt; Traceroute – Google Maps for data&amp;nbsp;packets&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Sometime in the future:&lt;/strong&gt; What&amp;nbsp;is:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;booting up? [Issue&amp;nbsp;15]&lt;/li&gt;
&lt;li&gt;a cookie? [Issue&amp;nbsp;8]&lt;/li&gt;
&lt;li&gt;a cache? [Issue&amp;nbsp;8]&lt;/li&gt;
&lt;li&gt;&lt;span class="caps"&gt;XSS&lt;/span&gt;? [Issue&amp;nbsp;8]&lt;/li&gt;
&lt;li&gt;a &lt;span class="caps"&gt;CDN&lt;/span&gt;? [Issue&amp;nbsp;8]&lt;/li&gt;
&lt;li&gt;Unicode? And what does it have to do with emoji? [Issue&amp;nbsp;8]&lt;/li&gt;
&lt;li&gt;those &amp;#8216;\r\n’s in the &lt;span class="caps"&gt;HTTP&lt;/span&gt; request packet [Issue&amp;nbsp;12,17]?&lt;/li&gt;
&lt;li&gt;a good reason developers write code and give it away for free online? [Issue&amp;nbsp;21]&lt;/li&gt;
&lt;li&gt;&lt;span class="caps"&gt;ASCII&lt;/span&gt;? [Issue&amp;nbsp;23]&lt;/li&gt;
&lt;li&gt;compiling code into an application [Issue&amp;nbsp;26]?&lt;/li&gt;
&lt;li&gt;firmware? [Issue&amp;nbsp;34]&lt;/li&gt;
&lt;/ul&gt;</content><category term="Season 03"></category></entry><entry><title>Issue 35: Virtual Private Networks (VPNs)</title><link href="https://ngjunsiang.github.io/laymansguide/issue035.html" rel="alternate"></link><published>2019-08-24T08:00:00+08:00</published><updated>2019-08-24T08:00:00+08:00</updated><author><name>J S Ng</name></author><id>tag:ngjunsiang.github.io,2019-08-24:/laymansguide/issue035.html</id><summary type="html">&lt;p&gt;VPNs link devices that are not within the same network, such that they can behave as though they are. By encrypting the packet data before it is sent between devices, the &lt;span class="caps"&gt;VPN&lt;/span&gt; software hides these packets from being snooped (i.e. spied upon), effectively forming an encrypted tunnel for information to travel between devices. This enables devices to circumvent firewalls and protect the privacy of information in the data&amp;nbsp;packets.&lt;/p&gt;</summary><content type="html">&lt;p&gt;Previously: Firewalls block data packets that match certain rules. They decrypt the data packet layer by layer, dropping those that match its programmed rules without allowing them to be forwarded to the next point in its journey. The type of filtering that can be applied depends on the processing power available to the router, since some information is hidden more deeply in the data packet than others. Such filtering is typically circumvented by the use of VPNs, or other means of encrypting the data that is&amp;nbsp;required.&lt;/p&gt;
&lt;p&gt;Thus far, our picture of networks divides them into public networks (consisting of devices with public &lt;span class="caps"&gt;IP&lt;/span&gt; addresses) and private networks (devices with private &lt;span class="caps"&gt;IP&lt;/span&gt; addresses). Data traffic between devices in the same private network goes through their common gateway without getting forwarded to the rest of the internet. This data traffic cannot be snooped by outsiders who are not in that network. Theoretically, data within this private network is secure; you can do network printing or share files with other computers within your private home network and know that nobody outside of that network will inadvertently receive a leaked data&amp;nbsp;packet.&lt;/p&gt;
&lt;p&gt;What if you’re out but desperately need to access a file on your home shared network? Or you’re out of the office but need to send a print job to the office printer? (I leave it to you to imagine more plausible scenarios; I’m just trying to explain when you might want a &lt;span class="caps"&gt;VPN&lt;/span&gt;&amp;nbsp;:P)&lt;/p&gt;
&lt;p&gt;You would want some way for your computer to be able to access that private home/office network, but you can’t do it through a public gateway: that would compromise data security, since packets travelling through the Internet from the private network to your computer can be intercepted by other devices along the&amp;nbsp;way.&lt;/p&gt;
&lt;p&gt;You need a&amp;nbsp;…&lt;/p&gt;
&lt;h2&gt;Virtual Private Network (&lt;span class="caps"&gt;VPN&lt;/span&gt;)&lt;/h2&gt;
&lt;p&gt;A Virtual Private Network (&lt;span class="caps"&gt;VPN&lt;/span&gt;) is a way for devices that are not in the same private network to &lt;strong&gt;behave as though they are&lt;/strong&gt;. This network consists of a &lt;span class="caps"&gt;VPN&lt;/span&gt; server, and one or more &lt;span class="caps"&gt;VPN&lt;/span&gt; clients. The &lt;span class="caps"&gt;VPN&lt;/span&gt; server acts as a &lt;span class="caps"&gt;DHCP&lt;/span&gt; server for the clients, assigning them a private &lt;span class="caps"&gt;IP&lt;/span&gt; address for the &lt;span class="caps"&gt;VPN&lt;/span&gt;. This allows devices within the &lt;span class="caps"&gt;VPN&lt;/span&gt; to communicate with each other, regardless of&amp;nbsp;location.&lt;/p&gt;
&lt;p&gt;How is data prevented from leaking outside of the &lt;span class="caps"&gt;VPN&lt;/span&gt; then? By encryption (which we won’t go into the technical details of in this issue). Data travelling between &lt;span class="caps"&gt;VPN&lt;/span&gt; clients is encrypted before being sent out, and decrypted when it arrives. Anyone snooping on the packet contents as it travels gateway to gateway will just see encrypted jumble. That means firewalls won’t be able to identify the information it needs to block data packets, and the data packets thus usually get through&amp;nbsp;unmolested.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Issue summary:&lt;/strong&gt; VPNs link devices that are not within the same network, such that they can behave as though they are. By encrypting the packet data before it is sent between devices, the &lt;span class="caps"&gt;VPN&lt;/span&gt; software hides these packets from being snooped (i.e. spied upon), effectively forming an encrypted tunnel for information to travel between devices. This enables devices to circumvent firewalls and protect the privacy of information in the data&amp;nbsp;packets.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;Last issue was firewalls, this issue is VPNs. You’ll notice that the more advanced the technology, the shorter my posts. That’s because I have already laid out most of the framework for understanding the Internet infrastructure in the issues leading up to these&amp;nbsp;two.&lt;/p&gt;
&lt;p&gt;That’s part of the beauty of the Internet: understanding its basic pieces gives you a pretty good picture that helps you understand most of what’s happening in Internet-related news today. But that’s also the difficulty: finding all the information put together in a coherent, easy-to-read way that actually lays out the picture helpfully. I hope this newsletter has largely succeeded in doing that. If it has not, please let me know where it fell short, and how I might improve it&amp;nbsp;:)&lt;/p&gt;
&lt;h2&gt;What I’ll be covering&amp;nbsp;next&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Next issue:&lt;/strong&gt;&amp;nbsp;Latency&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Sometime in the future:&lt;/strong&gt; What&amp;nbsp;is:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;booting up? [Issue&amp;nbsp;15]&lt;/li&gt;
&lt;li&gt;a cookie? [Issue&amp;nbsp;8]&lt;/li&gt;
&lt;li&gt;a cache? [Issue&amp;nbsp;8]&lt;/li&gt;
&lt;li&gt;&lt;span class="caps"&gt;XSS&lt;/span&gt;? [Issue&amp;nbsp;8]&lt;/li&gt;
&lt;li&gt;a &lt;span class="caps"&gt;CDN&lt;/span&gt;? [Issue&amp;nbsp;8]&lt;/li&gt;
&lt;li&gt;Unicode? And what does it have to do with emoji? [Issue&amp;nbsp;8]&lt;/li&gt;
&lt;li&gt;those &amp;#8216;\r\n’s in the &lt;span class="caps"&gt;HTTP&lt;/span&gt; request packet [Issue&amp;nbsp;12,17]?&lt;/li&gt;
&lt;li&gt;a good reason developers write code and give it away for free online? [Issue&amp;nbsp;21]&lt;/li&gt;
&lt;li&gt;&lt;span class="caps"&gt;ASCII&lt;/span&gt;? [Issue&amp;nbsp;23]&lt;/li&gt;
&lt;li&gt;compiling code into an application [Issue&amp;nbsp;26]?&lt;/li&gt;
&lt;li&gt;firmware? [Issue&amp;nbsp;34]&lt;/li&gt;
&lt;/ul&gt;</content><category term="Season 03"></category></entry><entry><title>Issue 34: Firewalls</title><link href="https://ngjunsiang.github.io/laymansguide/issue034.html" rel="alternate"></link><published>2019-08-17T08:00:00+08:00</published><updated>2019-08-17T08:00:00+08:00</updated><author><name>J S Ng</name></author><id>tag:ngjunsiang.github.io,2019-08-17:/laymansguide/issue034.html</id><summary type="html">&lt;p&gt;Firewalls block data packets that match certain rules. They decrypt the data packet layer by layer, dropping those that match its programmed rules without allowing them to be forwarded to the next point in its journey. The type of filtering that can be applied depends on the processing power available to the router, since some information is hidden more deeply in the data packet than others. Such filtering is typically circumvented by the use of VPNs, or other means of encrypting the data that is&amp;nbsp;required.&lt;/p&gt;</summary><content type="html">&lt;p&gt;Previously: Data is encapsulated when it goes out from an app onto the internet as a request or response. First, in the &lt;span class="caps"&gt;TCP&lt;/span&gt; layer, the &lt;span class="caps"&gt;OS&lt;/span&gt; tags the request with the pre-assigned port number so that it can forward the response to the correct app later. Next, in the &lt;span class="caps"&gt;IP&lt;/span&gt; layer, the network card adds source and destination &lt;span class="caps"&gt;IP&lt;/span&gt; address information so that the data packet arrives at the correct destination server, and the destination server can send the response back to the correct computer. As the packet goes through the router, the router replaces the (source) private &lt;span class="caps"&gt;IP&lt;/span&gt; address assigned to the device by the router with the public &lt;span class="caps"&gt;IP&lt;/span&gt; address assigned to the router by the &lt;span class="caps"&gt;ISP&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;If the above summary of Issues 30–33 makes sense to you, you are probably ready to proceed :) If not, you might want to review those issues quickly through the links&amp;nbsp;below:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://ngjunsiang.github.io/laymansguide/issue030.html"&gt;Issue 30&lt;/a&gt;): Private &lt;span class="caps"&gt;IP&lt;/span&gt; addresses&lt;br /&gt;
&lt;a href="https://ngjunsiang.github.io/laymansguide/issue032.html"&gt;Issue 32&lt;/a&gt;): Sharing a public &lt;span class="caps"&gt;IP&lt;/span&gt; address: Network Address Traversal&lt;br /&gt;
&lt;a href="https://ngjunsiang.github.io/laymansguide/issue033.html"&gt;Issue 33&lt;/a&gt;): Port numbers&lt;br /&gt;
&lt;a href="https://buttondown.email/laymansguide/archive"&gt;Read the rest of the archives&amp;nbsp;here.&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Okay, now we understand how the open, unfettered internet of the 1990s worked. But we are still nowhere near understand the modern Internet until we understand how security is applied. Let’s look at one of the earliest features&amp;nbsp;first.&lt;/p&gt;
&lt;h2&gt;Firewall: a wall to prevent the spread of&amp;nbsp;fire&lt;/h2&gt;
&lt;p&gt;A software firewall performs an equivalent function: to prevent the transmission of an identified packet through&amp;nbsp;it.&lt;/p&gt;
&lt;p&gt;Of course, that means it must be able to be configured with rules that enable it to check the data packets to see if they should be allowed through. What kind of rules can be written for a firewall? That would depend entirely on what information is available in the data&amp;nbsp;packet.&lt;/p&gt;
&lt;h2&gt;&lt;span class="caps"&gt;IP&lt;/span&gt; and port number&amp;nbsp;filtering&lt;/h2&gt;
&lt;p&gt;Thus far, we know that the outermost layer of the data packet is the &lt;span class="caps"&gt;IP&lt;/span&gt; layer, which contains &lt;span class="caps"&gt;IP&lt;/span&gt; address information. A firewall can simply block out data packets coming from a certain source &lt;span class="caps"&gt;IP&lt;/span&gt; address, or being sent to a certain destination &lt;span class="caps"&gt;IP&lt;/span&gt; address. This lets a router administrator block certain devices on the network, by blocking data packets with source &lt;span class="caps"&gt;IP&lt;/span&gt; address matching the private &lt;span class="caps"&gt;IP&lt;/span&gt; address of the device. It also allows an &lt;span class="caps"&gt;ISP&lt;/span&gt; to filter out certain servers from receiving data packets from its customers, by blocking data packets with destination &lt;span class="caps"&gt;IP&lt;/span&gt; address matching the public &lt;span class="caps"&gt;IP&lt;/span&gt; address of the&amp;nbsp;server.&lt;/p&gt;
&lt;p&gt;Do this with a sufficiently comprehensive list of &lt;span class="caps"&gt;IP&lt;/span&gt; addresses, and you can completely block out an entire region’s or even country’s servers. And it would take a &lt;span class="caps"&gt;VPN&lt;/span&gt; to circumvent this, if the &lt;span class="caps"&gt;VPN&lt;/span&gt; server’s &lt;span class="caps"&gt;IP&lt;/span&gt; address is not in the firewall’s block&amp;nbsp;list.&lt;/p&gt;
&lt;p&gt;At the next level, the &lt;span class="caps"&gt;TCP&lt;/span&gt; layer contains port information. A firewall can block out all web browser traffic by restricting data packets with port number 80, or prevent the use of &lt;span class="caps"&gt;HTTPS&lt;/span&gt; by block port 443. It could also theoretically restrict WhatsApp messages, or Apple Messages, just about anything with a well-known or registered port number. This involves more processing power, since the router would have to process the &lt;span class="caps"&gt;IP&lt;/span&gt; layer first to get to the &lt;span class="caps"&gt;TCP&lt;/span&gt;&amp;nbsp;layer.&lt;/p&gt;
&lt;h2&gt;Hostname&amp;nbsp;filtering&lt;/h2&gt;
&lt;p&gt;At higher levels of filtering (involving yet more processing power), the router might even block certain hostnames. Remember that the public &lt;span class="caps"&gt;IP&lt;/span&gt; address of the server is needed before a request can be sent, and this &lt;span class="caps"&gt;IP&lt;/span&gt; address is obtained through a &lt;span class="caps"&gt;DNS&lt;/span&gt; query (&lt;a href="https://ngjunsiang.github.io/laymansguide/issue029.html"&gt;Issue 29&lt;/a&gt;)). If a firewall intercepts and processes the &lt;span class="caps"&gt;DNS&lt;/span&gt; query and blocks the &lt;span class="caps"&gt;DNS&lt;/span&gt; query to resolve that hostname, the device never obtains the public &lt;span class="caps"&gt;IP&lt;/span&gt; address of the server and won’t be able to send the&amp;nbsp;request.&lt;/p&gt;
&lt;h2&gt;Advanced&amp;nbsp;filtering&lt;/h2&gt;
&lt;p&gt;Advanced routers might also come with built-in patterns that detect different types of traffic, e.g. streaming video, videoconferencing, bittorrent, and more. Anything with a predictable pattern can be blocked by a firewall that the data packet passes through, some requiring more processing power than&amp;nbsp;others.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Issue summary:&lt;/strong&gt; Firewalls block data packets that match certain rules. They decrypt the data packet layer by layer, dropping those that match its programmed rules without allowing them to be forwarded to the next point in its journey. The type of filtering that can be applied depends on the processing power available to the router, since some information is hidden more deeply in the data packet than others. Such filtering is typically circumvented by the use of VPNs, or other means of encrypting the data that is&amp;nbsp;required.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;Short issue, entirely by design. Firewall blocking and circumvention methods are an arms race between two sides, one side building better software and hardware that detects packets more quickly and accurately (requiring massive computational power), and the other side seeking ways to hide such metadata or enable it to get to its destination via other paths, often with the use of encryption (also requiring computational power). The details of how each method works can fill tomes. So I’ve decided to just introduce the basic idea, which is really quite simple: detect and&amp;nbsp;block.&lt;/p&gt;
&lt;p&gt;Today, most basic routers have ways to block data packets using hardware (&lt;span class="caps"&gt;MAC&lt;/span&gt;) address, &lt;span class="caps"&gt;IP&lt;/span&gt; address and port number information. Hostname blocking may be enabled on more advanced (i.e. expensive) routers, or on custom router &lt;em&gt;firmware&lt;/em&gt; (I’ll unpack this many issues in the future). You can use this to block ads from certain providers, to restrict access to certain sites (whether to protect your kids or to improve your productivity, I won’t guess), or even to only allow known devices to use your network (in case your neighbour is really good at hacking wifi&amp;nbsp;networks).&lt;/p&gt;
&lt;p&gt;I mentioned VPNs a lot, and didn’t elaborate on that. That’s because I’ll be covering that in the next issue&amp;nbsp;:)&lt;/p&gt;
&lt;h2&gt;What I’ll be covering&amp;nbsp;next&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Next issue:&lt;/strong&gt; VPNs: Virtual Private&amp;nbsp;Networks&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Sometime in the future:&lt;/strong&gt; What&amp;nbsp;is:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;booting up? [Issue&amp;nbsp;15]&lt;/li&gt;
&lt;li&gt;a cookie? [Issue&amp;nbsp;8]&lt;/li&gt;
&lt;li&gt;a cache? [Issue&amp;nbsp;8]&lt;/li&gt;
&lt;li&gt;&lt;span class="caps"&gt;XSS&lt;/span&gt;? [Issue&amp;nbsp;8]&lt;/li&gt;
&lt;li&gt;a &lt;span class="caps"&gt;CDN&lt;/span&gt;? [Issue&amp;nbsp;8]&lt;/li&gt;
&lt;li&gt;Unicode? And what does it have to do with emoji? [Issue&amp;nbsp;8]&lt;/li&gt;
&lt;li&gt;those &amp;#8216;\r\n’s in the &lt;span class="caps"&gt;HTTP&lt;/span&gt; request packet [Issue&amp;nbsp;12,17]?&lt;/li&gt;
&lt;li&gt;a good reason developers write code and give it away for free online? [Issue&amp;nbsp;21]&lt;/li&gt;
&lt;li&gt;&lt;span class="caps"&gt;ASCII&lt;/span&gt;? [Issue&amp;nbsp;23]&lt;/li&gt;
&lt;li&gt;compiling code into an application [Issue&amp;nbsp;26]?&lt;/li&gt;
&lt;li&gt;firmware? [Issue&amp;nbsp;34]&lt;/li&gt;
&lt;/ul&gt;</content><category term="Season 03"></category></entry><entry><title>Issue 33: Port numbers</title><link href="https://ngjunsiang.github.io/laymansguide/issue033.html" rel="alternate"></link><published>2019-08-10T08:00:00+08:00</published><updated>2019-08-10T08:00:00+08:00</updated><author><name>J S Ng</name></author><id>tag:ngjunsiang.github.io,2019-08-10:/laymansguide/issue033.html</id><summary type="html">&lt;p&gt;When an app makes a network request through the &lt;span class="caps"&gt;OS&lt;/span&gt;, the &lt;span class="caps"&gt;OS&lt;/span&gt; adds the source and destination port number to the query in accordance with &lt;span class="caps"&gt;TCP&lt;/span&gt;. When the &lt;span class="caps"&gt;OS&lt;/span&gt; receives the response, it forwards the data to the app which is mapped to the destination port number. Port numbers 1-1023 are registered to standard Internet services, port numbers 1024 to 49151 may be registered to other services, and port numbers 49152 to 65535 may be used by&amp;nbsp;anyone.&lt;/p&gt;</summary><content type="html">&lt;p&gt;Previously: The devices on your home network share the single &lt;span class="caps"&gt;ISP&lt;/span&gt;-assigned &lt;span class="caps"&gt;IP&lt;/span&gt; address through your router. The router rewrites the source &lt;span class="caps"&gt;IP&lt;/span&gt; and port number on outgoing data packets, and rewrites the destination &lt;span class="caps"&gt;IP&lt;/span&gt; and port number on incoming data packets, acting as a middleman for your devices so that they can access the&amp;nbsp;Internet.&lt;/p&gt;
&lt;p&gt;In Issue 32, when I was explaining Network Address Traversal (&lt;span class="caps"&gt;NAT&lt;/span&gt;), I mentioned&amp;nbsp;this:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Another of those things is that &lt;span class="caps"&gt;TCP&lt;/span&gt; will give the request a port number. Yes, you might have heard this term when configuring routers. We won’t need to discuss port numbers yet, so let’s put that&amp;nbsp;aside.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;And then I went on the explain how the source and destination &lt;span class="caps"&gt;IP&lt;/span&gt; addresses are tagged on through the Internet Protocol (&lt;span class="caps"&gt;IP&lt;/span&gt;).&lt;/p&gt;
&lt;p&gt;Well, now is the time to talk about what’s going on through the Transmission Control Protocol (&lt;span class="caps"&gt;TCP&lt;/span&gt;). Within a single device, you often have different software services&amp;nbsp;running:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;span class="caps"&gt;DNS&lt;/span&gt; querying (&lt;a href="https://ngjunsiang.github.io/laymansguide/issue029.html"&gt;Issue 29&lt;/a&gt;))&lt;/li&gt;
&lt;li&gt;Internet time synchronisation (over the Network Time&amp;nbsp;Protocol)&lt;/li&gt;
&lt;li&gt;Software updaters checking for updates&amp;nbsp;online&lt;/li&gt;
&lt;li&gt;Skype/Zoom/videoconferencing&lt;/li&gt;
&lt;li&gt;Instant&amp;nbsp;messaging&lt;/li&gt;
&lt;li&gt;Web&amp;nbsp;browsers&lt;/li&gt;
&lt;li&gt;Others&amp;nbsp;&amp;#8230;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;When a data packet comes in through the network chip and arrives at the operating system (&lt;span class="caps"&gt;OS&lt;/span&gt;), how does it know which software app to forward the data packet&amp;nbsp;to?&lt;/p&gt;
&lt;h2&gt;Port&amp;nbsp;numbers&lt;/h2&gt;
&lt;p&gt;When a software app needs to send a request or some data through the Internet, it has to go through the &lt;span class="caps"&gt;OS&lt;/span&gt;. The &lt;span class="caps"&gt;OS&lt;/span&gt; decides which software gets to use the Internet, and which ones don’t (that is what your firewall is for). If a software app has permission to access the internet, it requests a &lt;strong&gt;port number&lt;/strong&gt; from the &lt;span class="caps"&gt;OS&lt;/span&gt;. The &lt;span class="caps"&gt;OS&lt;/span&gt; assigns the app a port number, and stores information about which application is mapped to which port&amp;nbsp;number.&lt;/p&gt;
&lt;p&gt;When the software app sends data to the &lt;span class="caps"&gt;OS&lt;/span&gt; to be sent out via the network, the &lt;span class="caps"&gt;OS&lt;/span&gt; adds identifying information, including the source and destination port number, as part of &lt;span class="caps"&gt;TCP&lt;/span&gt;. Then the &lt;span class="caps"&gt;OS&lt;/span&gt; sends the resulting data packet to the network card to be forwarded to the gateway (via your &lt;span class="caps"&gt;LAN&lt;/span&gt; cable or wifi connection). The network card then adds the source and destination &lt;span class="caps"&gt;IP&lt;/span&gt; address information (and other identifying information) as part of &lt;span class="caps"&gt;IP&lt;/span&gt;, creating a larger data packet (which at this point is app data inside a &lt;span class="caps"&gt;TCP&lt;/span&gt; shell inside an &lt;span class="caps"&gt;IP&lt;/span&gt; shell &amp;#8230; like a Matryoshka&amp;nbsp;doll).&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;Request #4676 to host
Source IP:        &lt;span class="gs"&gt;*27.104.229.65*&lt;/span&gt;
Source Port:      &lt;span class="gs"&gt;*45784*&lt;/span&gt;
Destination IP:   172.217.26.78
Destination Port: 80
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;When response data is returned, the &lt;span class="caps"&gt;OS&lt;/span&gt; checks the destination port number, looks up its list of assigned ports, and forwards the data to the correct app. Cycle&amp;nbsp;complete!&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="nv"&gt;Request&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="sc"&gt;#4676&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;host&lt;/span&gt;
&lt;span class="nv"&gt;Source&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;IP&lt;/span&gt;:&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="mi"&gt;172&lt;/span&gt;.&lt;span class="mi"&gt;217&lt;/span&gt;.&lt;span class="mi"&gt;26&lt;/span&gt;.&lt;span class="mi"&gt;78&lt;/span&gt;
&lt;span class="nv"&gt;Source&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;Port&lt;/span&gt;:&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mi"&gt;54674&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="k"&gt;random&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;port&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;host&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;
&lt;span class="nv"&gt;Destination&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;IP&lt;/span&gt;:&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="mi"&gt;27&lt;/span&gt;.&lt;span class="mi"&gt;104&lt;/span&gt;.&lt;span class="mi"&gt;229&lt;/span&gt;.&lt;span class="mi"&gt;65&lt;/span&gt;
&lt;span class="nv"&gt;Destination&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;Port&lt;/span&gt;:&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;45784&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Just like there is a source and destination &lt;span class="caps"&gt;IP&lt;/span&gt; address, there is also a source and destination port number. The source port number is the assigned port number from the &lt;span class="caps"&gt;OS&lt;/span&gt;. The destination port number, well &amp;#8230; how are we to know&amp;nbsp;that?&lt;/p&gt;
&lt;h2&gt;Reserved port&amp;nbsp;numbers&lt;/h2&gt;
&lt;p&gt;With so many types of data being transferred over the Internet, how do things not get mixed&amp;nbsp;up?&lt;/p&gt;
&lt;p&gt;Reserved port numbers is how. The well-known internet traffic data types have standardised protocols: web traffic follows HyperText Transfer Protocol (&lt;span class="caps"&gt;HTTP&lt;/span&gt; - &lt;a href="https://ngjunsiang.github.io/laymansguide/issue007.html"&gt;Issue 7&lt;/a&gt;)), some types of file transfer occur in accordance with the File Transfer Protocol (&lt;span class="caps"&gt;FTP&lt;/span&gt;), &lt;span class="caps"&gt;DNS&lt;/span&gt; queries obey the &lt;span class="caps"&gt;DNS&lt;/span&gt; protocol,&amp;nbsp;etc.&lt;/p&gt;
&lt;p&gt;These well-known protocols are assigned standard port numbers by &lt;span class="caps"&gt;IANA&lt;/span&gt;, the same authority that manages known &lt;span class="caps"&gt;IP&lt;/span&gt; addresses. &lt;span class="caps"&gt;HTTP&lt;/span&gt; uses port 80. &lt;span class="caps"&gt;FTP&lt;/span&gt; uses port 20 (data transfer) and 21 (control). &lt;span class="caps"&gt;DNS&lt;/span&gt; uses port 53. You can find the &lt;a href="https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers"&gt;full list of well-known port numbers on Wikipedia&lt;/a&gt;. Port numbers 1 to 1023 are reserved for this purpose and may not be used publicly for other&amp;nbsp;purposes.&lt;/p&gt;
&lt;p&gt;If your app is trying to query a hostname to get the associated &lt;span class="caps"&gt;IP&lt;/span&gt; address, the destination port number is 53. The app simply uses the standard port number depending on what service it is trying to use, and which protocol it is following. If your app is trying to request data from a web server, the destination port number is 80; your web browser actually requests https://google.com:80 but it will leave out the port number if it is a standard port number. You can also try requesting https://google.com:8000 but you won&amp;#8217;t get any data in return since nothing is listening on that port number at Google&amp;#8217;s&amp;nbsp;end.&lt;/p&gt;
&lt;p&gt;Web servers will (by default) listen on port 80, &lt;span class="caps"&gt;FTP&lt;/span&gt; servers on port 21, &lt;span class="caps"&gt;DNS&lt;/span&gt; servers on port 53, and so on. Any traffic arriving with those port numbers will be directed to these (software) servers for&amp;nbsp;processing.&lt;/p&gt;
&lt;h2&gt;Registered port&amp;nbsp;numbers&lt;/h2&gt;
&lt;p&gt;Port numbers 1024 to 49151 are available for organisations, corporations, and other corporate bodies to request if they are setting up widespread area services. Whatsapp uses ports 4244, 5222, 5223, 5228, 5242. Apple uses port 5223 for push notifications. Google Play uses port 5228 for messaging. This makes it possible for these services to work without knowing what the port numbers of the software apps on the receiving end are mapped&amp;nbsp;to.&lt;/p&gt;
&lt;h2&gt;Private port&amp;nbsp;numbers&lt;/h2&gt;
&lt;p&gt;Port numbers 49152 to 65535 are available for anyone to use. Tinkerers, hackers, anyone who just needs a number to send data&amp;nbsp;from.&lt;/p&gt;
&lt;p&gt;&amp;#8230; and that’s a wrap. Source and destination &lt;span class="caps"&gt;IP&lt;/span&gt; addresses get data to the right computers, source and destination port numbers get data to the right apps in those&amp;nbsp;computers.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Issue summary:&lt;/strong&gt; When an app makes a network request through the &lt;span class="caps"&gt;OS&lt;/span&gt;, the &lt;span class="caps"&gt;OS&lt;/span&gt; adds the source and destination port number to the query in accordance with &lt;span class="caps"&gt;TCP&lt;/span&gt;. When the &lt;span class="caps"&gt;OS&lt;/span&gt; receives the response, it forwards the data to the app which is mapped to the destination port number. Port numbers 1-1023 are registered to standard Internet services, port numbers 1024 to 49151 may be registered to other services, and port numbers 49152 to 65535 may be used by&amp;nbsp;anyone.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;Short and sweet! Issues 30-33 are my summary of how data packets find their way across the internet (via &lt;span class="caps"&gt;IP&lt;/span&gt; addresses) and to the right apps (via port numbers). It’s amazing that this is basically how almost all Internet traffic gets routed; the rules are simple and hence very scalable, you don’t need massive computation to get packets to the right places (but you do need massive hardware to process lots of packets&amp;nbsp;quickly).&lt;/p&gt;
&lt;p&gt;In the next few issues, I’ll go into some security and performance considerations for internet traffic: firewalls and traffic blocking, VPNs, and internet&amp;nbsp;speeds.&lt;/p&gt;
&lt;h2&gt;What I’ll be covering&amp;nbsp;next&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Next issue:&lt;/strong&gt; Firewalls and traffic&amp;nbsp;blocking&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Sometime in the future:&lt;/strong&gt; What&amp;nbsp;is:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;booting up? [Issue&amp;nbsp;15]&lt;/li&gt;
&lt;li&gt;a cookie? [Issue&amp;nbsp;8]&lt;/li&gt;
&lt;li&gt;a cache? [Issue&amp;nbsp;8]&lt;/li&gt;
&lt;li&gt;&lt;span class="caps"&gt;XSS&lt;/span&gt;? [Issue&amp;nbsp;8]&lt;/li&gt;
&lt;li&gt;a &lt;span class="caps"&gt;CDN&lt;/span&gt;? [Issue&amp;nbsp;8]&lt;/li&gt;
&lt;li&gt;Unicode? And what does it have to do with emoji? [Issue&amp;nbsp;8]&lt;/li&gt;
&lt;li&gt;those &amp;#8216;\r\n&amp;#8217;s in the &lt;span class="caps"&gt;HTTP&lt;/span&gt; request packet [Issue&amp;nbsp;12,17]?&lt;/li&gt;
&lt;li&gt;a good reason developers write code and give it away for free online? [Issue&amp;nbsp;21]&lt;/li&gt;
&lt;li&gt;&lt;span class="caps"&gt;ASCII&lt;/span&gt;? [Issue&amp;nbsp;23]&lt;/li&gt;
&lt;li&gt;compiling code into an application [Issue&amp;nbsp;26]?&lt;/li&gt;
&lt;/ul&gt;</content><category term="Season 03"></category></entry><entry><title>Issue 32: Sharing a public IP address: Network Address Traversal</title><link href="https://ngjunsiang.github.io/laymansguide/issue032.html" rel="alternate"></link><published>2019-08-03T08:00:00+08:00</published><updated>2019-08-03T08:00:00+08:00</updated><author><name>J S Ng</name></author><id>tag:ngjunsiang.github.io,2019-08-03:/laymansguide/issue032.html</id><summary type="html">&lt;p&gt;When a request from a device on the network is to be forwarded to the gateway, it has to traverse different networks. The router helps it by rewriting the source &lt;span class="caps"&gt;IP&lt;/span&gt; and port number, keeping track of the originating &lt;span class="caps"&gt;IP&lt;/span&gt; and port. When a response is received, it rewrites the destination &lt;span class="caps"&gt;IP&lt;/span&gt; and port so that the response will reach the originating&amp;nbsp;device.&lt;/p&gt;</summary><content type="html">&lt;p&gt;Previously: A router assigns &lt;span class="caps"&gt;IP&lt;/span&gt; addresses automatically using &lt;span class="caps"&gt;DHCP&lt;/span&gt;. It reserves any registered static &lt;span class="caps"&gt;IP&lt;/span&gt; addresses for devices identified by their &lt;span class="caps"&gt;MAC&lt;/span&gt; address, and assigns the remaining private &lt;span class="caps"&gt;IP&lt;/span&gt; addresses in the pool to any devices that request one. Each &lt;span class="caps"&gt;IP&lt;/span&gt; address has a lease period, after which the device must request an &lt;span class="caps"&gt;IP&lt;/span&gt; address&amp;nbsp;again.&lt;/p&gt;
&lt;p&gt;In Issue 30, I tried to answer the question &amp;#8220;how do all my devices manage to share the one precious &lt;span class="caps"&gt;IP&lt;/span&gt; address assigned to me by my &lt;span class="caps"&gt;ISP&lt;/span&gt;?&amp;#8221;, and in the process introduced two more acronyms: &lt;span class="caps"&gt;DHCP&lt;/span&gt; and &lt;span class="caps"&gt;NAT&lt;/span&gt;. I covered &lt;span class="caps"&gt;DHCP&lt;/span&gt; last issue, and today I’ll explain &lt;span class="caps"&gt;NAT&lt;/span&gt;. It is one of those technologies that work silently in the background, doing its own thing merrily until something bad&amp;nbsp;happens.&lt;/p&gt;
&lt;h2&gt;Requests and&amp;nbsp;Responses&lt;/h2&gt;
&lt;p&gt;Remember that when your phone/laptop/device first connects to the router, it doesn’t have a private &lt;span class="caps"&gt;IP&lt;/span&gt; Address yet, and it uses its &lt;span class="caps"&gt;MAC&lt;/span&gt; Address (a hardware &lt;span class="caps"&gt;ID&lt;/span&gt; key) to ask the router for one. Once it gets a private &lt;span class="caps"&gt;IP&lt;/span&gt; address, it can finally start to send and receive&amp;nbsp;requests.&lt;/p&gt;
&lt;p&gt;In Issue 8, I gave an example of the &lt;em&gt;content&lt;/em&gt; of a&amp;nbsp;response:&lt;/p&gt;
&lt;p&gt;&lt;img alt="An HTTP response header from Hypothes.is" src="https://ngjunsiang.github.io/laymansguide/issue008_01.png" /&gt;&lt;br /&gt;
&lt;em&gt;The response header from&amp;nbsp;Hypothes.is&lt;/em&gt;    &lt;/p&gt;
&lt;p&gt;This is like the header of a letter that Hypothes.is writes to my web browser (with a company letterhead and all that), saying that it received my request (&lt;span class="caps"&gt;HTTP&lt;/span&gt; 200 &lt;span class="caps"&gt;OK&lt;/span&gt;), and the content of my request (not shown) follows after this&amp;nbsp;header.&lt;/p&gt;
&lt;p&gt;In Issue 30, I described an analogy for how packets are requested and&amp;nbsp;received:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;When someone sends a physical packet to you, they’ll write a home address &lt;em&gt;and&lt;/em&gt; a name (To: ). The mailman doesn’t care that much about the name; they just send the packet to the home address. Once it reaches your home, someone in the house (the early riser, or the stay-home one) looks at the name and figures out where the packet should go. If the packet is addressed to “Peter”, it’s natural to assume that it’s meant for Peter-in-this-house and not&amp;nbsp;Peter-5-blocks-down-the-street.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;When I click a link or load an image, my web browser sends another request for the information. This request may include some data (e.g. if I&amp;#8217;m sending my credit card details), or it may just consist of a header (e.g. if I’m going to a new &lt;span class="caps"&gt;URL&lt;/span&gt;). But how do I send it&amp;nbsp;out?&lt;/p&gt;
&lt;p&gt;When we write letters, we never drop them into the mailbox directly; without To or From address information, the mailman would have absolutely no idea what to do with our&amp;nbsp;letter!&lt;/p&gt;
&lt;p&gt;This is where &lt;strong&gt;Transmission Control Protocol&lt;/strong&gt; (&lt;span class="caps"&gt;TCP&lt;/span&gt;) and &lt;strong&gt;Internet Protocol&lt;/strong&gt; (&lt;span class="caps"&gt;IP&lt;/span&gt;) comes&amp;nbsp;in.&lt;/p&gt;
&lt;h2&gt;Transmission Control Protocol: not going into it for&amp;nbsp;now&lt;/h2&gt;
&lt;p&gt;It is not the time to delve into what &lt;span class="caps"&gt;TCP&lt;/span&gt; does and how it works, but it is part of the sequence of events that lead to requests being sent. For now, just know that when my web browser sends the request, it has to go through my network card which will encode the request into an electromagnetic signal to be sent over the airwaves as a wifi signal. As it does so, a number of things&amp;nbsp;happen.&lt;/p&gt;
&lt;p&gt;One of those things is that &lt;span class="caps"&gt;TCP&lt;/span&gt; will stamp the request with some identifying information, so that when a response is received, it can be matched to the&amp;nbsp;request.&lt;/p&gt;
&lt;p&gt;Another of those things is that &lt;span class="caps"&gt;TCP&lt;/span&gt; will give the request a port number. Yes, you might have heard this term when configuring routers. We won’t need to discuss port numbers yet, so let’s put that&amp;nbsp;aside.&lt;/p&gt;
&lt;h2&gt;Internet Protocol: To and&amp;nbsp;From&lt;/h2&gt;
&lt;p&gt;As I type this section, it dawned on me that there is one acronym I didn’t introduce properly. All this while I’ve been using “&lt;span class="caps"&gt;IP&lt;/span&gt; address” repeatedly and never even mentioned what “&lt;span class="caps"&gt;IP&lt;/span&gt;” stood&amp;nbsp;for!&lt;/p&gt;
&lt;p&gt;Well, now we know: it stands for Internet Protocol (&lt;span class="caps"&gt;IP&lt;/span&gt;). &lt;span class="caps"&gt;IP&lt;/span&gt; is the next protocol layer in the sequence (that ensures our request gets through, and a response gets back). It is a big part of the backbone that forms the internet. At this point, our request has some identifying info and a port number, but no To or From information&amp;nbsp;yet.&lt;/p&gt;
&lt;p&gt;Where does the To: information come from? From the &lt;span class="caps"&gt;URL&lt;/span&gt; I am trying to access (or more specifically, the domain name of the &lt;span class="caps"&gt;URL&lt;/span&gt;). My web browser first sends a &lt;span class="caps"&gt;DNS&lt;/span&gt; query (&lt;a href="https://ngjunsiang.github.io/laymansguide/issue028.html"&gt;Issue 28&lt;/a&gt;)) to resolve the domain name to an &lt;span class="caps"&gt;IP&lt;/span&gt; address, and now we have the &lt;span class="caps"&gt;IP&lt;/span&gt; address to put in the To: field. In Internet Protocol, this is the &lt;strong&gt;Destination address&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;What about the From:&amp;nbsp;information?&lt;/p&gt;
&lt;p&gt;At this point, my network card only knows a few &lt;span class="caps"&gt;IP&lt;/span&gt;&amp;nbsp;addresses:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Gateway:&lt;/strong&gt; this is the &lt;span class="caps"&gt;IP&lt;/span&gt; address of the router, where all requests are&amp;nbsp;sent&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;span class="caps"&gt;DNS&lt;/span&gt; server:&lt;/strong&gt; this is the &lt;span class="caps"&gt;IP&lt;/span&gt; address where all &lt;span class="caps"&gt;DNS&lt;/span&gt; queries are&amp;nbsp;sent&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Private &lt;span class="caps"&gt;IP&lt;/span&gt; address:&lt;/strong&gt; This is the private &lt;span class="caps"&gt;IP&lt;/span&gt; address the router gave to my device when it first connected to the&amp;nbsp;wifi&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The only &lt;span class="caps"&gt;IP&lt;/span&gt; address there that is viable is the private &lt;span class="caps"&gt;IP&lt;/span&gt; address. So that is the &lt;span class="caps"&gt;IP&lt;/span&gt; address to put in the From: field. In Internet Protocol. this is the &lt;strong&gt;Source address&lt;/strong&gt;.&lt;/p&gt;
&lt;h2&gt;Sending and&amp;nbsp;receiving&lt;/h2&gt;
&lt;p&gt;Now our letter is packaged in a &lt;span class="caps"&gt;TCP&lt;/span&gt;/&lt;span class="caps"&gt;IP&lt;/span&gt; envelope, with a port number, source address, and destination address. It is ready to go out from the network card! It is&amp;nbsp;broadcast!&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;Request #4676
Source IP:        192.168.1.10
Source Port:      8976
Destination IP:   172.217.26.78
Destination Port: 80
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;My smart &lt;span class="caps"&gt;TV&lt;/span&gt;, Playstation, iPad, and other wifi-connected devices around the house are blind as to what it contains. They all receive this request, decode the address information, realise it is not for them (the Destination address is not their private &lt;span class="caps"&gt;IP&lt;/span&gt;), and promptly discard the&amp;nbsp;request.&lt;/p&gt;
&lt;p&gt;Only the router receives this request (because it is The Gateway Through Which All Things Pass), and has to figure out what to do with it. It sees that the Destination address is not in its forwarding tables, and knows it must send this packet to another gateway (i.e. your &lt;span class="caps"&gt;ISP&lt;/span&gt;). But that can’t happen yet: the Source address is a private &lt;span class="caps"&gt;IP&lt;/span&gt; address! Those can never go out to the &lt;span class="caps"&gt;ISP&lt;/span&gt; gateway, because the &lt;span class="caps"&gt;ISP&lt;/span&gt; gateway would get confused. It would think “private &lt;span class="caps"&gt;IP&lt;/span&gt; addresses are reserved for internal use and can only come from devices within my own network, so this packet must have come from another &lt;span class="caps"&gt;ISP&lt;/span&gt; computer and not my&amp;nbsp;customers”.&lt;/p&gt;
&lt;p&gt;So your router does a clever thing: it &lt;em&gt;rewrites&lt;/em&gt; your&amp;nbsp;request.&lt;/p&gt;
&lt;h2&gt;Network Address&amp;nbsp;Traversal&lt;/h2&gt;
&lt;p&gt;The router replaces the Source address with its public &lt;span class="caps"&gt;IP&lt;/span&gt; address, the one issued by the &lt;span class="caps"&gt;ISP&lt;/span&gt;. At the same time, it also replaces the port number (e.g. 80 for web traffic) with another random one (e.g. 45784, some large number between 1024 and&amp;nbsp;65535).&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;Request #4676
Source IP:        &lt;span class="gs"&gt;*27.104.229.65*&lt;/span&gt;
Source Port:      &lt;span class="gs"&gt;*45784*&lt;/span&gt;
Destination IP:   172.217.26.78
Destination Port: 80
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;The server&amp;nbsp;responds:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="nv"&gt;Request&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="sc"&gt;#4676&lt;/span&gt;
&lt;span class="nv"&gt;Source&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;IP&lt;/span&gt;:&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="mi"&gt;172&lt;/span&gt;.&lt;span class="mi"&gt;217&lt;/span&gt;.&lt;span class="mi"&gt;26&lt;/span&gt;.&lt;span class="mi"&gt;78&lt;/span&gt;
&lt;span class="nv"&gt;Source&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;Port&lt;/span&gt;:&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mi"&gt;54674&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="k"&gt;random&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;
&lt;span class="nv"&gt;Destination&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;IP&lt;/span&gt;:&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="mi"&gt;27&lt;/span&gt;.&lt;span class="mi"&gt;104&lt;/span&gt;.&lt;span class="mi"&gt;229&lt;/span&gt;.&lt;span class="mi"&gt;65&lt;/span&gt;
&lt;span class="nv"&gt;Destination&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;Port&lt;/span&gt;:&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;45784&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;The router sees the destination port, 45784, and realises that the outgoing packet with the same port number originated from me. So it rewrites this response to send it back to&amp;nbsp;me:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;Request #4676
Source IP:        172.217.26.78
Source Port:      54674
Destination IP:   &lt;span class="gs"&gt;*192.168.1.10*&lt;/span&gt;
Destination Port: &lt;span class="gs"&gt;*8976*&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;And &lt;em&gt;that’s&lt;/em&gt; how it’s&amp;nbsp;done.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Issue summary:&lt;/strong&gt; When a request from a device on the network is to be forwarded to the gateway, it has to traverse different networks. The router helps it by rewriting the source &lt;span class="caps"&gt;IP&lt;/span&gt; and port number, keeping track of the originating &lt;span class="caps"&gt;IP&lt;/span&gt; and port. When a response is received, it rewrites the destination &lt;span class="caps"&gt;IP&lt;/span&gt; and port so that the response will reach the originating&amp;nbsp;device.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;This issue is much, much lengthier than expected; I totally underestimated the prior-knowledge-bridging content that’s required. You notice that the &lt;span class="caps"&gt;NAT&lt;/span&gt; portion of this mailer is pretty short, but there’s a lengthy backstory to pull together disparate pieces of information from past&amp;nbsp;issues.&lt;/p&gt;
&lt;p&gt;You intuitively know that you need a router to access the internet, but might not know why. I hope this post illustrates sufficiently one of the key functions of a router :) the magic of &lt;span class="caps"&gt;NAT&lt;/span&gt; is what allows multiple devices to share one public &lt;span class="caps"&gt;IP&lt;/span&gt; address. Keep in mind that when you’re on public wifi, you may be sharing this digital infrastructure with hundreds if not thousands of other users! The hardware needed is immense; certainly far more expansive than the impression given by a home&amp;nbsp;router.&lt;/p&gt;
&lt;p&gt;As the picture gets clearer and more detailed it’s also getting more complex. My personal philosophy is “there are no dumb questions, only dumb answers”. I bet there’re tons of things I overlooked. If there’re any lingering questions, please drop me an email and I’ll try not to send a dumb answer&amp;nbsp;:)&lt;/p&gt;
&lt;h2&gt;What I’ll be covering&amp;nbsp;next&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Next issue:&lt;/strong&gt; All about port&amp;nbsp;numbers&lt;/p&gt;
&lt;p&gt;This next issue is fun! As you are receiving packets for your web browser, skype call, network file transfers, &lt;span class="caps"&gt;DNS&lt;/span&gt; queries, etc, how does your computer get the right packets to the right software&amp;nbsp;services?&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Sometime in the future:&lt;/strong&gt; What&amp;nbsp;is:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;booting up? [Issue&amp;nbsp;15]&lt;/li&gt;
&lt;li&gt;a cookie? [Issue&amp;nbsp;8]&lt;/li&gt;
&lt;li&gt;a cache? [Issue&amp;nbsp;8]&lt;/li&gt;
&lt;li&gt;&lt;span class="caps"&gt;XSS&lt;/span&gt;? [Issue&amp;nbsp;8]&lt;/li&gt;
&lt;li&gt;a &lt;span class="caps"&gt;CDN&lt;/span&gt;? [Issue&amp;nbsp;8]&lt;/li&gt;
&lt;li&gt;Unicode? And what does it have to do with emoji? [Issue&amp;nbsp;8]&lt;/li&gt;
&lt;li&gt;those &amp;#8216;\r\n&amp;#8217;s in the &lt;span class="caps"&gt;HTTP&lt;/span&gt; request packet [Issue&amp;nbsp;12,17]?&lt;/li&gt;
&lt;li&gt;a good reason developers write code and give it away for free online? [Issue&amp;nbsp;21]&lt;/li&gt;
&lt;li&gt;&lt;span class="caps"&gt;ASCII&lt;/span&gt;? [Issue&amp;nbsp;23]&lt;/li&gt;
&lt;li&gt;compiling code into an application [Issue&amp;nbsp;26]?&lt;/li&gt;
&lt;/ul&gt;</content><category term="Season 03"></category></entry><entry><title>Issue 31: Getting a private IP address: DHCP (and DDNS)</title><link href="https://ngjunsiang.github.io/laymansguide/issue031.html" rel="alternate"></link><published>2019-07-27T08:00:00+08:00</published><updated>2019-07-27T08:00:00+08:00</updated><author><name>J S Ng</name></author><id>tag:ngjunsiang.github.io,2019-07-27:/laymansguide/issue031.html</id><summary type="html">&lt;p&gt;&lt;span class="caps"&gt;DHCP&lt;/span&gt; is a protocol by which a router assigns &lt;span class="caps"&gt;IP&lt;/span&gt; addresses to devices that connect to it. Static &lt;span class="caps"&gt;IP&lt;/span&gt; addresses are &lt;span class="caps"&gt;IP&lt;/span&gt; addresses that are reserved for a device, so that the device always gets the same &lt;span class="caps"&gt;IP&lt;/span&gt; address when it&amp;nbsp;connects.&lt;/p&gt;</summary><content type="html">&lt;p&gt;Previously: Private &lt;span class="caps"&gt;IP&lt;/span&gt; addresses are special &lt;span class="caps"&gt;IP&lt;/span&gt; addresses that routers will treat as belonging to devices within the private network, and not outside it. Data packets sent to private &lt;span class="caps"&gt;IP&lt;/span&gt; addresses will never make it past the gateway into the internet. This system allows multiple devices within a private network to share a public &lt;span class="caps"&gt;IP&lt;/span&gt;&amp;nbsp;address.&lt;/p&gt;
&lt;p&gt;Last week, I tried to answer the question &amp;#8220;how do all my devices manage to share the one precious &lt;span class="caps"&gt;IP&lt;/span&gt; address assigned to me by my &lt;span class="caps"&gt;ISP&lt;/span&gt;?&amp;#8221;, and in the process introduced two more acronyms: &lt;span class="caps"&gt;DHCP&lt;/span&gt; and &lt;span class="caps"&gt;NAT&lt;/span&gt;. I don’t intend to spam this newsletter with acronyms, but to use them as neat little terms that conveniently capture ideas about how different parts of the complete Internet experience works. So if you never remember what &lt;span class="caps"&gt;DHCP&lt;/span&gt; is, don’t fret over it; you won’t see it often unless you configure routers or servers&amp;nbsp;often.&lt;/p&gt;
&lt;p&gt;In a nutshell, &lt;span class="caps"&gt;DHCP&lt;/span&gt; is how you get a (private) &lt;span class="caps"&gt;IP&lt;/span&gt; address when you connect to your router. Before that, here’s one of those niggly little problems that the early Internet pioneers ran into in trying to write awesome&amp;nbsp;services:&lt;/p&gt;
&lt;h2&gt;&lt;span class="caps"&gt;MAC&lt;/span&gt; address: Media Access Control&amp;nbsp;address&lt;/h2&gt;
&lt;p&gt;When your phone/laptop/device first connects to the router, it needs to know what its private &lt;span class="caps"&gt;IP&lt;/span&gt; address is, so it can begin stamping data packets to be sent. It doesn’t have a private &lt;span class="caps"&gt;IP&lt;/span&gt; address yet, so it has to ask the router for one. But if it sends the &lt;span class="caps"&gt;IP&lt;/span&gt; address request, how would the router know who to reply&amp;nbsp;to?&lt;/p&gt;
&lt;p&gt;The answer is that each device (or more specifically, the networking chip of the device) has a unique hardware code, known as the &lt;strong&gt;&lt;span class="caps"&gt;MAC&lt;/span&gt; address&lt;/strong&gt;. It will stamp the request with its &lt;span class="caps"&gt;MAC&lt;/span&gt; address first, so the router knows who to offer the &lt;span class="caps"&gt;IP&lt;/span&gt; address&amp;nbsp;to.&lt;/p&gt;
&lt;p&gt;The &lt;span class="caps"&gt;MAC&lt;/span&gt; address can also be used to do many other things, like block devices on a network; we’ll get to those other things in future issues&amp;nbsp;;)&lt;/p&gt;
&lt;h2&gt;&lt;span class="caps"&gt;DHCP&lt;/span&gt;: Dynamic Host Configuration&amp;nbsp;Protocol&lt;/h2&gt;
&lt;p&gt;So what happens after that? your device asks for an &lt;span class="caps"&gt;IP&lt;/span&gt; address, and the router reserves one from its pool of private &lt;span class="caps"&gt;IP&lt;/span&gt; addresses and offers it to the device. the device accepts the request, and the router adds the device &lt;span class="caps"&gt;IP&lt;/span&gt; address to its forwarding table.&amp;nbsp;Done.&lt;/p&gt;
&lt;p&gt;It’s called a dynamic process because the router assigns private &lt;span class="caps"&gt;IP&lt;/span&gt; addresses only upon request, so a device may not always end up with the same &lt;span class="caps"&gt;IP&lt;/span&gt;&amp;nbsp;address.&lt;/p&gt;
&lt;h2&gt;Static vs Dynamic &lt;span class="caps"&gt;IP&lt;/span&gt;&amp;nbsp;addresses&lt;/h2&gt;
&lt;p&gt;One potential drawback of this dynamic process is that if you are trying to set up a network printer the Old Way, it will ask you to input the address of the printer. And unless you have figured out internal &lt;span class="caps"&gt;DNS&lt;/span&gt; on your router and properly hostnamed all your printers, you will be providing this address not as a hostname (like printer.home.com) but as an &lt;span class="caps"&gt;IP&lt;/span&gt; address&amp;nbsp;(192.168.1.5).&lt;/p&gt;
&lt;p&gt;&lt;img alt="Add Printer dialog asking for an IP address" src="https://ngjunsiang.github.io/laymansguide/issue031_01.gif" /&gt;&lt;br /&gt;
&lt;em&gt;An old printer management dialog window for adding printers. &lt;a href="https://marinescience.ucdavis.edu/bml/facilities/it/instructions/mac-how-add-network-printer-ip-address"&gt;Source: &lt;span class="caps"&gt;UC&lt;/span&gt; Davis Coastal And Marine Science&amp;nbsp;Institute&lt;/a&gt;&lt;/em&gt;    &lt;/p&gt;
&lt;p&gt;But when you reboot your network printer and it requests an &lt;span class="caps"&gt;IP&lt;/span&gt; address from the router again, will it get a different one? Will you have to re-add the printer&amp;nbsp;again?&lt;/p&gt;
&lt;p&gt;Not if you get the router to assign it as a static &lt;span class="caps"&gt;IP&lt;/span&gt; address. The router can store a list of &lt;span class="caps"&gt;MAC&lt;/span&gt; addresses and their associated static (private) &lt;span class="caps"&gt;IP&lt;/span&gt; addresses, so that the device will always get the same &lt;span class="caps"&gt;IP&lt;/span&gt;&amp;nbsp;address.&lt;/p&gt;
&lt;h2&gt;&lt;span class="caps"&gt;DHCP&lt;/span&gt; and your &lt;span class="caps"&gt;ISP&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;One more thing you need to know about &lt;span class="caps"&gt;DHCP&lt;/span&gt;: when a device requests an &lt;span class="caps"&gt;IP&lt;/span&gt; address, it’s not going to get that &lt;span class="caps"&gt;IP&lt;/span&gt; address forever. &lt;span class="caps"&gt;IP&lt;/span&gt; addresses have a lease (5 days by default), after which the &lt;span class="caps"&gt;IP&lt;/span&gt; address will expire and the device will have to request a new &lt;span class="caps"&gt;IP&lt;/span&gt;&amp;nbsp;address.&lt;/p&gt;
&lt;p&gt;It’s the same thing with your &lt;span class="caps"&gt;ISP&lt;/span&gt;. Your home router, even if it is left on 24/7, will have to renew its (public) &lt;span class="caps"&gt;IP&lt;/span&gt; address with your &lt;span class="caps"&gt;ISP&lt;/span&gt; every few days, as and when it expires. So your &lt;span class="caps"&gt;ISP&lt;/span&gt; also (most likely) assigns you &lt;span class="caps"&gt;IP&lt;/span&gt; addresses by &lt;span class="caps"&gt;DHCP&lt;/span&gt;; you are not going to enjoy the privilege of a static &lt;span class="caps"&gt;IP&lt;/span&gt; address unless you pay gobs more&amp;nbsp;money!&lt;/p&gt;
&lt;h2&gt;Wait: why are static &lt;span class="caps"&gt;IP&lt;/span&gt; addresses such a&amp;nbsp;privilege?&lt;/h2&gt;
&lt;p&gt;Remember what a public &lt;span class="caps"&gt;IP&lt;/span&gt; address is? It’s a way for data packets to get to you wherever they are sent from. And that is possible because of the forwarding tables stored in Internet registries everywhere (including your &lt;span class="caps"&gt;ISP&lt;/span&gt;). All over the world, anyone who knows your &lt;span class="caps"&gt;IP&lt;/span&gt; address can send your router&amp;nbsp;data.&lt;/p&gt;
&lt;p&gt;But often they won’t do so. They will use a &lt;span class="caps"&gt;URL&lt;/span&gt; instead, because they are easier to remember.  The sender finds out what &lt;span class="caps"&gt;IP&lt;/span&gt; address the domain name is assigned to by querying its &lt;span class="caps"&gt;DNS&lt;/span&gt; servers (&lt;a href="https://ngjunsiang.github.io/laymansguide/issue028.html"&gt;Issue 28&lt;/a&gt;)).&lt;/p&gt;
&lt;p&gt;If you want your own domain name, you have to buy one at a domain name provider. This lets you add your unique domain name to the &lt;span class="caps"&gt;WHOIS&lt;/span&gt; database (&lt;a href="https://ngjunsiang.github.io/laymansguide/issue028.html"&gt;Issue 28&lt;/a&gt;)) … but you need an &lt;span class="caps"&gt;IP&lt;/span&gt; address to map to your domain name. And you can’t use your &lt;span class="caps"&gt;ISP&lt;/span&gt;-assigned &lt;span class="caps"&gt;IP&lt;/span&gt; address, because it’s dynamic and changes when the lease expires … can&amp;nbsp;you?&lt;/p&gt;
&lt;h2&gt;Dynamic &lt;span class="caps"&gt;DNS&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;Some domain name providers offer a service known as Dynamic &lt;span class="caps"&gt;DNS&lt;/span&gt; (&lt;strong&gt;&lt;span class="caps"&gt;DDNS&lt;/span&gt;&lt;/strong&gt;). This service lets you run software on your computer or a sufficiently advanced router that will update the provider whenever your public &lt;span class="caps"&gt;IP&lt;/span&gt; address has changed. So if you want to be able to stream videos from your own home server for your own viewing, without going through a cloud service, that is possible! But we won’t go into the details here&amp;nbsp;;)&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Issue summary:&lt;/strong&gt; &lt;span class="caps"&gt;DHCP&lt;/span&gt; is a protocol by which a router assigns &lt;span class="caps"&gt;IP&lt;/span&gt; addresses to devices that connect to it. Static &lt;span class="caps"&gt;IP&lt;/span&gt; addresses are &lt;span class="caps"&gt;IP&lt;/span&gt; addresses that are reserved for a device, so that the device always gets the same &lt;span class="caps"&gt;IP&lt;/span&gt; address when it&amp;nbsp;connects.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;I had almost forgotten about &lt;span class="caps"&gt;DDNS&lt;/span&gt;, and decided to include it at the last minute, making this a bit longer than I had aimed for. But I hope this fleshes out your model of the Internet a little more, so that you understand how it is possible for you to have your own domain name&amp;nbsp;too.&lt;/p&gt;
&lt;p&gt;I usually introduce new terms and acronyms in bold, but I didn’t bold &lt;span class="caps"&gt;DHCP&lt;/span&gt; here. You won’t ever need that acronym again and you will probably forget it if you don’t do router configuration, and that’s just how things should&amp;nbsp;be.&lt;/p&gt;
&lt;h2&gt;What I’ll be covering&amp;nbsp;next&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Next issue:&lt;/strong&gt; How do packets from my device get out onto the internet, and how do they come back to me? Network Address Traversal (&lt;span class="caps"&gt;NAT&lt;/span&gt;)&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Sometime in the future:&lt;/strong&gt; What&amp;nbsp;is:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;booting up? [Issue&amp;nbsp;15]&lt;/li&gt;
&lt;li&gt;a cookie? [Issue&amp;nbsp;8]&lt;/li&gt;
&lt;li&gt;a cache? [Issue&amp;nbsp;8]&lt;/li&gt;
&lt;li&gt;&lt;span class="caps"&gt;XSS&lt;/span&gt;? [Issue&amp;nbsp;8]&lt;/li&gt;
&lt;li&gt;a &lt;span class="caps"&gt;CDN&lt;/span&gt;? [Issue&amp;nbsp;8]&lt;/li&gt;
&lt;li&gt;Unicode? And what does it have to do with emoji? [Issue&amp;nbsp;8]&lt;/li&gt;
&lt;li&gt;those &amp;#8216;\r\n&amp;#8217;s in the &lt;span class="caps"&gt;HTTP&lt;/span&gt; request packet [Issue&amp;nbsp;12,17]?&lt;/li&gt;
&lt;li&gt;a good reason developers write code and give it away for free online? [Issue&amp;nbsp;21]&lt;/li&gt;
&lt;li&gt;&lt;span class="caps"&gt;ASCII&lt;/span&gt;? [Issue&amp;nbsp;23]&lt;/li&gt;
&lt;li&gt;compiling code into an application [Issue&amp;nbsp;26]?&lt;/li&gt;
&lt;/ul&gt;</content><category term="Season 03"></category></entry><entry><title>Issue 30: Private IP Addresses</title><link href="https://ngjunsiang.github.io/laymansguide/issue030.html" rel="alternate"></link><published>2019-07-20T08:00:00+08:00</published><updated>2019-07-20T08:00:00+08:00</updated><author><name>J S Ng</name></author><id>tag:ngjunsiang.github.io,2019-07-20:/laymansguide/issue030.html</id><summary type="html">&lt;p&gt;Private &lt;span class="caps"&gt;IP&lt;/span&gt; addresses are special &lt;span class="caps"&gt;IP&lt;/span&gt; addresses that routers will treat as belonging to devices within the private network, and not outside it. Data packets sent to private &lt;span class="caps"&gt;IP&lt;/span&gt; addresses will never make it past the gateway into the internet. This system allows multiple devices within a private network to share a public &lt;span class="caps"&gt;IP&lt;/span&gt;&amp;nbsp;address.&lt;/p&gt;</summary><content type="html">&lt;p&gt;Previously: Your web browser resolves a hostname (finds out which &lt;span class="caps"&gt;IP&lt;/span&gt; address a hostname points to) by sending a &lt;span class="caps"&gt;DNS&lt;/span&gt; query to its&amp;nbsp;gateway.&lt;/p&gt;
&lt;p&gt;Back in &lt;a href="https://ngjunsiang.github.io/laymansguide/issue027.html"&gt;Issue 27&lt;/a&gt;), I said&amp;nbsp;this:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;If you are good at math, you can work out the total number of available [&lt;span class="caps"&gt;IP&lt;/span&gt; address] combinations: it’s 4,294,967,296 (256^4). It seems like a lot, but we actually have more humans on this planet than we have &lt;span class="caps"&gt;IP&lt;/span&gt; addresses. And if we assign a unique &lt;span class="caps"&gt;IP&lt;/span&gt; address to each device on the Internet, many of us will need multiple &lt;span class="caps"&gt;IP&lt;/span&gt; addresses for our smartphone, laptop, Amazon Echo, smart &lt;span class="caps"&gt;TV&lt;/span&gt;, router,&amp;nbsp;…&lt;/p&gt;
&lt;p&gt;&lt;span class="caps"&gt;IP&lt;/span&gt; addresses are a limited resource! They are really&amp;nbsp;precious!&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;span class="caps"&gt;IP&lt;/span&gt; addresses are so precious that your &lt;span class="caps"&gt;ISP&lt;/span&gt; only has a handful, and they will only give you one per subscriber line. Which of your devices are going to receive&amp;nbsp;it?&lt;/p&gt;
&lt;p&gt;Fortunately, there is a way for all of them to share this one &lt;span class="caps"&gt;IP&lt;/span&gt;&amp;nbsp;address.&lt;/p&gt;
&lt;h2&gt;Private &lt;span class="caps"&gt;IP&lt;/span&gt;&amp;nbsp;addresses&lt;/h2&gt;
&lt;p&gt;When you send a data packet through the internet, the data packet gets &amp;#8220;stamped&amp;#8221; with the destination &lt;span class="caps"&gt;IP&lt;/span&gt; address. The first router it reaches checks its internal forwarding tables (covered in Issue 27) to see if the &lt;span class="caps"&gt;IP&lt;/span&gt; address is there; if it is not, the router forwards it to the router’s gateway, and the process&amp;nbsp;repeats.&lt;/p&gt;
&lt;p&gt;Some &lt;span class="caps"&gt;IP&lt;/span&gt; addresses don’t get treated this way. Data packets sent to the following &lt;span class="caps"&gt;IP&lt;/span&gt; address ranges will &lt;strong&gt;never&lt;/strong&gt; be forwarded past a gateway:
- 10.0.0.0 to 10.255.255.255
- 172.16.0.0 to 172.31.255.255
- 192.168.0.0 to&amp;nbsp;192.168.255.255&lt;/p&gt;
&lt;p&gt;In effect, packets sent to these addresses will never make it out beyond your router, onto the (public) internet. These addresses are known as &lt;strong&gt;private &lt;span class="caps"&gt;IP&lt;/span&gt; addresses&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Not too long ago, you configured your router through a webpage. That means you need to enter an &lt;span class="caps"&gt;IP&lt;/span&gt; address into your browser to access the router settings, and there’s no way for you to know that &lt;span class="caps"&gt;IP&lt;/span&gt; address in advance. Most routers are configured to have a default gateway &lt;span class="caps"&gt;IP&lt;/span&gt; address of 192.168.1.1 or 192.168.0.1 (check your router’s manual for the correct one), so you set that as your gateway address in network settings. the private &lt;span class="caps"&gt;IP&lt;/span&gt; address system prevents commands you send to your router from making their way out to the Internet, and potentially leaking your&amp;nbsp;information.&lt;/p&gt;
&lt;p&gt;Imagine how many devices at home are sending data packets to 192.168.0.1 (or 192.168.1.1), to be forwarded to their destinations through the gateway … private &lt;span class="caps"&gt;IP&lt;/span&gt; addresses allow private networks to be separated from the internet. Every device in the private network has an &lt;span class="caps"&gt;IP&lt;/span&gt; address that only the router has a complete list of. You can&amp;#8217;t send a data packet to a private address (say, 192.168.1.3) on a different private network, since that data packet will never make it past the gateway. The router will simply attempt to send it to 192.68.1.3 within the same private&amp;nbsp;network.&lt;/p&gt;
&lt;p&gt;(A &lt;strong&gt;router&lt;/strong&gt; is a &lt;em&gt;device&lt;/em&gt; that forwards data packets it receives; a &lt;strong&gt;gateway&lt;/strong&gt; is a &lt;em&gt;destination point&lt;/em&gt; that a data packet gets sent to as it makes its way across the internet to its destination. I’ll try not to get too philosophical about the difference between them, but I’ll be using them interchangably depending on whether I’m emphasising the device or the network&amp;nbsp;layout.)&lt;/p&gt;
&lt;h2&gt;Handling the complexity: &lt;span class="caps"&gt;DHCP&lt;/span&gt; and &lt;span class="caps"&gt;NAT&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;It all sounds terribly simple when described this way. And then somebody at the back of the room raises their hand and asks, “so when we want to send a packet to &lt;span class="caps"&gt;IP&lt;/span&gt; address 45.63.153.22, should I send it to 45.63.153.22 (destination) or 192.168.0.1&amp;nbsp;(gateway)?”&lt;/p&gt;
&lt;p&gt;No spoilers, we’ll cover this a couple issues later. The router juggles between the various &lt;span class="caps"&gt;IP&lt;/span&gt; addresses through a process called Network Address Traversal (&lt;span class="caps"&gt;NAT&lt;/span&gt;). &lt;span class="caps"&gt;NAT&lt;/span&gt; goes hand-in-hand with &lt;span class="caps"&gt;IP&lt;/span&gt; addresses to enable this &lt;span class="caps"&gt;IP&lt;/span&gt;-sharing magic. But first it has to have a public &lt;span class="caps"&gt;IP&lt;/span&gt; address&amp;nbsp;…&lt;/p&gt;
&lt;p&gt;How do our devices get an &lt;span class="caps"&gt;IP&lt;/span&gt; address from the router? How does our router get an &lt;span class="caps"&gt;IP&lt;/span&gt; address from the &lt;span class="caps"&gt;ISP&lt;/span&gt;? This usually occurs according to a set of rules known as Dynamic Host Configuration Protocol (&lt;span class="caps"&gt;DHCP&lt;/span&gt;)—yep, it’s another&amp;nbsp;protocol.&lt;/p&gt;
&lt;h2&gt;An analogy: home addresses and&amp;nbsp;names&lt;/h2&gt;
&lt;p&gt;When someone sends a physical packet to you, they’ll write a home address &lt;em&gt;and&lt;/em&gt; a name (To: ). The mailman doesn’t care that much about the name; they just send the packet to the home address. Once it reaches your home, someone in the house (the early riser, or the stay-home one) looks at the name and figures out where the packet should go. If the packet is addressed to “Peter”, it’s natural to assume that it’s meant for Peter-in-this-house and not&amp;nbsp;Peter-5-blocks-down-the-street.&lt;/p&gt;
&lt;p&gt;This system allows multiple people to share one address. That address is like your &lt;span class="caps"&gt;ISP&lt;/span&gt;-given public &lt;span class="caps"&gt;IP&lt;/span&gt; address. The names are like private &lt;span class="caps"&gt;IP&lt;/span&gt; addresses; they are only meaningful within the house, and ambiguous outside of that&amp;nbsp;context.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Issue summary:&lt;/strong&gt; Private &lt;span class="caps"&gt;IP&lt;/span&gt; addresses are special &lt;span class="caps"&gt;IP&lt;/span&gt; addresses that routers will treat as belonging to devices within the private network, and not outside it. Data packets sent to private &lt;span class="caps"&gt;IP&lt;/span&gt; addresses will never make it past the gateway into the internet. This system allows multiple devices within a private network to share a public &lt;span class="caps"&gt;IP&lt;/span&gt;&amp;nbsp;address.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;This was a little longer than I expected, but I’m pretty pleased with it. I hope you found the analogy helpful; it just popped to mind as I was nearing the end of the&amp;nbsp;issue.&lt;/p&gt;
&lt;p&gt;Private &lt;span class="caps"&gt;IP&lt;/span&gt; addresses were something I started learning when I started playing with my home router to try to optimise its performance (this was back in the slow days of 56k &lt;span class="caps"&gt;ADSL&lt;/span&gt;), and it took me weeks to understand all the different knobs and dials in the web interface. If you ever come across them, now you know what’s going on&amp;nbsp;:)&lt;/p&gt;
&lt;h2&gt;What I’ll be covering&amp;nbsp;next&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Next issue:&lt;/strong&gt; How do my devices get an &lt;span class="caps"&gt;IP&lt;/span&gt; address? Dynamic &lt;span class="caps"&gt;IP&lt;/span&gt; addresses and &lt;span class="caps"&gt;DHCP&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Sometime in the future:&lt;/strong&gt; What&amp;nbsp;is:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;booting up? [Issue&amp;nbsp;15]&lt;/li&gt;
&lt;li&gt;a cookie? [Issue&amp;nbsp;8]&lt;/li&gt;
&lt;li&gt;a cache? [Issue&amp;nbsp;8]&lt;/li&gt;
&lt;li&gt;&lt;span class="caps"&gt;XSS&lt;/span&gt;? [Issue&amp;nbsp;8]&lt;/li&gt;
&lt;li&gt;a &lt;span class="caps"&gt;CDN&lt;/span&gt;? [Issue&amp;nbsp;8]&lt;/li&gt;
&lt;li&gt;Unicode? And what does it have to do with emoji? [Issue&amp;nbsp;8]&lt;/li&gt;
&lt;li&gt;those &amp;#8216;\r\n&amp;#8217;s in the &lt;span class="caps"&gt;HTTP&lt;/span&gt; request packet [Issue&amp;nbsp;12,17]?&lt;/li&gt;
&lt;li&gt;a good reason developers write code and give it away for free online? [Issue&amp;nbsp;21]&lt;/li&gt;
&lt;li&gt;&lt;span class="caps"&gt;ASCII&lt;/span&gt;? [Issue&amp;nbsp;23]&lt;/li&gt;
&lt;li&gt;compiling code into an application [Issue&amp;nbsp;26]?&lt;/li&gt;
&lt;/ul&gt;</content><category term="Season 03"></category></entry><entry><title>Issue 29: How to resolve a hostname</title><link href="https://ngjunsiang.github.io/laymansguide/issue029.html" rel="alternate"></link><published>2019-07-13T08:00:00+08:00</published><updated>2019-07-13T08:00:00+08:00</updated><author><name>J S Ng</name></author><id>tag:ngjunsiang.github.io,2019-07-13:/laymansguide/issue029.html</id><summary type="html">&lt;p&gt;Resolving a hostname means answering the question “which &lt;span class="caps"&gt;IP&lt;/span&gt; address does this hostname point to?”. Your web browser seeks this answer by sending a &lt;span class="caps"&gt;DNS&lt;/span&gt; query to the gateway. If the gateway is unable to provide a satisfactory answer, you can configure your network interface to send the &lt;span class="caps"&gt;DNS&lt;/span&gt; query to a different &lt;span class="caps"&gt;DNS&lt;/span&gt;&amp;nbsp;server.&lt;/p&gt;</summary><content type="html">&lt;p&gt;Previously: An &lt;span class="caps"&gt;IP&lt;/span&gt; address is a string of four numbers that looks like 255.255.128.1. &lt;span class="caps"&gt;IP&lt;/span&gt; addresses are a list managed by the &lt;span class="caps"&gt;IANA&lt;/span&gt;, and all Internet registries agree to route data packets through their servers according to that list, so that you can send your data to anyone whose &lt;span class="caps"&gt;IP&lt;/span&gt; address you know. If you don&amp;#8217;t know their &lt;span class="caps"&gt;IP&lt;/span&gt; address, but you know their domain name, you can look up the domain name in a &lt;span class="caps"&gt;WHOIS&lt;/span&gt; database through a Domain Name Server to get their &lt;span class="caps"&gt;IP&lt;/span&gt;&amp;nbsp;address.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Resolving host message in a Chrome browser" src="https://ngjunsiang.github.io/laymansguide/issue029_01.png" /&gt;&lt;br /&gt;
&lt;em&gt;A really old screenshot of Chrome, showing the resolving host message. &lt;a href="https://www.webnots.com/what-is-resolving-host-or-domain-name/"&gt;Source:&amp;nbsp;Webnots&lt;/a&gt;&lt;/em&gt;    &lt;/p&gt;
&lt;p&gt;I think it’s basically impossible to be living in the age of the Internet and not have encountered one of those absolutely annoying times when your web browser just seems to be stuck on “resolving host …” for what seems like &lt;em&gt;forever&lt;/em&gt;. What &lt;em&gt;is&lt;/em&gt; it doing? And what does resolving host&amp;nbsp;mean?!&lt;/p&gt;
&lt;p&gt;Let’s address the second part&amp;nbsp;first:&lt;/p&gt;
&lt;h2&gt;What is a&amp;nbsp;host?&lt;/h2&gt;
&lt;p&gt;In the early days of the internet, before blogging happened, if you wanted your own webpage you had to write the content and code yourself and put it up somewhere that people can access. the one place almost everybody in my generation knew could do this was Yahoo! GeoCities, a &lt;strong&gt;web hosting service&lt;/strong&gt;. They are called hosting services because they act like a host to your content, serving them biscuits and water, making sure they know the wifi password to the place, and the way to the&amp;nbsp;bathroom.&lt;/p&gt;
&lt;p&gt;This is why the part of the domain name after the subdomain, i.e. facebook.com or google.com without the www in front, is also known as the &lt;strong&gt;hostname&lt;/strong&gt;; on the internet, that is literally the name of the host(ing server) that holds your&amp;nbsp;content.&lt;/p&gt;
&lt;h2&gt;What does resolving&amp;nbsp;mean?&lt;/h2&gt;
&lt;p&gt;&lt;a href="https://www.merriam-webster.com/dictionary/resolve"&gt;Merriam-Webster&amp;nbsp;online:&lt;/a&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;resolve&lt;/strong&gt; &lt;em&gt;verb&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;re·​solve |&amp;nbsp;ri-ˈzälv&lt;/p&gt;
&lt;p&gt;4 b : to find an answer&amp;nbsp;to&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;To resolve a hostname is to seek an answer to the question “which &lt;span class="caps"&gt;IP&lt;/span&gt; address does this hostname point&amp;nbsp;to?”&lt;/p&gt;
&lt;p&gt;Your web browser, bless its poor soul, has to ask this question every time you type a &lt;span class="caps"&gt;URL&lt;/span&gt; into the address bar. It does not keep a list of domain names (and the addresses they map to), so someone else has to seek the answer for&amp;nbsp;it.&lt;/p&gt;
&lt;p&gt;This someone, or rather something, is a Domain Name&amp;nbsp;Service.&lt;/p&gt;
&lt;h2&gt;&lt;span class="caps"&gt;DNS&lt;/span&gt;: Domain Name&amp;nbsp;Service&lt;/h2&gt;
&lt;p&gt;&lt;img alt="Network connection properties window" src="https://ngjunsiang.github.io/laymansguide/issue029_02.png" /&gt;&lt;br /&gt;
&lt;em&gt;Network connection properties, a window that one used to see very often when configuring a router. &lt;a href="https://helpdeskgeek.com/networking/change-ip-address-and-dns-servers-using-the-command-prompt/"&gt;Source: Help Desk&amp;nbsp;Geek&lt;/a&gt;&lt;/em&gt;    &lt;/p&gt;
&lt;p&gt;In the days when you had to set up your router through a &lt;span class="caps"&gt;LAN&lt;/span&gt; cable connected to your internet-less laptop, this was a screen you would see regularly. You had to do this because you had to set your gateway address to point to the router’s default &lt;span class="caps"&gt;IP&lt;/span&gt; address in order to access its internal admin&amp;nbsp;page.&lt;/p&gt;
&lt;p&gt;But I talked about gateways back in (&lt;a href="https://ngjunsiang.github.io/laymansguide/issue027.html"&gt;Issue 27&lt;/a&gt;)), so we’re here to talk about &lt;span class="caps"&gt;DNS&lt;/span&gt; servers&amp;nbsp;instead.&lt;/p&gt;
&lt;p&gt;Just like other data request packets, the request to resolve a host (known as a &lt;strong&gt;&lt;span class="caps"&gt;DNS&lt;/span&gt; query&lt;/strong&gt;) first goes to the gateway (usually your router). If it can’t be resolved there, it gets forwarded to the next gateway (your &lt;span class="caps"&gt;ISP&lt;/span&gt;), and it keeps getting forwarded until it reaches a server that is able to answer that query and return the long-desired &lt;span class="caps"&gt;IP&lt;/span&gt; Address (hey, a few seconds is already lifetime for an &lt;span class="caps"&gt;HTTP&lt;/span&gt;&amp;nbsp;session!)&lt;/p&gt;
&lt;p&gt;Usually, this request would be resolved by your &lt;span class="caps"&gt;ISP&lt;/span&gt;’s &lt;span class="caps"&gt;DNS&lt;/span&gt; servers. But sometimes the &lt;span class="caps"&gt;ISP&lt;/span&gt; gets a little swamped, or their &lt;span class="caps"&gt;DNS&lt;/span&gt; server decided to call in sick, or didn’t update its &lt;span class="caps"&gt;WHOIS&lt;/span&gt; databases properly and gave you a wrong answer, or … anyway, if you wanted to bypass that &lt;span class="caps"&gt;DNS&lt;/span&gt; server and try another one, you could input its &lt;span class="caps"&gt;IP&lt;/span&gt; address in the Preferred &lt;span class="caps"&gt;DNS&lt;/span&gt; Server field&amp;nbsp;above.&lt;/p&gt;
&lt;p&gt;Short question for you, dear reader: Why does the Preferred &lt;span class="caps"&gt;DNS&lt;/span&gt; Server field require an &lt;span class="caps"&gt;IP&lt;/span&gt; address and not a&amp;nbsp;hostname?&lt;/p&gt;
&lt;p&gt;Advice on the Internet these days suggests that if you find your browser is taking a little too long to resolve a hostname, you can try configuring your network interface to use &lt;a href="https://developers.google.com/speed/public-dns/"&gt;Google Public &lt;span class="caps"&gt;DNS&lt;/span&gt;&lt;/a&gt; instead. Since this is a newsletter and not a helpdesk, I won’t go into the details here but you can always drop me a message if you need&amp;nbsp;help.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Issue summary:&lt;/strong&gt; Resolving a hostname means answering the question “which &lt;span class="caps"&gt;IP&lt;/span&gt; address does this hostname point to?”. Your web browser seeks this answer by sending a &lt;span class="caps"&gt;DNS&lt;/span&gt; query to the gateway. If the gateway is unable to provide a satisfactory answer, you can configure your network interface to send the &lt;span class="caps"&gt;DNS&lt;/span&gt; query to a different &lt;span class="caps"&gt;DNS&lt;/span&gt;&amp;nbsp;server.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;This a is a nice, sweet, and short issue, though it took almost as long to write as Issue 28. Crazy, I&amp;nbsp;know.&lt;/p&gt;
&lt;p&gt;I have more to say about &lt;span class="caps"&gt;DNS&lt;/span&gt;, but I don’t think it belongs in this issue. I’ll figure out where to slot that info, whenever it becomes more relevant&amp;nbsp;:)&lt;/p&gt;
&lt;p&gt;I hope a picture of how your browser gets its data is gradually forming in your head: registries looking up databases of addresses, requests getting forwarded to higher and higher gateways, and now hostnames resolving into &lt;span class="caps"&gt;IP&lt;/span&gt;&amp;nbsp;addresses.&lt;/p&gt;
&lt;p&gt;Yeah I really should have introduced hostnames last issue, but couldn&amp;#8217;t find a place to put them without making the issue more unwieldy than it needs to be. I think it made perfect sense&amp;nbsp;here.&lt;/p&gt;
&lt;p&gt;Did you answer the question above? It’s meant to make you think a little; that helps a lot for remembering what you read. You have to input the &lt;span class="caps"&gt;DNS&lt;/span&gt; Server as an &lt;span class="caps"&gt;IP&lt;/span&gt; address because if you used a hostname, your laptop would have to resolve that hostname &lt;em&gt;before&lt;/em&gt; knowing where to send the &lt;span class="caps"&gt;DNS&lt;/span&gt; query. For this reason, Google Public &lt;span class="caps"&gt;DNS&lt;/span&gt; makes its &lt;span class="caps"&gt;DNS&lt;/span&gt; Server &lt;span class="caps"&gt;IP&lt;/span&gt; addresses easy to remember: 8.8.8.8 and&amp;nbsp;8.8.4.4.&lt;/p&gt;
&lt;h2&gt;What I’ll be covering&amp;nbsp;next&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Next issue:&lt;/strong&gt; Private &lt;span class="caps"&gt;IP&lt;/span&gt; addresses – how do I use one &lt;span class="caps"&gt;IP&lt;/span&gt; address for all my&amp;nbsp;devices?&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Sometime in the future:&lt;/strong&gt; What&amp;nbsp;is:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;booting up? [Issue&amp;nbsp;15]&lt;/li&gt;
&lt;li&gt;a cookie? [Issue&amp;nbsp;8]&lt;/li&gt;
&lt;li&gt;a cache? [Issue&amp;nbsp;8]&lt;/li&gt;
&lt;li&gt;&lt;span class="caps"&gt;XSS&lt;/span&gt;? [Issue&amp;nbsp;8]&lt;/li&gt;
&lt;li&gt;a &lt;span class="caps"&gt;CDN&lt;/span&gt;? [Issue&amp;nbsp;8]&lt;/li&gt;
&lt;li&gt;Unicode? And what does it have to do with emoji? [Issue&amp;nbsp;8]&lt;/li&gt;
&lt;li&gt;those &amp;#8216;\r\n&amp;#8217;s in the &lt;span class="caps"&gt;HTTP&lt;/span&gt; request packet [Issue&amp;nbsp;12,17]?&lt;/li&gt;
&lt;li&gt;a good reason developers write code and give it away for free online? [Issue&amp;nbsp;21]&lt;/li&gt;
&lt;li&gt;&lt;span class="caps"&gt;ASCII&lt;/span&gt;? [Issue&amp;nbsp;23]&lt;/li&gt;
&lt;li&gt;compiling code into an application [Issue&amp;nbsp;26]?&lt;/li&gt;
&lt;/ul&gt;</content><category term="Season 03"></category></entry><entry><title>Issue 28: Domain Names and DNS</title><link href="https://ngjunsiang.github.io/laymansguide/issue028.html" rel="alternate"></link><published>2019-07-06T08:00:00+08:00</published><updated>2019-07-06T08:00:00+08:00</updated><author><name>J S Ng</name></author><id>tag:ngjunsiang.github.io,2019-07-06:/laymansguide/issue028.html</id><summary type="html">&lt;p&gt;Domain names consist of an optional subdomain, the domain name, and the top-level domain. The top-level domains are managed by a registry, which receives registration requests from domain name registrars, and maintains registrant information for each domain under their &lt;span class="caps"&gt;TLD&lt;/span&gt; in a &lt;span class="caps"&gt;WHOIS&lt;/span&gt; database. The domain name registrars let you configure which &lt;span class="caps"&gt;IP&lt;/span&gt; address to forward data packets to, and propagate that information through their &lt;span class="caps"&gt;DNS&lt;/span&gt; servers so that data packets will be routed&amp;nbsp;accordingly.&lt;/p&gt;</summary><content type="html">&lt;p&gt;Last issue, I introduced &lt;span class="caps"&gt;IP&lt;/span&gt; addresses: a string of four numbers that tells routers where to send the data packet. These &lt;span class="caps"&gt;IP&lt;/span&gt; addresses are managed by the Internet Assigned Numbers Authority (&lt;span class="caps"&gt;IANA&lt;/span&gt;), and Internet registries everywhere agree to configure their routers to abide by this agreement. Without this coordination, our data won’t be able to make it across the Internet so&amp;nbsp;easily.&lt;/p&gt;
&lt;h2&gt;Domain&amp;nbsp;names&lt;/h2&gt;
&lt;p&gt;When was the last time you remembered entering an &lt;span class="caps"&gt;IP&lt;/span&gt; address into the address bar in your browser? (If you’re a tinkerer, maybe the last time you tried to configure your router through a web browser.) Almost all the time, we enter web addresses that use &lt;strong&gt;domain names&lt;/strong&gt;, not &lt;span class="caps"&gt;IP&lt;/span&gt; addresses. Here are some domain names you probably know: www.facebook.com, www.google.com,&amp;nbsp;www.instagram.com.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;https&lt;/code&gt; part in front of addresses like https://www.facebook.com is not part of the domain name; it is the protocol: a web browser would use that to determine which set of rules to use in processing the data received. I first introduced the idea of a protocol in &lt;a href="https://ngjunsiang.github.io/laymansguide/issue007.html"&gt;Issue 7&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;Here’s something that might be new to some of you: www.facebook.com is still not the domain name. facebook.com is the domain name. That’s how it was conceptualised in the 1980s, where people already realised that memorising names is much easier than memorising &lt;span class="caps"&gt;IP&lt;/span&gt; addresses. The original specifications for the Domain Name System were published in 1983, making this system less than 40 years&amp;nbsp;old.&lt;/p&gt;
&lt;p&gt;The right to use a domain name is governed by &lt;strong&gt;domain name registrars&lt;/strong&gt; (basically any service you see selling and managing domain names), which have to be accredited by the Internet Corporation for Assigned Names and Numbers (&lt;span class="caps"&gt;ICANN&lt;/span&gt;).&lt;/p&gt;
&lt;h2&gt;Subdomains&lt;/h2&gt;
&lt;p&gt;Some domains are a huge place. Just look at the number of services Google offers. Each of these services might be residing on a different server, under a different &lt;span class="caps"&gt;IP&lt;/span&gt; address. It would be mightily inconvenient if each domain name could only be mapped to a single &lt;span class="caps"&gt;IP&lt;/span&gt; address: we would have to use multiple domain names to access them, perhaps gmail.com, googledrive.com, googleslides.com, and so&amp;nbsp;on.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Subdomains&lt;/strong&gt; are a way for a router to consolidate multiple locations under a single domain name. A data packet with the address www.google.com would be routed to the www server, drive.google.com would be routed to the drive server, mail.google.com would be routed to the mail server … and Google can strengthen its identity under this single domain name, and save on registering additional domain&amp;nbsp;names.&lt;/p&gt;
&lt;p&gt;Subdomains make it easier for a business or organisation to organise their web presence and identity. Once you have registered myorganisation.com as your domain name, you can configure your hosting server (the server that holds your webpages and files) with multiple subdomains (up to 100 per&amp;nbsp;domain).&lt;/p&gt;
&lt;h2&gt;… and Top-level&amp;nbsp;domains&lt;/h2&gt;
&lt;p&gt;What about international organisations? Some of them may have different branch offices, with webpages hosted on different servers with different &lt;span class="caps"&gt;IP&lt;/span&gt; addresses. Subdomains are a clunky way to deal with this: what if each office needed those subdomains to further divide sections of their website? You would have sgsales.acmecorp.com, sgsupport.acmecorp.com, sgadmin.acmecorp.com, ussales.acmecorp.com, … what a mess! Reserving a part of the full domain just for countries seemed like an obvious idea at the time, and so it&amp;nbsp;happened.&lt;/p&gt;
&lt;p&gt;The Domain Name System originally specified two main groups of &lt;strong&gt;top-level domains&lt;/strong&gt; (&lt;span class="caps"&gt;TLD&lt;/span&gt;):&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;The country code top-level domain, based on two-character territory codes.&amp;nbsp;Example: &lt;code&gt;.sg&lt;/code&gt;, &lt;code&gt;.my&lt;/code&gt;, &lt;code&gt;.us&lt;/code&gt;, &lt;code&gt;.ru&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;The seven generic top-level domains&amp;nbsp;– &lt;code&gt;.gov&lt;/code&gt;, &lt;code&gt;.edu&lt;/code&gt;, &lt;code&gt;.com&lt;/code&gt;, &lt;code&gt;.mil&lt;/code&gt;, &lt;code&gt;.org&lt;/code&gt;, &lt;code&gt;.net&lt;/code&gt;, &lt;code&gt;.int&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;A web address &lt;em&gt;must&lt;/em&gt; have a generic top-level domain describing its category, and optionally may also have a country code top-level domain to signify its associated territory. This helps people to identify the category/purpose and origin of the&amp;nbsp;website.&lt;/p&gt;
&lt;p&gt;Each top-level domain is managed by an administrative registry which takes care of the database of names under that &lt;span class="caps"&gt;TLD&lt;/span&gt;. Registration requests from the domain name registrars (mentioned above under domain names) are forwarded to the respective registries. This enables some TLDs to be protected. For instance, .edu domains may only be registered by accredited organisations on a the &lt;span class="caps"&gt;U.S.&lt;/span&gt; Department of Education’s list (&lt;a href="https://en.wikipedia.org/wiki/.edu#Eligibility"&gt;Wikipedia link&lt;/a&gt;).&lt;/p&gt;
&lt;h2&gt;&lt;span class="caps"&gt;WHOIS&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;What do these organisations do with their huge list of domain names? They put them in databases, of course. If you want to find out who&amp;nbsp;registered &lt;code&gt;mydomainname.net&lt;/code&gt;, you would send a request to a &lt;span class="caps"&gt;WHOIS&lt;/span&gt; server (that is not an acronym, it just means “who is”!) and it would give you the registrant’s information. Here, &lt;a href="https://whois.icann.org/en"&gt;give it a try&lt;/a&gt;. Just key in any domain name you know. I’ll&amp;nbsp;wait.&lt;/p&gt;
&lt;p&gt;When you register a domain name with a domain name registrar, you are putting your name on the &lt;span class="caps"&gt;WHOIS&lt;/span&gt; database, so that people know who the domain belongs to when they query the &lt;span class="caps"&gt;WHOIS&lt;/span&gt; database. The domain name registrar lets you configure the domain name to associate it with your &lt;span class="caps"&gt;IP&lt;/span&gt; address. This information then propagates through the registrar’s Domain Name System (&lt;span class="caps"&gt;DNS&lt;/span&gt;) servers, so that within a day or two, data packets will start to arrive at your&amp;nbsp;server.&lt;/p&gt;
&lt;p&gt;How does that happen? That’s a story for the next&amp;nbsp;issue.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Issue summary:&lt;/strong&gt; Domain names consist of an optional subdomain, the domain name, and the top-level domain. The top-level domains are managed by a registry, which receives registration requests from domain name registrars, and maintains registrant information for each domain under their &lt;span class="caps"&gt;TLD&lt;/span&gt; in a &lt;span class="caps"&gt;WHOIS&lt;/span&gt; database. The domain name registrars let you configure which &lt;span class="caps"&gt;IP&lt;/span&gt; address to forward data packets to, and propagate that information through their &lt;span class="caps"&gt;DNS&lt;/span&gt; servers so that data packets will be routed&amp;nbsp;accordingly.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;This was wayyy longer than I thought it would be—there are a lot of things I needed to look up and confirm. That’s part of the reason I started this newsletter: to help me clarify what I know and ensure it’s not just “something I heard”. Domain names, something that looks so simple, has a really huge backend system maintaining its&amp;nbsp;existence!&lt;/p&gt;
&lt;p&gt;If you really try to imagine how all this happens, one thing starts to become clear: the backbone of the Internet is lists and lists and lists and lists … and the hardware that looks up these lists for you are really carrying a heavy load! There are numerous organisations responsible for ensuring that the Internet keeps on running. The day they are no longer sustainable, the Internet is going to be reconfigured into something a lot less&amp;nbsp;interconnected.&lt;/p&gt;
&lt;p&gt;I’m sorry if this issue was a little too heavy on the terms. I bolded the terms that I’m likely to use again, if it helps to focus your attention. I’ll reintroduce the terms again if I use them in future&amp;nbsp;issues.&lt;/p&gt;
&lt;h2&gt;What I’ll be covering&amp;nbsp;next&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Next issue:&lt;/strong&gt; &lt;span class="caps"&gt;DNS&lt;/span&gt; lookup and resolving (how do I know which &lt;span class="caps"&gt;IP&lt;/span&gt; address to send this packet&amp;nbsp;to?)&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Sometime in the future:&lt;/strong&gt; What&amp;nbsp;is:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;booting up? [Issue&amp;nbsp;15]&lt;/li&gt;
&lt;li&gt;a cookie? [Issue&amp;nbsp;8]&lt;/li&gt;
&lt;li&gt;a cache? [Issue&amp;nbsp;8]&lt;/li&gt;
&lt;li&gt;&lt;span class="caps"&gt;XSS&lt;/span&gt;? [Issue&amp;nbsp;8]&lt;/li&gt;
&lt;li&gt;a &lt;span class="caps"&gt;CDN&lt;/span&gt;? [Issue&amp;nbsp;8]&lt;/li&gt;
&lt;li&gt;Unicode? And what does it have to do with emoji? [Issue&amp;nbsp;8]&lt;/li&gt;
&lt;li&gt;those &amp;#8216;\r\n&amp;#8217;s in the &lt;span class="caps"&gt;HTTP&lt;/span&gt; request packet [Issue&amp;nbsp;12,17]?&lt;/li&gt;
&lt;li&gt;a good reason developers write code and give it away for free online? [Issue&amp;nbsp;21]&lt;/li&gt;
&lt;li&gt;&lt;span class="caps"&gt;ASCII&lt;/span&gt;? [Issue&amp;nbsp;23]&lt;/li&gt;
&lt;li&gt;compiling code into an application [Issue&amp;nbsp;26]?&lt;/li&gt;
&lt;/ul&gt;</content><category term="Season 03"></category></entry><entry><title>Issue 27: What is an IP address?</title><link href="https://ngjunsiang.github.io/laymansguide/issue027.html" rel="alternate"></link><published>2019-06-29T08:00:00+08:00</published><updated>2019-06-29T08:00:00+08:00</updated><author><name>J S Ng</name></author><id>tag:ngjunsiang.github.io,2019-06-29:/laymansguide/issue027.html</id><summary type="html">&lt;p&gt;P addresses are a string of four numbers. A list of reserved &lt;span class="caps"&gt;IP&lt;/span&gt; addresses is managed by &lt;span class="caps"&gt;IANA&lt;/span&gt;, and all Internet registries agree to forward data packets according to that list. A data packet sent from a client goes to its gateway. At the gateway, the destination &lt;span class="caps"&gt;IP&lt;/span&gt; address is checked against the gateway’s forwarding tables. If the &lt;span class="caps"&gt;IP&lt;/span&gt; address is found in the forwarding table, it gets sent along that route, otherwise it gets forwarded to the next gateway, … until it reaches its&amp;nbsp;destination.&lt;/p&gt;</summary><content type="html">&lt;p&gt;In Season 2, I took a detour to introduce some cool things that developers typically work with, and ideas they implement to make their work as smooth as&amp;nbsp;possible.&lt;/p&gt;
&lt;p&gt;And now we’re back on track, where I last stopped in Season 1. There, I did a little dive into my app to introduce &lt;a href="https://ngjunsiang.github.io/laymansguide/issue007.html"&gt;&lt;span class="caps"&gt;HTTP&lt;/span&gt;&lt;/a&gt;), the protocol that forms the &lt;em&gt;de facto&lt;/em&gt; means of communication for the internet. And then I showed some &lt;a href="https://ngjunsiang.github.io/laymansguide/issue009.html"&gt;&lt;span class="caps"&gt;HTTP&lt;/span&gt; requests&lt;/a&gt;), the basic means of requesting data from servers, served over unsecured &lt;span class="caps"&gt;HTTP&lt;/span&gt; and secured &lt;span class="caps"&gt;HTTPS&lt;/span&gt;, and I hope that illustrated sufficiently why &lt;span class="caps"&gt;HTTPS&lt;/span&gt; is really&amp;nbsp;important.&lt;/p&gt;
&lt;p&gt;In Season 3, I’ll continue where I left off. We’ll see where that &lt;span class="caps"&gt;HTTP&lt;/span&gt; request packet goes, and what this Internet thing looks like on the&amp;nbsp;outside.&lt;/p&gt;
&lt;h2&gt;The &lt;span class="caps"&gt;HTTP&lt;/span&gt; packet,&amp;nbsp;revisited&lt;/h2&gt;
&lt;p&gt;&lt;img alt="An HTTP request captured in Wireshark" src="https://ngjunsiang.github.io/laymansguide/issue012_01.png" /&gt;&lt;br /&gt;
&lt;em&gt;Remember this from &lt;a href="https://ngjunsiang.github.io/laymansguide/issue012.html"&gt;Issue 12&lt;/a&gt;)?&lt;/em&gt;    &lt;/p&gt;
&lt;p&gt;The two columns (Source and Destination) that I censored out contain my &lt;span class="caps"&gt;IP&lt;/span&gt; address, and Hypothes.is’s &lt;span class="caps"&gt;IP&lt;/span&gt; address. Why would I want to censor that? I hope this and the next few issues will make it&amp;nbsp;clear.&lt;/p&gt;
&lt;p&gt;When my laptop sends out the &lt;span class="caps"&gt;HTTP&lt;/span&gt; packet, the radio waves containing the data do not have enough energy to reach all the way to wherever Hypothes.is’s servers are based. Instead, before they completely dissipate to undetectable levels, my router has to receive them (just like a radio receives &lt;span class="caps"&gt;FM&lt;/span&gt; waves with its antenna), decode the information, and pass it forward to my &lt;span class="caps"&gt;ISP&lt;/span&gt;’s server, which then forwards it to another server … until it finally reaches the Hypothes.is&amp;nbsp;server.&lt;/p&gt;
&lt;p&gt;How does it do&amp;nbsp;that?&lt;/p&gt;
&lt;h2&gt;The &lt;span class="caps"&gt;IP&lt;/span&gt;&amp;nbsp;address&lt;/h2&gt;
&lt;p&gt;Each &lt;span class="caps"&gt;HTTP&lt;/span&gt; packet contains information about the source of the packet (i.e. my router), and the destination of the packet (i.e. Hypothes.is). This information is encoded as a string of four numbers, ranging from 0 to 255 (the smallest possible combination is 0.0.0.0, the largest is&amp;nbsp;255.255.255.255).&lt;/p&gt;
&lt;p&gt;This string of four numbers is known as an &lt;span class="caps"&gt;IP&lt;/span&gt;&amp;nbsp;address.&lt;/p&gt;
&lt;p&gt;If you are good at math, you can work out the total number of available combinations: it’s 4,294,967,296 (256^4). It seems like a lot, but we actually have more humans on this planet than we have &lt;span class="caps"&gt;IP&lt;/span&gt; addresses. And if we assign a unique &lt;span class="caps"&gt;IP&lt;/span&gt; address to each device on the Internet, many of us will need multiple &lt;span class="caps"&gt;IP&lt;/span&gt; addresses for our smartphone, laptop, Amazon Echo, smart &lt;span class="caps"&gt;TV&lt;/span&gt;, router,&amp;nbsp;…&lt;/p&gt;
&lt;p&gt;&lt;span class="caps"&gt;IP&lt;/span&gt; addresses are a limited resource! They are really precious! If you don’t have one, nobody would be able to send you anything. The &lt;span class="caps"&gt;HTTP&lt;/span&gt; packets that other people send will never reach you. The &lt;span class="caps"&gt;HTTP&lt;/span&gt; packets you send will not have an &lt;span class="caps"&gt;IP&lt;/span&gt; address in the Source column above. You would be cut off from the internet. (Less dramatically, you would be&amp;nbsp;offline.)&lt;/p&gt;
&lt;p&gt;When you sign a contract with your &lt;span class="caps"&gt;ISP&lt;/span&gt; for an internet connection, they might give you a free router and other niceties or freebies. But the most important thing they give you is the privilege of using one of the &lt;span class="caps"&gt;IP&lt;/span&gt; addresses they&amp;nbsp;own.&lt;/p&gt;
&lt;h2&gt;Wait what?! Why do the ISPs get to hog all the &lt;span class="caps"&gt;IP&lt;/span&gt;&amp;nbsp;addresses?&lt;/h2&gt;
&lt;p&gt;A long long time ago … well, actually just back in 1987, a bunch of internet pioneers came together and published a list of reserved &lt;span class="caps"&gt;IP&lt;/span&gt; addresses in &lt;a href="https://tools.ietf.org/html/rfc1010"&gt;&lt;span class="caps"&gt;RFC1010&lt;/span&gt; (starting on page 16)&lt;/a&gt;. The RFCs (&lt;strong&gt;R&lt;/strong&gt;equest &lt;strong&gt;F&lt;/strong&gt;or &lt;strong&gt;C&lt;/strong&gt;omments) are documents published by the Internet Engineering Task Force (&lt;span class="caps"&gt;IETF&lt;/span&gt;) for interested folks to review. Considering the magnitude of responsibility involved, a committee was drafted … and the &lt;a href="https://en.wikipedia.org/wiki/Internet_Assigned_Numbers_Authority"&gt;Internet Assigned Numbers Authority&lt;/a&gt; (&lt;span class="caps"&gt;IANA&lt;/span&gt;) was born in&amp;nbsp;1988.&lt;/p&gt;
&lt;p&gt;&lt;span class="caps"&gt;IANA&lt;/span&gt; parcelled out &lt;span class="caps"&gt;IP&lt;/span&gt; addresses to regional Internet registries, which further subassigned them to smaller Internet registries, such as your &lt;span class="caps"&gt;ISP&lt;/span&gt;. Lots of money was involved, unsurprisingly. To own an &lt;span class="caps"&gt;IP&lt;/span&gt; address means to have every registry out there agree that all data packets intended for that &lt;span class="caps"&gt;IP&lt;/span&gt; address should be forwarded to your server. That’s a lot of obedience you own, and it will cost&amp;nbsp;you.&lt;/p&gt;
&lt;p&gt;Okay, so how do those packets actually make their way to you if they don’t originate anywhere near&amp;nbsp;you?&lt;/p&gt;
&lt;h2&gt;Forwarding Tables and The&amp;nbsp;Gateway&lt;/h2&gt;
&lt;p&gt;Your smartphone, or laptop, first sends the packet to its gateway (which is typically your router). Your router differs from your handy gadgets in one key way: it is a server, while your gadgets are clients (&lt;a href="https://ngjunsiang.github.io/laymansguide/issue007.html"&gt;I covered clients and servers in Issue 7.&lt;/a&gt;)). The router contains a forwarding table, which is a table telling it where to forward data meant for various &lt;span class="caps"&gt;IP&lt;/span&gt; addresses. For example, if you are trying to send a document to your home network printer, that data packet is not meant to go out onto the Internet—it’s meant to be forwarded to the printer! The information in the forwarding table ensures that this happens. Your laptop has no idea what the &lt;span class="caps"&gt;IP&lt;/span&gt; address of the printer is; all it knows is your router’s &lt;span class="caps"&gt;IP&lt;/span&gt; address, and it will forward everything to your router for it to figure&amp;nbsp;out.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Network connection properties window" src="https://ngjunsiang.github.io/laymansguide/issue027_01.png" /&gt;&lt;br /&gt;
&lt;em&gt;Network connection properties, a window that one used to see very often when configuring a router. &lt;a href="https://helpdeskgeek.com/networking/change-ip-address-and-dns-servers-using-the-command-prompt/"&gt;Source: Help Desk&amp;nbsp;Geek&lt;/a&gt;&lt;/em&gt;    &lt;/p&gt;
&lt;p&gt;If the destination &lt;span class="caps"&gt;IP&lt;/span&gt; address is not in the forwarding table, the data packet gets forwarded to &lt;strong&gt;your router’s gateway&lt;/strong&gt;, which is typically your &lt;span class="caps"&gt;ISP&lt;/span&gt;’s router. The &lt;span class="caps"&gt;ISP&lt;/span&gt; router then checks its forwarding tables to see if the destination address is in there (maybe the data packet is meant for one of your &lt;span class="caps"&gt;ISP&lt;/span&gt;’s customers?), if not it gets forwarded to the next gateway … a few hops and bounces later, it finally reaches its destination.&amp;nbsp;Phew!&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Issue summary:&lt;/strong&gt; &lt;span class="caps"&gt;IP&lt;/span&gt; addresses are a string of four numbers. A list of reserved &lt;span class="caps"&gt;IP&lt;/span&gt; addresses is managed by &lt;span class="caps"&gt;IANA&lt;/span&gt;, and all Internet registries agree to forward data packets according to that list. A data packet sent from a client goes to its gateway. At the gateway, the destination &lt;span class="caps"&gt;IP&lt;/span&gt; address is checked against the gateway’s forwarding tables. If the &lt;span class="caps"&gt;IP&lt;/span&gt; address is found in the forwarding table, it gets sent along that route, otherwise it gets forwarded to the next gateway, … until it reaches its&amp;nbsp;destination.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;This looked like a good place to stop before I get any deeper. I’ve left out a lot of the history of development of the internet and Internet Protocol (which is where the acronym &lt;span class="caps"&gt;IP&lt;/span&gt; comes from), because it is necessarily messy and not really relevant here. But one important result of these developments is that there isn’t a single master server out there to which &lt;strong&gt;all&lt;/strong&gt; data packets must go to be sorted. This makes the Internet more robust (if one gateway fails, your packet can still reach its destination via other routes), but more importantly it prevents server owners from dominating the entire Internet and its development (because whoever owns that master gateway will hold great sway over the flow of&amp;nbsp;information).&lt;/p&gt;
&lt;h2&gt;What I’ll be covering&amp;nbsp;next&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Next season:&lt;/strong&gt; Domain Names (because who memorises &lt;span class="caps"&gt;IP&lt;/span&gt; addresses&amp;nbsp;anyway?)&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Sometime in the future:&lt;/strong&gt; What&amp;nbsp;is:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;booting up? [Issue&amp;nbsp;15]&lt;/li&gt;
&lt;li&gt;a cookie? [Issue&amp;nbsp;8]&lt;/li&gt;
&lt;li&gt;a cache? [Issue&amp;nbsp;8]&lt;/li&gt;
&lt;li&gt;&lt;span class="caps"&gt;XSS&lt;/span&gt;? [Issue&amp;nbsp;8]&lt;/li&gt;
&lt;li&gt;a &lt;span class="caps"&gt;CDN&lt;/span&gt;? [Issue&amp;nbsp;8]&lt;/li&gt;
&lt;li&gt;Unicode? And what does it have to do with emoji? [Issue&amp;nbsp;8]&lt;/li&gt;
&lt;li&gt;those &amp;#8216;\r\n&amp;#8217;s in the &lt;span class="caps"&gt;HTTP&lt;/span&gt; request packet [Issue&amp;nbsp;12,17]?&lt;/li&gt;
&lt;li&gt;a good reason developers write code and give it away for free online? [Issue&amp;nbsp;21]&lt;/li&gt;
&lt;li&gt;&lt;span class="caps"&gt;ASCII&lt;/span&gt;? [Issue&amp;nbsp;23]&lt;/li&gt;
&lt;li&gt;compiling code into an application [Issue&amp;nbsp;26]?&lt;/li&gt;
&lt;/ul&gt;</content><category term="Season 03"></category></entry></feed>