<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:googleplay="http://www.google.com/schemas/play-podcasts/1.0"><channel><title><![CDATA[SWE Handbook]]></title><description><![CDATA[Finding software engineering hard? Same! SWE Handbook aims to make it easier by sharing my firsthand insights on networking, databases, and more.]]></description><link>https://www.swehandbook.com</link><image><url>https://substackcdn.com/image/fetch/$s_!aQXI!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa3393623-aa85-40dc-88ea-fabab48b290a_576x576.png</url><title>SWE Handbook</title><link>https://www.swehandbook.com</link></image><generator>Substack</generator><lastBuildDate>Wed, 06 May 2026 10:54:07 GMT</lastBuildDate><atom:link href="https://www.swehandbook.com/feed" rel="self" type="application/rss+xml"/><copyright><![CDATA[Nicholas Lim]]></copyright><language><![CDATA[en]]></language><webMaster><![CDATA[swehandbook@substack.com]]></webMaster><itunes:owner><itunes:email><![CDATA[swehandbook@substack.com]]></itunes:email><itunes:name><![CDATA[Nicholas Lim]]></itunes:name></itunes:owner><itunes:author><![CDATA[Nicholas Lim]]></itunes:author><googleplay:owner><![CDATA[swehandbook@substack.com]]></googleplay:owner><googleplay:email><![CDATA[swehandbook@substack.com]]></googleplay:email><googleplay:author><![CDATA[Nicholas Lim]]></googleplay:author><itunes:block><![CDATA[Yes]]></itunes:block><item><title><![CDATA[Switches and Routers]]></title><description><![CDATA[How switches and routers (and repeaters, bridges and hubs) work [Networking Fundamentals]]]></description><link>https://www.swehandbook.com/p/switches-and-routers</link><guid isPermaLink="false">https://www.swehandbook.com/p/switches-and-routers</guid><dc:creator><![CDATA[Nicholas Lim]]></dc:creator><pubDate>Sun, 25 Feb 2024 08:29:12 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/4c847d71-0357-45f6-938e-a91da797825c_2912x2048.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Switches and routers form the foundations of computer networks as they are vital for ensuring that data packets reach their destination. To help us understand how switches and routers work, it&#8217;ll be helpful to first understand what are repeaters, bridges and hubs.</p><h2>Repeaters</h2><p>The purpose of a repeater is to simply regenerate signals. When data is transmitted across a wire, it decays as it travels further along the wire. When two devices are far away from each other, data signals might decay too much for them to communicate - repeaters solve this by regenerating signals.</p><h2>Hubs</h2><p>When two computers communicate directly with each other, they can use a single wire between them. When one more computer is added, you now need 3 wires so that they can all communicate with each other. The number of wires starts to grow quickly with each additional computer - when you add the Nth computer, you need </p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\n(N-1 + N-2 + \\ldots + 1) = \\frac{N(N-1)}{2}, \\text{ or } O(N^2) \\text{ wires}&quot;,&quot;id&quot;:&quot;JPLFEEQABD&quot;}" data-component-name="LatexBlockToDOM"></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!tynu!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2128bda9-1781-4456-a82d-e7e72305f858_938x790.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!tynu!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2128bda9-1781-4456-a82d-e7e72305f858_938x790.png 424w, https://substackcdn.com/image/fetch/$s_!tynu!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2128bda9-1781-4456-a82d-e7e72305f858_938x790.png 848w, https://substackcdn.com/image/fetch/$s_!tynu!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2128bda9-1781-4456-a82d-e7e72305f858_938x790.png 1272w, https://substackcdn.com/image/fetch/$s_!tynu!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2128bda9-1781-4456-a82d-e7e72305f858_938x790.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!tynu!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2128bda9-1781-4456-a82d-e7e72305f858_938x790.png" width="306" height="257.7185501066098" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2128bda9-1781-4456-a82d-e7e72305f858_938x790.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:790,&quot;width&quot;:938,&quot;resizeWidth&quot;:306,&quot;bytes&quot;:56695,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!tynu!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2128bda9-1781-4456-a82d-e7e72305f858_938x790.png 424w, https://substackcdn.com/image/fetch/$s_!tynu!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2128bda9-1781-4456-a82d-e7e72305f858_938x790.png 848w, https://substackcdn.com/image/fetch/$s_!tynu!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2128bda9-1781-4456-a82d-e7e72305f858_938x790.png 1272w, https://substackcdn.com/image/fetch/$s_!tynu!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2128bda9-1781-4456-a82d-e7e72305f858_938x790.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">5 computers requires 5(4)/2 = 10 wires</figcaption></figure></div><p>Hubs avoid this problem by acting as an intermediary between computers - when one computer sends a data signal to the hub, the hub broadcasts the data signal to all other computers connected to the hub. Hubs are essentially <em>multi-port</em> repeaters.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!upyu!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1eacf7dd-b7c2-438b-b35b-b40089f93fab_938x790.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!upyu!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1eacf7dd-b7c2-438b-b35b-b40089f93fab_938x790.png 424w, https://substackcdn.com/image/fetch/$s_!upyu!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1eacf7dd-b7c2-438b-b35b-b40089f93fab_938x790.png 848w, https://substackcdn.com/image/fetch/$s_!upyu!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1eacf7dd-b7c2-438b-b35b-b40089f93fab_938x790.png 1272w, https://substackcdn.com/image/fetch/$s_!upyu!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1eacf7dd-b7c2-438b-b35b-b40089f93fab_938x790.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!upyu!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1eacf7dd-b7c2-438b-b35b-b40089f93fab_938x790.png" width="296" height="249.2963752665245" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1eacf7dd-b7c2-438b-b35b-b40089f93fab_938x790.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:790,&quot;width&quot;:938,&quot;resizeWidth&quot;:296,&quot;bytes&quot;:43693,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!upyu!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1eacf7dd-b7c2-438b-b35b-b40089f93fab_938x790.png 424w, https://substackcdn.com/image/fetch/$s_!upyu!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1eacf7dd-b7c2-438b-b35b-b40089f93fab_938x790.png 848w, https://substackcdn.com/image/fetch/$s_!upyu!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1eacf7dd-b7c2-438b-b35b-b40089f93fab_938x790.png 1272w, https://substackcdn.com/image/fetch/$s_!upyu!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1eacf7dd-b7c2-438b-b35b-b40089f93fab_938x790.png 1456w" sizes="100vw"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Hub forwarding messages to all other connected computers</figcaption></figure></div><h2>Bridges</h2><p>However, one issue with hubs is that the data signal is broadcasted to all devices connected to the hub - what if we only want some devices to receive the data signal? We can use a bridge!</p><p>Just like a physical bridge that has two ends, a network bridge also has two interfaces/ports to connect to. When a device wants to send data to another device on the same side, the bridge will receive a broadcasted data signal from that side&#8217;s hub and choose to not forward it to the other side. When a computer wants to send a message to a computer on the other side of the bridge, the bridge will forward this to the other side.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!roz-!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b56b10c-d672-43a8-af4c-d4a07bbade18_956x545.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!roz-!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b56b10c-d672-43a8-af4c-d4a07bbade18_956x545.png 424w, https://substackcdn.com/image/fetch/$s_!roz-!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b56b10c-d672-43a8-af4c-d4a07bbade18_956x545.png 848w, https://substackcdn.com/image/fetch/$s_!roz-!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b56b10c-d672-43a8-af4c-d4a07bbade18_956x545.png 1272w, https://substackcdn.com/image/fetch/$s_!roz-!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b56b10c-d672-43a8-af4c-d4a07bbade18_956x545.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!roz-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b56b10c-d672-43a8-af4c-d4a07bbade18_956x545.png" width="474" height="270.2196652719665" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5b56b10c-d672-43a8-af4c-d4a07bbade18_956x545.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:545,&quot;width&quot;:956,&quot;resizeWidth&quot;:474,&quot;bytes&quot;:41223,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!roz-!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b56b10c-d672-43a8-af4c-d4a07bbade18_956x545.png 424w, https://substackcdn.com/image/fetch/$s_!roz-!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b56b10c-d672-43a8-af4c-d4a07bbade18_956x545.png 848w, https://substackcdn.com/image/fetch/$s_!roz-!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b56b10c-d672-43a8-af4c-d4a07bbade18_956x545.png 1272w, https://substackcdn.com/image/fetch/$s_!roz-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b56b10c-d672-43a8-af4c-d4a07bbade18_956x545.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Bridge stops the data signal from reaching the right side</figcaption></figure></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!FOnR!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fea74be9d-5867-480d-bfc9-0454ab4b415c_956x532.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!FOnR!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fea74be9d-5867-480d-bfc9-0454ab4b415c_956x532.png 424w, https://substackcdn.com/image/fetch/$s_!FOnR!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fea74be9d-5867-480d-bfc9-0454ab4b415c_956x532.png 848w, https://substackcdn.com/image/fetch/$s_!FOnR!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fea74be9d-5867-480d-bfc9-0454ab4b415c_956x532.png 1272w, https://substackcdn.com/image/fetch/$s_!FOnR!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fea74be9d-5867-480d-bfc9-0454ab4b415c_956x532.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!FOnR!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fea74be9d-5867-480d-bfc9-0454ab4b415c_956x532.png" width="492" height="273.7907949790795" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ea74be9d-5867-480d-bfc9-0454ab4b415c_956x532.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:532,&quot;width&quot;:956,&quot;resizeWidth&quot;:492,&quot;bytes&quot;:41533,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!FOnR!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fea74be9d-5867-480d-bfc9-0454ab4b415c_956x532.png 424w, https://substackcdn.com/image/fetch/$s_!FOnR!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fea74be9d-5867-480d-bfc9-0454ab4b415c_956x532.png 848w, https://substackcdn.com/image/fetch/$s_!FOnR!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fea74be9d-5867-480d-bfc9-0454ab4b415c_956x532.png 1272w, https://substackcdn.com/image/fetch/$s_!FOnR!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fea74be9d-5867-480d-bfc9-0454ab4b415c_956x532.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Bridge forwards the data signal to the right side</figcaption></figure></div><p>We see that the bridge learns which devices are on each side, then decides whether to forward the data signal based on the destination of the data signal.</p><h2>Switches</h2><p>What if we only want communication between two specific devices? Or communication between one device and a dynamic set of other devices? We&#8217;ll use a switch!</p><p>A switch is a combination of a hub and a bridge - it has multiple ports like a switch, and learns which devices are on each port like a bridge. When an origin device wants to send a message to a destination device, the switch knows which port the destination device is on and only forwards the message to that port. </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!RxQr!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffbbef2c3-98bc-4252-b056-e07081282781_654x532.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!RxQr!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffbbef2c3-98bc-4252-b056-e07081282781_654x532.png 424w, https://substackcdn.com/image/fetch/$s_!RxQr!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffbbef2c3-98bc-4252-b056-e07081282781_654x532.png 848w, https://substackcdn.com/image/fetch/$s_!RxQr!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffbbef2c3-98bc-4252-b056-e07081282781_654x532.png 1272w, https://substackcdn.com/image/fetch/$s_!RxQr!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffbbef2c3-98bc-4252-b056-e07081282781_654x532.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!RxQr!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffbbef2c3-98bc-4252-b056-e07081282781_654x532.png" width="402" height="327.0091743119266" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/fbbef2c3-98bc-4252-b056-e07081282781_654x532.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:532,&quot;width&quot;:654,&quot;resizeWidth&quot;:402,&quot;bytes&quot;:34258,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!RxQr!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffbbef2c3-98bc-4252-b056-e07081282781_654x532.png 424w, https://substackcdn.com/image/fetch/$s_!RxQr!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffbbef2c3-98bc-4252-b056-e07081282781_654x532.png 848w, https://substackcdn.com/image/fetch/$s_!RxQr!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffbbef2c3-98bc-4252-b056-e07081282781_654x532.png 1272w, https://substackcdn.com/image/fetch/$s_!RxQr!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffbbef2c3-98bc-4252-b056-e07081282781_654x532.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Switch only forwards the signal to the destination</figcaption></figure></div><p>The switch knows this by building a MAC (media access control) address table. MAC addresses are unique 48-bit hardware addresses assigned to each network card in each device during manufacturing. As the switch receives data frames from devices connected to its ports, it finds the MAC addresses of these source devices and associates these MAC addresses with the ports on which it received the frames. If it encounters a frame where the destination MAC address hasn&#8217;t been seen before, it will forward the frame to all ports except the one on which it was received.</p><p>As MAC addresses are not routable across different networks like IP addresses, they are primarily used by switches for directing traffic to the correct destination within the same network. As such, switches facilitate communication <em>within</em> a network, while routers facilitate communication <em>between</em> networks.</p><p>You might wonder though, what separates what&#8217;s within a network, and outside of the network? This differentiation is typically based on IP addressing, where devices within a network share the same IP address range, while devices in different networks have distinct IP address ranges.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!qSA9!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F131cf88f-7706-46f0-9b3c-c22fd6c1204f_774x663.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!qSA9!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F131cf88f-7706-46f0-9b3c-c22fd6c1204f_774x663.png 424w, https://substackcdn.com/image/fetch/$s_!qSA9!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F131cf88f-7706-46f0-9b3c-c22fd6c1204f_774x663.png 848w, https://substackcdn.com/image/fetch/$s_!qSA9!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F131cf88f-7706-46f0-9b3c-c22fd6c1204f_774x663.png 1272w, https://substackcdn.com/image/fetch/$s_!qSA9!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F131cf88f-7706-46f0-9b3c-c22fd6c1204f_774x663.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!qSA9!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F131cf88f-7706-46f0-9b3c-c22fd6c1204f_774x663.png" width="432" height="370.04651162790697" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/131cf88f-7706-46f0-9b3c-c22fd6c1204f_774x663.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:663,&quot;width&quot;:774,&quot;resizeWidth&quot;:432,&quot;bytes&quot;:75524,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!qSA9!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F131cf88f-7706-46f0-9b3c-c22fd6c1204f_774x663.png 424w, https://substackcdn.com/image/fetch/$s_!qSA9!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F131cf88f-7706-46f0-9b3c-c22fd6c1204f_774x663.png 848w, https://substackcdn.com/image/fetch/$s_!qSA9!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F131cf88f-7706-46f0-9b3c-c22fd6c1204f_774x663.png 1272w, https://substackcdn.com/image/fetch/$s_!qSA9!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F131cf88f-7706-46f0-9b3c-c22fd6c1204f_774x663.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Devices in this network all share the 192.168.100.x IP address space</figcaption></figure></div><h2>Routers</h2><p>Routers facilitates communication between networks by routing data packets based on their destination IP addresses. Routers serve as gateways for each network - for each network they are connected to, they have an IP address within that network, such as <code>192.168.12.12</code> and <code>192.168.13.22</code> as shown in the diagram below. For each device, the router is their way out of their local network.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Qemg!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F356dff4a-5222-436f-a91d-b5a1d88ba5c6_1687x665.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Qemg!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F356dff4a-5222-436f-a91d-b5a1d88ba5c6_1687x665.png 424w, https://substackcdn.com/image/fetch/$s_!Qemg!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F356dff4a-5222-436f-a91d-b5a1d88ba5c6_1687x665.png 848w, https://substackcdn.com/image/fetch/$s_!Qemg!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F356dff4a-5222-436f-a91d-b5a1d88ba5c6_1687x665.png 1272w, https://substackcdn.com/image/fetch/$s_!Qemg!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F356dff4a-5222-436f-a91d-b5a1d88ba5c6_1687x665.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Qemg!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F356dff4a-5222-436f-a91d-b5a1d88ba5c6_1687x665.png" width="1456" height="574" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/356dff4a-5222-436f-a91d-b5a1d88ba5c6_1687x665.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:574,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:151698,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Qemg!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F356dff4a-5222-436f-a91d-b5a1d88ba5c6_1687x665.png 424w, https://substackcdn.com/image/fetch/$s_!Qemg!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F356dff4a-5222-436f-a91d-b5a1d88ba5c6_1687x665.png 848w, https://substackcdn.com/image/fetch/$s_!Qemg!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F356dff4a-5222-436f-a91d-b5a1d88ba5c6_1687x665.png 1272w, https://substackcdn.com/image/fetch/$s_!Qemg!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F356dff4a-5222-436f-a91d-b5a1d88ba5c6_1687x665.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">The router connects up two networks by acting as the gateway between them</figcaption></figure></div><p>When a router receives data packets from devices connected to their network interfaces, the router examines the destination IP address in the data packets and consults its routing table to determine the best path or next-hop router for forwarding the packet towards its destination.</p><p>A routing table contains information about known networks, including network addresses and the corresponding next-hop routers - they are populated through dynamic routing protocols or manually configured static routes.</p><p>Common routing protocols include RIP (Routing Information Protocol), OSPF (Open Shortest Path First), EIGRP (Enhanced Interior Gateway Routing Protocol), and BGP (Border Gateway Protocol).</p><h2>Conclusion</h2><p>Switches and routers are absolutely vital for computer networks as they ensure that data packets are delivered to the intended destination. Switches use MAC address tables to switch packets <em>within</em> networks, while routers use routing tables to route packets <em>between</em> networks.</p><p>If you found this helpful, please share it with a friend and do consider subscribing &#128071;&#127996;</p><p>Thanks for reading,<br><a href="https://www.linkedin.com/in/jwnicholas99/">Nicholas Lim</a></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://www.swehandbook.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading The Software Engineer's Handbook! Subscribe for free to learn more about all things software engineering</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><h2>Resources</h2><ul><li><p><a href="https://www.youtube.com/watch?v=bj-Yfakjllc&amp;list=PLIFyRwBY_4bRLmKfP1KnZA6rZbRHtxmXi">Practical Networking&#8217;s Networking Fundamentals YouTube Playlist</a></p></li></ul><p></p>]]></content:encoded></item><item><title><![CDATA[Networking Fundamentals]]></title><description><![CDATA[What is a computer network? How do computers talk to each other?]]></description><link>https://www.swehandbook.com/p/networking-fundamentals</link><guid isPermaLink="false">https://www.swehandbook.com/p/networking-fundamentals</guid><dc:creator><![CDATA[Nicholas Lim]]></dc:creator><pubDate>Sun, 25 Feb 2024 06:59:32 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/68210af2-796f-4f9b-b599-9020285def99_2912x2048.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Computer networks are what make the Internet possible. Despite the Internet being an indispensable part of our daily lives as well as our jobs as software engineers, it often seems like a magical black box that just <em>works</em> (or if it doesn&#8217;t work, we&#8217;re not sure why). To understand how the Internet works, I&#8217;ll be taking a look at the fundamentals of computer networking in a series of articles.</p><h2>What is a Computer Network?</h2><p>A computer network is simply a bunch of computers that are connected together so they can talk to one another. More formally, a computer network is two or more computing devices that are connected with the purpose of sharing data and resources.</p><p>Devices in a network are connected via physical (cables, fiber optics) or wireless technologies, allowing them to communicate with one another using a set of standardised rules (protocols).</p><p>There are several types of networks, each for different needs - some of these include:</p><ul><li><p><strong>Local Area Network (LAN):</strong> connects computers over short distances - eg. connecting computers in a school or building</p></li><li><p><strong>Wireless Local Area Network (WLAN):</strong> like LAN but connections are wireless</p></li><li><p><strong>Metropolitan Area Network (MAN):</strong> size is between LAN and WAN - eg. connecting computers across a city</p></li><li><p><strong>Wide Area Network (WAN):</strong> connects computers over a wide area, such as computers across a continent - eg. the internet is the largest WAN in the world</p></li><li><p><strong>Virtual Private Network (VPN):</strong> secure, point-to-point connection between two network end points - establishes an encrypted channel</p></li></ul><h2>Common Terminology</h2><p>Here are some common terms used in computer networking:</p><ul><li><p><strong>Node:</strong> a device connected to a network, including computers, servers, routers, switches and other devices - nodes can receive, send, create or store data</p></li><li><p><strong>Host:</strong> a node, usually a computer or server, that has its own IP address and actively engages in network communication by initiating communication with other devices and responding to requests from other hosts - hosts are a subset of nodes</p></li><li><p><strong>Switches:</strong> a device that connects other devices and manages node-to-node communication within a network (routers connect networks, while switches connect nodes <em>within</em> a network)</p></li><li><p><strong>Routers:</strong> a physical or virtual device that connects networks by sending data packets between them - routers decides a packet&#8217;s future path by examining the destination IP address of the packet&#8217;s header and comparing it to its routing database</p></li><li><p><strong>Internet Protocol (IP) Address:</strong> a unique number that identifies a device on the internet or local network. IP addresses are important as they are crucial in figuring out where to send data to</p></li><li><p><strong>Port:</strong> a virtual point where network connections start and end. Each port is associated with a specific process or service - as lots of different types of data flow to and from a computer, ports helps computers understand where should data go and what to do with them</p></li><li><p><strong>Protocol:</strong> a standardised set of rules or algorithms that define the way how two entities communicate across the network</p></li></ul><h2>How do Computers Talk to Each Other?</h2><p>Let&#8217;s say you want to send a message using your computer to another computer in another network - what happens? Here&#8217;s a high-level overview:</p><p>First, the message is broken down into data packets which contain two parts: a header and a payload. The header includes information such as the source and destination IP addresses, while the payload contains the message.</p><p>Second, the packets are sent from the source node to the destination node through a series of intermediary nodes such as switches and routers. Routers examine the destination IP address in the packet header and decides the best path for forwarding the packet towards its destination.</p><p>Third, when the destination node receives the packets, the packets are reassembled into the original message and processed accordingly.</p><h2>How does the Internet work?</h2><p>The Internet is a behemoth network of networks that enables communication on a global scale. It consists of millions of interconnected networks owned by various organisations, internet service providers (ISPs) and backbone providers. As it is still a network, at a high-level, it works the same way as described in the previous section.</p><p>Let&#8217;s say you want to send an image from your phone to your friend Alex halfway across the world. The image is first broken down into data packets that is sent to your wireless router via radio technology (<a href="https://www.youtube.com/watch?v=0faCad2kKeg">here&#8217;s a video by Wendover</a> that explains how this works). The router then transmits your data packets via electrical signals (copper wires) or flashes of light (fiber optics) to your ISP.</p><p>Next, your ISP sends these data packets to an internet hub where networks are connected together with each other. Because Alex is halfway across the world, these data packets will be further forwarded to the internet backbone providers that have laid out vast arrays of cables to connect up networks across large areas. One such example is the underwater cables that connect up networks across vast bodies of water - here&#8217;s a snapshot of the <a href="https://www.submarinecablemap.com/">Submarine Cable Map</a> by TeleGeography:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!IY5M!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5aa34783-cc26-4b61-aa9e-d71fab43e3d8_1023x805.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!IY5M!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5aa34783-cc26-4b61-aa9e-d71fab43e3d8_1023x805.png 424w, https://substackcdn.com/image/fetch/$s_!IY5M!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5aa34783-cc26-4b61-aa9e-d71fab43e3d8_1023x805.png 848w, https://substackcdn.com/image/fetch/$s_!IY5M!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5aa34783-cc26-4b61-aa9e-d71fab43e3d8_1023x805.png 1272w, https://substackcdn.com/image/fetch/$s_!IY5M!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5aa34783-cc26-4b61-aa9e-d71fab43e3d8_1023x805.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!IY5M!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5aa34783-cc26-4b61-aa9e-d71fab43e3d8_1023x805.png" width="1023" height="805" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5aa34783-cc26-4b61-aa9e-d71fab43e3d8_1023x805.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:805,&quot;width&quot;:1023,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:243017,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!IY5M!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5aa34783-cc26-4b61-aa9e-d71fab43e3d8_1023x805.png 424w, https://substackcdn.com/image/fetch/$s_!IY5M!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5aa34783-cc26-4b61-aa9e-d71fab43e3d8_1023x805.png 848w, https://substackcdn.com/image/fetch/$s_!IY5M!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5aa34783-cc26-4b61-aa9e-d71fab43e3d8_1023x805.png 1272w, https://substackcdn.com/image/fetch/$s_!IY5M!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5aa34783-cc26-4b61-aa9e-d71fab43e3d8_1023x805.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>When the data packets are transmitted across the ocean to reach an internet hub where Alex is, the packets are forwarded to Alex&#8217;s ISP, which then transmits them to his wireless router and to his phone via wireless technology. Lastly, his phone re-assembles the packets into an image.</p><p>All this happens in a <em>split second</em> <em>- </em>genuinely mind-boggling!</p><p><a href="https://www.youtube.com/watch?v=TNQsmPf24go">Here&#8217;s a great video</a> by Vox that explains how the Internet works using helpful visual materials.</p><h2>Conclusion</h2><p>While the Internet might seem like magic, at its core it is a computer network. Computer networks enable computers to communicate with each other by routing data packets using switches and routers until it reaches the destination.</p><p>If you found this helpful, please share it with a friend and do consider subscribing &#128071;&#127996;</p><p>Thanks for reading,<br><a href="https://www.linkedin.com/in/jwnicholas99/">Nicholas Lim</a></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://www.swehandbook.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading The Software Engineer's Handbook! Subscribe for free to learn more about all things software engineering</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><h2>Resources</h2><ul><li><p><a href="https://www.explainthatstuff.com/howcomputernetworkswork.html">Explain That Stuff&#8217;s How Computer Networks Work</a></p></li><li><p><a href="https://www.youtube.com/watch?v=bj-Yfakjllc&amp;list=PLIFyRwBY_4bRLmKfP1KnZA6rZbRHtxmXi">Practical Networking&#8217;s Networking Fundamentals YouTube Playlist</a></p></li><li><p><a href="https://www.ibm.com/topics/networking">IBM&#8217;s What is Networking?</a></p></li><li><p><a href="https://aws.amazon.com/what-is/computer-networking/">AWS&#8217; What is Computer Networking?</a></p></li><li><p><a href="https://www.geeksforgeeks.org/basics-computer-networking/">GeeksForGeeks&#8217; Basic Computer Networking</a></p></li><li><p><a href="https://www.cloudflare.com/learning/network-layer/what-is-a-computer-port/">Cloudflare&#8217;s What is a Computer Port?</a></p></li><li><p><a href="https://www.youtube.com/watch?v=TNQsmPf24go">Vox&#8217;s How Does the Internet Work?</a></p></li></ul>]]></content:encoded></item></channel></rss>