I learned how routers <i>really</i> work from Ericsson's seminal video on the matter, The Good Warriors of the Net: <a href="https://www.youtube.com/watch?v=x9XWxD6cJuY" rel="nofollow">https://www.youtube.com/watch?v=x9XWxD6cJuY</a><p>Though I always thought the "router switch" was much more fun.
> If that is the case, my condolences.<p>As a software engineer working on IOS-XR, that gave me a chuckle :p<p>In the case of enterprise- and SP-grade routers, the data-plane - i.e., where the actual forwarding and lookups take place - runs entirely on a dedicated network processor (NP), mainly for performance reasons. Information on the NP is populated by the router's operating system in response to user configuration, network topology changes, or protocol state updates. On the other hand, the control plane runs mainly on the CPU(s). This is required so that the protocols running on the router OS (e.g., BGP) can receive and send out updates based on their state machines.
> <i>Note that the next hop’s IP address is in the router’s memory only: it does not appear in the packet at any time.</i><p>This clears some points that always puzzled me:<p>If the gateway is identified by an IP address, but the destination host is also an IP address, which address exactly is put into the packet? And how can a packet be routed if the gateway's IP is itself part of the subnet that's supposed to be routed to it. (E.g. 192.168.0.0/24 with default gateway 192.168.0.1)<p>So the answer is, if I send the packet to host 1.1.1.1 but the routing table has 2.2.2.2 as the next hop, the packet will have 1.1.1.1 as the destination in the IP part but the <i>MAC of 2.2.2.2</i> as destination of the Ethernet part (or equivalent). It doesn't matter which subnet the next hop's IP is in, as the routing table isn't consulted for it anyway - it's only used in ARP)<p>This leaves the question, why the indirection and why the mucking around with ARP and IPs that are never used as the destination to anything?<p>Couldn't you simply put the next hop's MAC address (instead of IP address) into the routing table and be able to route packets just as well, with a lot less complexity?
Hi, I'm the author. Uh hi w00t how why what's it doing here?! :D<p>I promise to make it better and actually finish it now! Check back in a day or two I guess? Also I should post the code I promised. Hello from the ADHD squirrel!
I would suggest expanding your terminology section. I know almost nothing about routers and I'm lost in the first sentence of the High Level Overview section.<p><pre><code> "A switch (or an L2 switch :-) ) is an L2-only thing."
</code></pre>
I don't know what L2 means. I suspect a definition of the various levels would expand the audience for this post.
Maybe a mention of other, non-ethernet, links. Serial PPP? Frame Relay? I realize these are mostly historical curiosities these days, but it might help to enforce the differences between L2 and L3.<p>When I first started working with routers, over 25 years ago, it was all ethernet LAN to serial WAN, usually point-to-point T1 or frame relay. On site had a <i>dual</i> T1, load balanced on both ports of a Cisco 2501. Fun times.
I learned a lot about networking when setting up servers in racks. Had to deal with issues arising from terrible UI's on a lot of the routers out there, so I just kept digging deeper and deeper into how it all works. Also, if more are looking into how packets are actually routed, look into BGP, and how CDN's work. Great stuff.
I believe this piece does a good job with forwarding, but would be improved by a discussion of termination.<p>Routing is only triggered when the packet is L2 terminated: the destination MAC of the packet is one of the router's own MACs.<p>If the packet's destination MAC does not belong to the router, it doesn't matter what is in its IP header, it will be switched in the LAN it came in on.<p>This design also generalizes nicely to the case when the destination IP of a routed packet is one of the router's IPs.
I teach computer networking class with lab using Linux Switch Appliance (LISA) and Quagga router (based on Zebra) on embedded computer running x86 CPU with multi-port Ethernet. The embedded router need to be dual-boot for its specific function because LISA is based on custom Linux kernel but Quagga is just using normal/vanilla kernel.<p>I am looking for a "layer 3 switch" than has switching and routing functionalities without rebooting. If anyone know any software based open source solution for this it will be very helpful. Preferably with Cisco IOS like user command interface but it is optional but not mandatory.<p>Based on the article, it is explaining router internal based on P4. Perhaps I should try to use P4 for the above mentioned requirements?
>"It needs to be routed: the router, based on L3 information, decides where it needs to go ,in L3 speak – it will decide which host to send it to, but not how. This corresponds to the routing table (or FIB)."<p>This is not correct. The FIB(forwarding information base) is concerned with layer 2. The RIB(routing information base) determines the next hop. The RIB is what is used to populate entries in the FIB with the correct outgoing interface. These two terms are basic router terms. It was kind of surprising to see this statement in a post titled "How Do Routers Work, Really?"
Click is a very good software router to read and learn: <a href="https://github.com/kohler/click" rel="nofollow">https://github.com/kohler/click</a><p>It can be more than a router though.
this is great if for no other reason that in section 1 it explains the difference between a switch and a router (which took me a decade? to really understand). I really wish someone could have laid it out clearly for me.