|
|
A Workstation's Routing Table
Return to Networking Basics Home Page.
Introduction
Every machine on your network with a TCP/IP stack has a configuration setting for a gateway. This is so that it can reach IP networks other than its own. When it detects that the destination is part of a remote network, it sends the packet to the gateway for forwarding. For destinations in the same subnet, it will send the packet directly to the other machine. How does a workstation determine if a destination is part of the same or a different IP network?First it ANDs the destination address of the packet with its own subnet mask. If the resulting address matches its own network mask, then the destination is in the same subnet, and the TCP/IP stack tells the card to send the packet directly to the destination machine. (Actually, more than this occurs in order to send the packet directly, but it's no longer part of TCP/IP, but Ethernet.) If, however, the calculation shows that the destination is part of another network, then the sender makes use of its gateway to transmit the packet. In effect, the sender is saying, "I do not know how to deliver this packet; can you please deliver it for me?" The gateway accepts the packet and then goes through a similar procedure. (That procedure is known as routing.)
Here are a few examples of the workstation's decision-making process.
Workstation IP Address Network/Netmask Gateway A 192.168.16.4 192.168.16.0/22 192.168.16.1 B 192.168.17.20 192.168.16.0/22 192.168.16.1 C 192.168.30.4 192.168.30.0/24 192.168.30.1 Example 1 - Workstation A sends to Workstation B
Workstation A knows its own network address/subnet mask is 192.168.16.0/22. Workstation A calculates the local-subnettedness of the destination packet as follows:Example 2 - Workstation C sends to Workstation B
Are A and B in the same subnet? bitwise-AND 11111111 . 11111111 . 11111100 . 00000000
11000000 . 10101000 . 00010001 . 00010100subnet mask of A
IP addr of dest (B)11000000 . 10101000 . 00010000 . 00000000 network of dest compare 11000000 . 10101000 . 00010000 . 00000000 network of A They are equal - Both Workstations are on the network 192.168.16.0 Because the network address of the sender matches the result of this calculation, the packet is sent directly to machine B.
Workstation C knows its network address/subnet mask is 192.168.30.0/24. Machine C checks to see if the destination packet falls within its subnet.
Are A and B in the same subnet? bitwise-AND 11111111 . 11111111 . 11111111 . 00000000
11000000 . 10101000 . 00010001 . 00010100subnet mask of C
IP addr of dest (B)11000000 . 10101000 . 00010001 . 00000000 network of dest compare 11000000 . 10101000 . 00011110 . 00000000 network of C They ARE NOT equal - 192.168.17.0 < not equal to > 192.168.30.0 In this case, the comparison fails. The sender, C, has no choice but to send packet to its gateway. (If you take the time to do the calculation, you discover the gateway is in machine C's subnet. In fact the gateway must always be in the sender's subnet; otherwise, the sender could not send to it either!)
A Workstation's Routing Table