There are a bunch of tutorials out there on how to build your own router based on Linux or one of the BSDs. I’d recommend such a tutorial as a good starting point for a top-down view.
The lower-level is very visible through Wireshark, with which you can capture all network traffic.
Most universities with computer science have courses in networking, which usually includes programming a router. I’m sure some courses are available online
Also search for tap & tun based tutorials. Make sure to be ready to read tons of RFCs in the area of neighbor discovery, path finding in graph , and parsing
The lower-level is very visible through Wireshark, with which you can capture all network traffic.
Does that help?