A router will have at least two network cards and be connected to at least two networks. A router will merely forward IP datagrams between networks. This forwarding is known as routing.
Repeaters and Bridges
Before looking at routers it is worth reviewing other technology for interconnecting physical networks. With thick Ethernet a length of cable ( a segment) can be a maximum of 500m in length. To overcome this restriction repeaters may be used. A repeater just amplifies a signal. A repeater sits at layer 1.
Note: that repeaters are "invisible" to TCP/IP.
The TCP/IP protocols have no knowledge of the presence or otherwise of repeaters. The problem with repeaters is that as well as increasing the length of an Ethernet LAN they can also increase the traffic on the LAN resulting in performance problems.
Bridges overcome the problems of repeaters. Bridges sit a layer 2 in the OSI/RM. Bridges still connect physical LAN segments to form a single logical LAN. Bridges therefore deal with frames rather than individual bits.
Bridges can obtain source and destination addresses from frame headers. Using these addresses a bridge can determine where workstations are in terms of which side of the bridge a workstation is. Once a bridge knows where a workstation and it sees a frame is going to that workstation the bridge can decide whether the frame needs to be passed on to the other side of the bridge. The net result is that a bridge will filter traffic allowing multiple traffic on a single Ethernet LAN.
Note: that bridges are not just for Ethernet.
The basic rule is that only similar networks can be bridged. For example Ethernet can not be bridged to X.25
Note: however that a feature of IEEE 802 LANs is that they share a common Logical Link Control Layer - IEEE 802.2
This means that bridging is possible between, say Ethernet (802.3) and Token Ring(802.5). The presence of bridges can have a marked effect on performance. As with repeaters bridges are invisible to TCP/IP. The bridge creates the illusion of a single network to the higher layers.
Bridges can be used to connect geographically remote LANs together. In this case two bridges would sit connected to their respective LANs. The bridges would be connected via a leased line or fibre optic link.
Routers and Gateways
A router is used to connect two physically separate networks. The router will forward packets on between these networks. Routers sit at layer three in the OSI/RM. This means that they are protocol dependent. This is because with TCP/IP it is IP which decides the routing to be done.
There are number of IP routers on the market. One of the decisions to make is whether to use normal hosts as your routers or to use dedicated routers. Note that the TCP/IP documentation often refers to routers as gateways. Gateways in OSI terminology convert protocols at layers above layer 3. A good example would be a mail gateway, for example converting smtp mail formats into X.400 formats.
How Indirect Routing Works
Previous to the chapter we have seen how when two hosts communicate ARP is used to determine the physical address of the destination host. This is sometimes referred to as direct routing.
Before a host will send an IP datagram the IP address is studied. The net id of the destination IP address is compared to our local net id. If they are the same then IP knows that no routing is required and that the datagram can be sent using the direct routing method where ARP will find the physical address of the destination host.
Routing will be used if when the destination and source addresses are compared they are found to be different. If this is the case the routing table of the host will be used to find the intermediate destination of this datagram.