On Fri, 10 Dec 1999, Denis J. Cirulis wrote: > I'm wondering is there any HOWTO on routing or maybe someone can > explain me how does it works. I must mension that i'm do not planning > to use RIP or OSPF routing protocols i want to know everything that is > interconnected with static routing table.
Routing is surprisingly simple, that's why the Internet works so well. All TCP/IP stacks do some kind of routing. When an application wants to send a packet, it delivers the packet to the kernel. The kernel treats all packets the same way. The only difference is that routers will forward packets to other hosts, whereas a system that is not a router will not. Packets are, for the most part, actually routed to networks, not individual hosts. A route contains the gateway, network address and the netmask. The netmask is a way of explaining how many hosts are at that network address. For example, a network address 129.35.24.0 with a netmask of 255.255.255.0 will include all addresses from 129.35.24.0 to 129.35.24.255. But if the netmask were 255.255.255.240, then it would only include addresses from 129.35.24.0 to 129.35.24.15. The gateway is the system (which must be on the same network) which handles packets for that particular route. All data going to that route is sent through this particular gateway. First, of course, the kernel checks to see if it's the destination for the packet. Assuming it's not, and that forwarding is enabled, then it goes on to the next steps. The kernel looks through its routing table to see if there is an explicit route to the destination host. If the host is on the same subnet, this will always be the case. Sometimes there is an explicit route to a host on a different subnet. If there is, the system uses that route, if not, it uses the default route. But an explicit route does not mean that the router is directly connected to the destination, or its network. It doesn't even mean that it knows the exact path that the packet will travel to reach it. It just means that it knows which of the gateways that it connects to is the "closest" to the destination. Whether there is an explicit route or not, the sending system behaves the same way, it just controls where the packet is sent. The transmitting system sends the packet to the gateway host for that route, with information about what the destination actually is. It then becomes the problem of the gateway host and the transmitting host forgets about it. A gateway host works by having network interfaces (this can be ethernet, PPP over a modem, or an interface to a T1, or a frame relay, or whatever) on more than one network. Each of its interfaces has a distinct IP address on the network it connects to. The gateway host looks in its routing table to see if it has an explicit route for the destination of the packet. If so, it sends it according to that explicit route. If not, most routers have a default route of their own that they send the packet to. Sooner or later the packet will reach a gateway that knows an explicit route for it. Some very large routers contain explicit routes for almost every subnet on the Internet, of which there are millions. In this way it is possible for a packet to pass through many routers on its way to the destination.