| Destination | Interface | Cost |
| A | X | 5 |
| B | Y | 19 |
| A | Z | 7 |
In the above example, all packets to A would be routed through interface X. With a different routing table, in which the third entry had cost 5, packets for A could be routed through either interface X or Z. If the route through X is removed, the route through Z can still be used.
The purpose of a routing protocol is to automatically build such routing tables.
A "Hello" protocol is used to discover our neighbors in the network graph. Generally, "Hello" packets are sent broadcast out on each interface. Any routers that respond are considered our neighbor. "Hello" packets are sent out regularly, and can be used to discover when a neighbor has gone down as well as when a neighbor becomes accessible.
| Destination | Interface | Cost |
| A | X | 3 |
| B | Y | 8 |
| C | Z | 2 |
| D | H | 5 |
| E | X | 18 |
| E | Y | 15 |
In distance-vector, when a link on an optimal route goes down, it may take a while for the other nodes in the route to discover that this route is no longer optimal. For example, if the link to from G to E goes down, B will tell G that it has a route to F with cost (distance) 3. G can then tell B that it has a route of cost 4. Since B's route to F goes through G, B will increase its distance to 5. That is still better than the other route that node C has to F, so it will keep sending packets to B, which sends packets to G, which sends the packets back to B. This continues until finally the distance-vector algorithm converges to the correct solution -- lowest cost route from C to E is via D, at a cost of 17.
The whole process takes time, and while it is converging, the network will not deliver packets from A to F.
On a network with delay 2s, capable of carrying 10Mb/s, the bandwidth-delay product is 20Mb or 2.5MB.
This means I can send 2.5MB, and stop sending, and the receiver hasn't yet seen any of the data.
Where is the data?
It is being stored by the network.
If that is too much data for the receiver, even if the receiver were to tell me when it gets the first bit of data, that 2.5MB is still in transit and will be delivered to the receiver. So a large bandwidth-delay product (seen, for example, on high-speed, high-latency satellite links) makes it harder to control traffic flow.
We can control the flow of data via windows. If the window size is one packet, the protocol is stop-and-wait: send a packet, wait for the ACK, send the next packet (TFTP does this).
The window size interacts with the round-trip time to determine the maximum speed of the sender. In this case the effective throughput given a window W = n bytes, and a RTT t = s seconds, is at most throughput \lt;= n * 8 / s (* 8 to convert bytes to bits).
For example, if W = 1000 bytes, and the RTT = 1s, the throughput is at most 8000 b/s.
Open Systems Interconnect (standardized by the ISO) is a model for describing protocols. Some protocols fit this model quite well, e.g. IP, and some straddle layers, e.g. TCP and ATM.
The routers only need the physical, data-link, and network layers to transport data (they may need other layers when implementing the routing protocols). The data-link and physical layers of different interfaces may be different -- for example, one interface may be ATM, the other interface may be Ethernet.
Conceptually, a protocol on one layer only talks to its peer(s) on the same layer. To do so, it uses the protocol on the layer immediately below it. The protocol also provides a service to the layer immediately above it.
One subtlety of this model is that all the network layers must be the same. That is because all the network layers must talk to each other in order to forward the packet end-to-end. In the Internet, this layer is the IP layer.
Reassembly might be needed because the different interfaces of a router might have very different MTUs, for example 4096 for FDDI, 1500 for Ethernet, 1024 for SLIP. On unixes the command ifconfig -a generally shows all configured interfaces.
The leftmost n bits of an IP address constitute the network part, and the remaining 32 - n bits are the host part of the address. To specify which is which, we give a network mask, which has "1" bits for each bit of the address that is in the network part, and "0" bits for each bit of the address that is in the host part. An example of a network mask is 1111 1111 1111 1111 0000 0000 0000 0000, which we usually write as 255.255.0.0. This network mask specifies n = 16, meaning the leftmost 16 bits of the address are the network part, and the rightmost 16 bits of the address are the host part.
Other masks might be 255.255.255.0 (n = 24), 255.255.255.128 (n = 25), 255.255.255.192 (n = 26), 255.255.255.224 (n = 27), 255.255.255.240 (n = 28), and so on.
For example, given an IP number of 128.171.111.222 and a network mask of 255.255.255.128, the network number is the bitwise logical AND of these two, or 128.171.111.128.
Internet routers only store routes to destination networks, not to individual hosts. For each destination, they must store both an IP address and a network mask.
| Destination | Mask | Interface | Cost |
| A1 | M1 | I1 | cost1 |
| A2 | M2 | I2 | cost2 |
| A3 | M3 | I3 | cost3 |
| ... | ... | ... | ... |
| An | Mn | In | costn |
Given the above routing table, and an IP packet with destination address
A, how do we find out if we have a route to A?
Algorithm: for each routing table entry i, consider whether:
A AND Mi = Ai AND Mi
If the two expressions are equal, then the network part of the address
is the same as the network part of the routing table destination, and
the route matches and can be used for this packet.
In general, more than one route may match -- if so, and they have masks with different numbers of 1s, we usually choose the one with the longest mask (the mask with the most "1" bits).
There are ways to sort the table to make the search more efficient than in the above serial search algorithm.