Methods for populating the routing table. Network routing

An article about the routing table is a topic that was promised about four years ago. In fact, I should have written about it a long time ago, but I couldn’t decide and only now I’m trying.

Manipulating the routing table allows you to fine-tune the operation of your . Most often this is not necessary, but sometimes you need to do something unusual, especially when there are several adapters on the computer, and then you have to take on the routing tables.

Viewing the routing table

Here is the output of the route print command on my desktop computer:

Network address Network mask Gateway address Interface Metrics
0.0.0.0 0.0.0.0 192.168.1.1 192.168.1.100 20
127.0.0.0 255.0.0.0 On-link 127.0.0.1 306
127.0.0.1 255.255.255.255 On-link 127.0.0.1 306
127.255.255.255 255.255.255.255 On-link 127.0.0.1 306
192.168.1.0 255.255.255.0 On-link 192.168.1.100 276
192.168.1.100 255.255.255.255 On-link 192.168.1.100 276
192.168.1.255 255.255.255.255 On-link 192.168.1.100 276
244.0.0.0 240.0.0.0 On-link 127.0.0.1 306
244.0.0.0 240.0.0.0 On-link 192.168.1.100 276
255.255.255.255 255.255.255.255 On-link 127.0.0.1 306
255.255.255.255 255.255.255.255 On-link 192.168.1.100 276

This is how we can view the routing tables. Let's try to describe what all this means. Each line specifies where to send which packets. That is, a network route is created for the range specified by the values ​​in the “network address” and “network mask” columns. For example, the address 192.168.0.1 and the mask 255.255.255.0 means that the range 192.168.0.* is in mind. The mask always looks like 255 at the beginning, zero at the end, and last non-zero number maybe a power of two minus one. For example, for the mask 255.255.127.0 and the same address 192.168.0.1, the range will be slightly wider, it will also include addresses like 192.168.1.*. To describe this more accurately, we need to represent all the numbers in binary form, but this is not the purpose of the article.

So, if we have decided on a range, we must understand where the computer will send packets if they are destined for addresses in this range. Let's start with the fourth column. It determines the adapter to which packets should be sent. For example, in in this case, it contains 192.168.1.100 - this is the address of my network card and 127.0.0.1 - the so-called loopback. The computer will not even try to send packets “to this adapter” anywhere. If I had another card active, for example, WiFi, then its address would appear in the fourth column.

The third column defines the "gateway" - the router to which these packets need to be sent. When it says “On-link”, it means that no routers are needed - the address is already within direct reach. The last column is the metric. It determines the preference for a route when there are options. Rows with the lowest metric are preferred when ranges match.

So, let's look at the described routes. In fact, the most important line in this case is the first line. She says that for any address (address 0.0.0.0 with a mask 0.0.0.0 specifies the full range) there is a route using my network card, and these packets can be directed to 192.168.1.1. The last address is mine, which explains everything. Any address that the computer cannot find somewhere nearby will be sent to the router and left to deal with it.

Let's talk about the rest. The three lines about 127 are system ones, due to the fact that these addresses must always be returned to the computer itself. Addresses in the range 192.168.1.* are the local network, 192.168.1.100 is our address in general, 192.168.1.255 is a special address for broadcast packets in local network. Addresses 244.0.0.0 are also special fixed addresses for broadcasting, and the last two lines are determined by the adapters themselves.

But this case is rather uninteresting. Let's look at the table on my router. The appearance will be slightly different, since it is Linux, and I display the corresponding tables with the route -n command.

DestinationGatewayGenmaskFlagsMetricRefUseIface
10.0.20.43 0.0.0.0 255.255.255.255 UH0 0 0 ppp0
192.168.1.0 0.0.0.0 255.255.255.0 U0 0 0 br0
10.22.220.0 0.0.0.0 255.255.255.0 U0 0 0 vlan1
10.0.0.0 10.22.220.1 255.224.0.0 U.G.0 0 0 vlan1
127.0.0.0 0.0.0.0 255.0.0.0 U0 0 0 lo
0.0.0.0 10.0.20.43 0.0.0.0 U.G.0 0 0 ppp0

Let's immediately note that the columns have changed a little. We will not dwell on all of them; the last column that has been significantly changed is the last one - instead of the adapter’s IP address, we indicate its name. Here lo is a “loop” (do not send anywhere), br0 is an internal network, ppp0 is an external one, vlan0 is an established VPN connection. So, let's look at the lines. Also in the column with flags, the letter G means Gateway - gateway, and H - Host, our computer.

The last line is the default gateway. We can send any package to the address 10.0.20.43. What's interesting is that this is ours own address, obtained with VPN installation- connections! This is how it always happens when a VPN connection is established, the packet is first sent to its virtual interface, where it is encapsulated in another packet that will go to the real gateway. Naturally, this is not visible in the routing tables. The first line also applies to the description of this connection.

We see the real gateway in the third line - addresses in the range 10.22.220.* are sent to vlan1, the gateway provided by the provider, the communicator with which we are connected network cable directly. The second line says that addresses in the 192.168.1.* range are a local network, and packets to them should be sent internally, not externally. Fifth - the usual information about "local addresses".

Routing Table Commands

I didn't say anything about the penultimate line. And it’s the most interesting, because I added it with my own hands. What is its meaning? I send addresses in the range 10.1-32.*.* to gateway 10.22.220.1. Packets to these addresses will not go to the Internet, but will remain in the provider’s local area. Yes, packages for the range 10.22.220. and so they go there, but this is not enough. This way I don’t get full access to local resources.

IN Windows case such a route would be added to the routing tables with the command route -p add 10.0.0.0 mask 255.224.0.0 10.22.220.1. -p means that the route is permanent, it should not be deleted after rebooting the computer.

The article is already much longer regular articles of this blog, so I'll call it a day. Write your questions here, and if you want to look into some specific configuration cases, it’s better to contact us on our forum.

Or gateway, is a network node with several IP interfaces (containing its own MAC address and IP address) connected to different IP networks, which, based on solving the routing problem, redirects datagrams from one network to another for delivery from the sender to the recipient.

They are either specialized computing machines, or computers with several IP interfaces, the operation of which is controlled by special software.

Routing in IP networks

Routing is used to receive a packet from one device and forward it across the network to another device via other networks. If there are no routers on the network, then routing is not supported. Routers route (forward) traffic to all networks that make up the internetwork.

To route a packet, the router must have the following information:

  • Destination address
  • A nearby router from which it can learn about remote networks
  • Available paths to all remote networks
  • The best path to each remote network
  • Methods for maintaining and checking routing information

The router learns about remote networks from neighboring routers or from network administrator. The router then builds a routing table that describes how to find remote networks.

If the network is connected directly to the router, it already knows how to route the packet to that network. If the network is not directly connected, the router must find out (learn) access paths to the remote network using static routing (the administrator manually enters the location of all networks into the routing table) or using dynamic routing.

Dynamic routing is a routing protocol process that determines how a device communicates with neighboring routers. The router will update information about each network it learns. If a change occurs in the network, the dynamic routing protocol automatically informs all routers of the change. If static routing is used, the system administrator will have to update the routing tables on all devices.

IP routing is a simple process that is the same on networks of any size. For example, the figure shows the process of step-by-step interaction between host A and host B on another network. In the example, the user of host A requests the IP address of host B by ping. Further operations are not so simple, so let’s look at them in more detail:

  • IN command line the user enters ping 172.16.20.2. On host A, a packet is generated using network layer protocols and ICMP.

  • IP calls ARP to find out the destination network for the packet by looking at the IP address and subnet mask of host A. This is a request to to remote host, i.e. the packet is not destined for the local network host, so the packet must be sent to the router to be forwarded to the desired remote network.
  • In order for host A to send a packet to the router, the host must know the hardware address of the router interface connected to the local network. The network layer passes the packet and hardware destination address to the data link layer to be divided into frames and forwarded to the local host. To obtain a hardware address, the host looks up the location of the destination in own memory called the ARP cache.
  • If the IP address has not yet been reached and is not present in the ARP cache, the host sends an ARP broadcast to look up the hardware address at IP address 172.16.10.1. This is why the first Ping request will usually time out, but the other four requests will succeed. Once an address is cached, there is usually no timeout.
  • The router responds and reports the hardware address of the Ethernet interface connected to the local network. The host now has all the information to forward the packet to the router over the local network. The network layer passes the packet down to generate an ICMP echo request (Ping) at the data link layer, appending the packet with the hardware address to which the host should send the packet. The packet has source and destination IP addresses along with an indication of the packet type (ICMP) in the network layer protocol field.
  • The link layer forms a frame in which the packet is encapsulated along with management information required for forwarding over a local network. This information includes the source and destination hardware addresses, as well as the value in the type field, established by the protocol network layer (this will be a type field since IP uses Ethernet_II frames by default). Figure 3 shows a frame generated at the link layer and forwarded over the local media. Figure 3 shows all the information needed to communicate with the router: source and destination hardware addresses, source and destination IP addresses, data, and check sum Frame CRC, located in the FCS (Frame Check Sequence) field.
  • Host A's link layer transmits the frame physical level. There, zeros and ones are encoded into a digital signal and then transmitted over a local physical network.

  • The signal reaches Ethernet interface 0 of the router, which is synchronized by the preamble digital signal to extract the frame. After constructing the frame, the router interface checks the CRC, and at the end of receiving the frame, compares the received value with the contents of the FCS field. In addition, it checks the transfer process for media fragmentation and conflicts.
  • The destination hardware address is checked. Since it matches the router address, the frame type field is analyzed to determine further actions with this data package. The type field specifies the IP protocol, so the router passes the packet to the IP protocol process running on the router. The frame is deleted. Source package(generated by host A) is placed in the router buffer.
  • The IP protocol looks at the destination IP address in the packet to determine whether the packet is destined for the router itself. Since the destination IP address is 172.16.20.2, the router determines from its routing table that network 172.16.20.0 is directly connected to Ethernet interface 1.
  • The router forwards the packet from the buffer to Ethernet interface 1. The router needs to frame it to forward the packet to the destination host. The router first checks its ARP cache to determine whether the hardware address has already been resolved during previous interactions with the given network. If the address is not in the ARP cache, the router sends an ARP broadcast request to Ethernet interface 1 to look up the hardware address for IP address 172.16.20.2.
  • Host B responds with the hardware address of its network adapter to an ARP request. The router's Ethernet 1 interface now has everything it needs to forward the packet to its final destination. The figure shows a frame generated by the router and transmitted over the local physical network.

The frame generated by the router's Ethernet 1 interface has a source hardware address from Ethernet interface 1 and a destination hardware address for the host B network adapter. It is important to note that, despite changes in the source and destination hardware addresses, on each router interface that sent the packet, the IP addresses source and destination never change. The package is not modified in any way, but the frames are changed.

  • Host B receives the frame and checks the CRC. If the check is successful, the frame is discarded and the packet is transferred to the IP protocol. It analyzes the destination IP address. Since the destination IP address is the same as Host B's configured address, the IP protocol examines the protocol field to determine the destination of the packet.
  • Our packet contains an ICMP echo request, so host B generates a new ICMP echo reply with a source IP address equal to host B and a destination IP address equal to host A. The process starts again, but in opposite direction. However, the hardware addresses of all devices along the packet's path are already known, so all devices will be able to obtain the hardware addresses of the interfaces from their own ARP caches.

In large networks, the process is similar, but the packet will have to travel more hops on the way to the destination host.

Routing tables

In the TCP/IP stack, routers and end nodes make decisions about who to pass a packet to in order to successfully deliver it to the destination node, based on so-called routing tables.

The table represents typical example a route table using network IP addresses for the network shown in the figure.

Routing table for Router 2

The table shows a multi-route routing table, since it contains two routes to network 116.0.0.0. In the case of constructing a single-route routing table, it is necessary to specify only one path to network 116.0.0.0 based on the lowest metric value.

As you can easily see, several routes are defined in the table with different parameters. You need to read each such entry in the routing table as follows:

To deliver a packet to the network with an address from the Network Address field and a mask from the Network Mask field, you need to send a packet from the interface with the IP address from the Interface field to the IP address from the Gateway Address field, and the “cost” of such delivery will be equal to the number from the field Metrics.

In this table, the "Destination Network Address" column indicates the addresses of all networks to which this router can transmit packets. The TCP/IP stack adopts the so-called one-hop approach to optimizing the packet forwarding route (next-hop routing) - each router and end node takes part in choosing only one packet transmission step. Therefore, each line of the routing table does not indicate the entire route as a sequence of IP addresses of the routers through which the packet must pass, but only one IP address - the address of the next router to which the packet must be transmitted. Along with the packet, responsibility for choosing is transferred to the next router next step routing The one-hop approach to routing means a distributed solution to the route selection problem. This removes the restriction on maximum amount transit routers along the packet's path.

To send a packet to the next router, knowledge of it is required local address, but in the TCP/IP stack it is customary to use only IP addresses in routing tables to store them universal format, independent of the type of networks included in the Internet. To find a local address from a known IP address, you must use the ARP protocol.

One-hop routing has another advantage - it allows you to reduce the size of routing tables in end nodes and routers by using the so-called default route (0.0.0.0) as the destination network number, which usually occupies the routing table last line. If there is such an entry in the routing table, then all packets with network numbers that are not in the routing table are sent to the router specified in the default line. Therefore, routers often store in their tables limited information about internet networks by forwarding packets for other networks to the default port and router. The default router is assumed to forward the packet to backbone network, and routers connected to the backbone have full information about the composition of the Internet.

In addition to the default route, there may be two types of special entries in the routing table - an entry about a host-specific route and an entry about the addresses of networks directly connected to the router ports.

A host-specific route contains a full IP address instead of a network number, that is, an address that has non-zero information not only in the network number field, but also in the host number field. It is assumed that for such an end node the route should be chosen differently from all other nodes in the network to which it belongs. In the case when the table contains different entries about the promotion of packets for the entire network N and its individual node, which has address N,D, upon arrival of a packet addressed to node N,D, the router will give preference to the entry for N,D.

Entries in the routing table related to networks directly connected to the router contain zeros (“connected”) in the “Metrics” field.

Routing Algorithms

Basic requirements for routing algorithms:

  • accuracy;
  • simplicity;
  • reliability;
  • stability;
  • justice;
  • optimality.

There are various algorithms for constructing tables for one-hop routing. They can be divided into three classes:

  • simple routing algorithms;
  • fixed routing algorithms;
  • adaptive routing algorithms.

Regardless of the algorithm used to build the routing table, the result of their work has a single format. Due to this, in the same network, different nodes can build routing tables according to their own algorithms, and then exchange missing data with each other, since the formats of these tables are fixed. Therefore, a router using an adaptive routing algorithm can provide an end node using a fixed routing algorithm with path information to a network that the end node knows nothing about.

Easy routing

This is a routing method that does not change when the topology and state of the data transmission network (DTN) changes.

Simple routing is provided various algorithms, typical of which are the following:

  • Random routing is the transmission of a message from a node in any randomly selected direction, with the exception of the directions in which the message was received by the node.
  • Flooding routing is the transmission of a message from a node in all directions except the direction in which the message arrived at the node. This routing guarantees short packet delivery time, at the expense of throughput degradation.
  • Routing based on previous experience - each packet has a counter for the number of nodes passed, in each communication node the counter is analyzed and the route that matches is remembered minimum value counter. This algorithm allows you to adapt to changes in network topology, but the adaptation process is slow and ineffective.

In general, simple routing does not provide directional packet transmission and has low efficiency. Its main advantage is to ensure stable operation of the network in case of failure various parts networks.

Fixed Routing

This algorithm is used in networks with a simple connection topology and is based on the manual compilation of a routing table by the network administrator. The algorithm often works effectively also for backbones of large networks, since the backbone itself may have simple structure with obvious the best ways The following algorithms distinguish packets in subnets connected to the backbone:

  • Single-path fixed routing is when a connection is established between two subscribers the only way. A network with such routing is unstable to failures and overloads.
  • Multi-path fixed routing - several can be installed possible ways and a path selection rule is introduced. The efficiency of such routing decreases as the load increases. If any communication line fails, it is necessary to change the routing table; for this purpose, several tables are stored in each communication node.

Adaptive Routing

This is the main type of routing algorithm used by routers in modern networks with complex topology. Adaptive routing is based on the fact that routers periodically exchange special topological information about the networks available on the Internet, as well as about the connections between routers. Usually, not only the topology of links is taken into account, but also their capacity and condition.

Adaptive protocols allow all routers to collect information about the topology of connections in the network, quickly processing all changes in the connection configuration. These protocols are distributed in nature, which is expressed in the fact that there are no dedicated routers in the network that would collect and summarize topological information: this work is distributed among all routers, the following algorithms are distinguished:

  • Local adaptive routing - each node contains information about the link state, queue length and routing table.
  • Global adaptive routing is based on the use of information received from neighboring nodes. To do this, each node contains a routing table, which indicates the transit time of messages. Based on information received from neighboring nodes, the table value is recalculated taking into account the queue length in the node itself.
  • Centralized adaptive routing - there is some central node that collects information about the state of the network. This center generates control packets containing routing tables and sends them to communication nodes.
  • Hybrid adaptive routing is based on the use of a table periodically sent by the center and on analyzing the queue length from the node itself.

Algorithm indicators (metrics)

Routing tables contain information that switching programs use to select best route. What characterizes the construction of routing tables? What is the nature of the information they contain? IN this section, dedicated to the performance of algorithms, an attempt is made to answer the question of how an algorithm determines the preference of one route over others.

Routing algorithms use many different metrics. Complex routing algorithms can rely on multiple metrics when selecting a route, combining them in such a way that the result is one hybrid metric. The following are the metrics used in routing algorithms:

  • Route length.
  • Reliability.
  • Delay.
  • Bandwidth.

Route length.

Route length is the most common routing metric. Some routing protocols allow network administrators to assign arbitrary prices to each network link. In this case, the path length is the sum of the costs associated with each channel that was traversed. Other routing protocols define a "hop count," a metric that describes the number of trips a packet must make on its way from its source to its destination through network aggregation elements (such as routers).

Reliability.

Reliability, in the context of routing algorithms, refers to the reliability of each link in the network (usually described in terms of bit-to-error ratio). Some network links may fail more often than others. Failures of some network links can be resolved more easily or quickly than failures of other links. When assigning reliability ratings, any reliability factors can be taken into account. Reliability ratings are typically assigned to network channels by administrators. As a rule, these are arbitrary digital values.

Delay.

Routing latency typically refers to the length of time it takes for a packet to travel from its source to its destination across an internetwork. Latency depends on many factors, including the bandwidth of the intermediate links in the network, the queues at the port of each router along the packet's path, network congestion on all intermediate links in the network, and the physical distance over which the packet must travel. Because there is a conglomeration of several important variables, latency is the most common and useful metric.

Bandwidth.

Bandwidth refers to the available traffic capacity of any link. All other things being equal, a 10 Mbps Ethernet channel is preferable to any leased line with a 64 KB/s bandwidth. Although bandwidth is an estimate of the maximum achievable capacity of a link, routes passing through links with higher bandwidth will not necessarily be better routes passing through slower channels.

The structure of the actual routing tables of the TCP/IP stack generally corresponds to the simplified structure of the tables discussed earlier. Note, however, that the appearance of the IP routing table depends on the specific implementation of the TCP/IP stack. Let's give an example of several routing table options that router R1 could work with in the network shown in Fig. 1.

Let's start with an “invented” extremely simplified version of the routing table (Table 1). There are three routes to networks (entries 56.0.0.0, 116.0.0.0, and 129.13.0.0), two entries for directly connected networks (198.21.17.0 and 213.34.12.0), and a default route entry.

Table 1. Simplified routing table for router R1

Destination network address Next router address Output interface address Distance to destination network
15
13
2
1 (connected)
1
56.0.0.0 213.34.12.4 213.34.12.3 15
116.0.0.0 213.34.12.4 213.34.12.3 13
129.13.0.0 198.21.17.6 198.21.17.5 2
198.21.17.0 198.21.17.5 198.21.17.5 1(connected)
213.34.12.0 213.34.12.3 213.34.12.3 1(connected)
Default route 198.21.17.7 198.21.17.5 -

More complex look have tables that are generated in commercially available network equipment.

If we imagine that the standard software router of the operating room operates as router R1 in this network Microsoft systems Windows XP, then its routing table could look like table. 2.

Rice. 1 Example of a routed network

Table 2. Windows XP software router table

Network address Mask Gateway address Interface Metrics
127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1 1
0.0.0.0 0.0.0.0 198.21.17.7 198.21.17.5 1
56.0.0.0 255.0.0.0 213.34.12.4 213.34.12.3 15
116.0.0.0 255.0.0.0 213.34.12.4 213.34.12.3 13
129.13.0.0 255.255.0.0 198.21.17.6 198.21.17.5 2
198.21.17.0 255.255.255.0 198.21.17.5 198.21.17.5 1
198.21.17.5 255.255.255.255 127.0.0.1 127.0.0.1 1
198.21.17.255 255.255.255.255 198.21.17.5 198.21.17.5 1
213.34.12.0 255.255.255.0 213.34.12.3 213.34.12.3 1
213.34.12.3 255.255.255.255 127.0.0.1 127.0.0.1 1
213.34.12.255 255.255.255.255 213.34.12.3 213.34.12.3 1
224.0.0.0 224.0.0.0 198.21.17.6 198.21.17.6 1
224.0.0.0 224.0.0.0 213.34.12.3 213.34.12.3 1
255.255.255.255 255.255.255.255 198.21.17.6 198.21.17.6 1

If you install one of the popular hardware routers in place of router R1, then its routing table for the same network may look completely different (Table 3).

Table 3. Routing table hardware router

And finally table. 4 is a routing table for the same router R1, implemented as a software router of one of the versions operating system Unix.

Table 4. Unix router routing table

Destination address Gateway Flags Interface
127.0.0.0 127.0.0.1 UH 1 154 1o0
Default route 198.21.17.7 U.G. 5 43270 1e0
198.21.17.0 198.21.17.5 U 35 246876 1e0
213.34.12.0 213.34.12.3 U 44 132435 le1
129.13.0.0 198.21.1.7.6 U.G. 6 16450 1e0
56.0.0.0 213.34.12.4 U.G. 12 5764 le1
116.0.0.0 213.34.12.4 U.G. 21 23544 le1

NOTE
Note that since there is no one-to-one correspondence between the network structure and the routing table, for each of the above table options you can offer your own “sub-options” that differ in the chosen route to a particular network. In this case, attention is focused on significant differences in the form of presentation of routing information by different implementations of routers.

Despite quite noticeable external differences, all three “real” tables contain all the key data from the considered simplified table, without which packet routing is impossible.

Such data, firstly, includes destination network addresses (the “Destination Address” columns in a hardware router and Unix router or the “Network Address” column in a Windows XP router).

Second required field The routing table is the address of the next router (the “Gateway” columns in a hardware router and Unix router or the “Gateway Address” column in a Windows XP router).

The third key parameter, the port address to which the packet should be sent, is indicated directly in some tables (the “Interface” column in the Windows XP router table), and in some - indirectly. So, in the Unix router table, instead of the port address, its conditional name is set - 1e0 for the port with the address 198.21.17.5, lei for the port with the address 213.34.12.3 and 1o0 for the internal port with the address 127.0.0.1. In a hardware router, there is no field indicating any form of output port at all. This is because the address of the output port can always be indirectly determined by the address of the next router. For example, let's determine from the table. 3 output port address for network 56.0.0.0. From the table it follows that the next router for this network will be the router with the address 213.34.12.4. The next router's address must belong to one of the networks directly attached to the router, and in this case it is network 213.34.12.0. The router has a port attached to this network, and we find the address of this port 213.34.12.3 in the Gateway column of the second row of the routing table, which describes the directly attached network 213.34.12.0. For directly attached networks, the next router address is always the router's own port address. Thus, for network 56.0.0 the output port address is 213.34.12.3.

The standard solution today is to use a mask field in each table entry, as is done in the Windows XP router and hardware router tables (Mask columns). The mechanism for processing masks when routers make decisions is discussed below. The absence of a mask field indicates that either the router is designed to work with only three standard address classes, or the same mask is used for all entries, which reduces routing flexibility.
Since each destination network is listed only once in the Unix router's routing table, and therefore there is no route selection, the metric field is an optional parameter. In the remaining two tables, the metric field is used only to indicate that the network is directly connected. A metric of 0 for a hardware router or 1 for a Windows XP router tells the router that this network is directly connected to its port, and the other metric value corresponds to a remote network. The choice of metric for the directly connected network (1 or 0) is arbitrary; the main thing is that the metric of the remote network is calculated taking into account this selected initial value. The Unix router uses a flag field where the G (Gateway) flag marks a remote network, and its absence indicates a directly connected one.

Sign of directly connected network tells the router that the packet has already reached its network, so the IP protocol fires an ARP request against the destination IP address rather than the next router.

However, there are situations where a router MUST store a metric value to record about each remote network. These situations occur when entries in the routing table are the result of some routing protocols, e.g. RIP protocol. In such protocols new information about any remote network is compared with the information contained in the table in this moment, and if the value of the new metric is better than the current one, then new entry displaces the existing one. The Unix router table does not have a metric field, which means that it does not use the RIP protocol.

Entry flags are only present in the Unix router table.

  • U - route is active and operational. The status field in a hardware router has a similar meaning.
  • N - a sign of a specific route to a specific host.
  • G - means that the packet route passes through an intermediate router (gateway). The absence of this flag indicates a directly connected network.
  • D - means that the route was obtained from a forwarded ICMP message. This flag can only be present in the end node's routing table. The sign means that the end node, during some previous packet transmission, chose not the most rational next router on the path to this network, and this router, using the ICMP protocol, informed the end node that all subsequent packets to this network should be sent through another router.

The Unix router table uses two more fields, having reference value. The number of links field shows how many times this route was referred to when forwarding packets. The load field reflects the number of bytes transferred along this route.

The hardware router table entries also have two reference fields. The record time to live (TTL) field in this case has nothing to do with the packet lifetime. Here it shows the time during which the value of this entry is still valid. The source field indicates the source of the entry in the routing table.

Description of the route command: Displays and modifies entries in the local IP routing table. Command run without parameters route displays a certificate.

route [-f] [-p] [ command [ endpoint ] [ mask netmask ] [ gateway ] [ metric metric ]] [ if interface ]]

-f Clears the routing table of all entries that are not a hub route (routes with a subnet mask of 255.255.255.255), a loopback network route (routes with an endpoint of 127.0.0.0 and a subnet mask of 255.0.0.0), or a multicast route (routes with an endpoint of point 224.0.0.0 and subnet mask 240.0.0.0). When using this option in conjunction with one of the commands (such as add, change or delete) the table is cleared before the command is executed. -p When using this option with the command add the specified route is added to the registry and used to initialize the IP routing table each time the TCP/IP protocol starts. By default, added routes are not saved when TCP/IP is started. When using the parameter with the command print displays a list of permanent routes. All other commands ignore this parameter. Permanent routes are stored in the registry at HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\PersistentRoutes command Specifies the command to be run on the remote system. The following table provides a list of valid parameters. mask endpoint Specifies the endpoint of the route. The endpoint can be the network IP address (where the host bits in the network address are set to 0), the IP address of the route to the host, or the value 0.0.0.0 for the default route. netmask Specifies the netmask (also known as subnet mask) according to the destination. The netmask can be the corresponding subnet mask network IP address , for example 255.255.255.255 for a route to a host or 0.0.0.0. for the default route. If this parameter metric omitted, subnet mask 255.255.255.255 is used. The endpoint cannot be more precise than the corresponding subnet mask. In other words, the value of bit 1 in the endpoint address is not possible if the value of the corresponding bit in the subnet mask is 0. gateway Specifies the forwarding or next hop IP address at which the set of addresses defined by the endpoint and the subnet mask is accessible. For locally connected subnet routes, the gateway address is the IP address assigned to the interface that is connected to the subnet. For remote routes that are accessible through one or more routers, the gateway address is the directly accessible IP address of the nearest router. if metric Specifies an integer route cost metric (ranging from 1 to 9999) for a route, which is used to select one of several routes in the routing table that most closely matches the destination address of the forwarded packet. The route with the lowest metric is selected. The metric reflects the number of hops, path speed, path reliability, path throughput, and administrative tools. interface Specifies the index of the interface through which the destination is accessible. To list the interfaces and their corresponding indexes, use the command route print . Interface index values ​​can be either decimal or hexadecimal. Before hexadecimal numbers enter 0x if. In case the parameter /? skipped, the interface is determined from the gateway address.

Displays help on the command line.

route command examples

interface Specifies the index of the interface through which the destination is accessible. To list the interfaces and their corresponding indexes, use the command

To display the entire contents of the IP routing table, enter the command:

To display routes in the IP routing table that begin with 10., enter the command. Routing table -(file) or database stored on the router or network computer, describing the correspondence between destination addresses and interfaces through which the data packet should be sent to the next router. Is simplest form routing rules.

The routing table usually contains:

· address of the destination network or host, or an indication that the route is the default route;

· destination network mask (for IPv4 networks, the mask /32 (255.255.255.255) allows you to specify a single network node);

· gateway, indicating the address of the router on the network to which the packet must be sent to specified address appointments;

· interface (depending on the system, this can be a serial number, GUID or symbolic name of the device);

· metric - a numerical indicator that specifies the route preference. The lower the number, the more preferred the route (intuitively represented as distance);

Enterprise network N is shown in Fig. 1.1.

Fig.1.1

In Table 1.9 there is no standard “Mask” column, so the same mask is used throughout the network. Table 1.9 is simplified; it does not contain signs of the route state, the time during which the entries in this table are valid. Instead of the destination network number, the full network address of the individual destination node can be specified. Here are the addresses of networks in a conditional format that do not correspond to any specific network protocol.

Table 1.9 Enterprise network routing table N for router M1.

The first column of the table contains packet destination addresses.

In each row of the table, after the destination address, indicate network address of the next router ( more precisely, the network address of the interface of the next router) to which the packet must be sent so that it moves towards the given address along a rational route.

Before passing a packet to the next router, the current router must determine which of its own ports it should place Current Package. For this purpose, the third column of the routing table is used, containing network addresses output interfaces.

Some implementations network protocols allow the presence of several rows in the routing table corresponding to the same destination address. In this case, when choosing a route, the column " distance to destination network". In this case, the distance is measured in any metric used in accordance with the specified network package criterion. The distance can be measured by the time it takes for a packet to travel along communication lines, various characteristics of the reliability of communication lines on a given route, throughput or another value reflecting the quality of a given route in relation to given criterion. The distance for networks directly connected to the router ports is assumed to be 1.

When a packet arrives at a router, the IP module extracts the destination network number from the incoming frame header and sequentially compares it with the network numbers from each row of the table. The line with the matching network number indicates the nearest router to which the packet should be forwarded.

Most often, not the entire IP address is indicated in the table as the destination address, but only the destination network number. Thus, for all packets destined for the same network, the IP protocol will offer the same route. However, in some cases it becomes necessary for one of the network nodes to determine specific route, different from the route specified for all other network nodes. To do this, a separate line is placed in the routing table for a given node, containing its full IP address and the corresponding routing information. If the table contains entries about routes both to the network as a whole and to its individual node, then when a packet addressed to this node arrives, the router will give preference to a specific route.

Since a packet can be addressed to any network on a composite network, it would seem that each routing table would have entries for all the networks that are part of the composite network. But with this approach, in case large network The volume of routing tables can be very large, which will affect the time it takes to view it, require a lot of storage space, etc. Therefore, in practice, a widely known technique for reducing the number of entries in the routing table is based on the introduction default route ( default route). This technique uses features of the network topology. Consider, for example, routers located on the periphery of a composite network. In their tables, it is enough to write down the numbers of only those networks that are directly connected to a given router or located nearby, on dead-end routes. For all other networks, you can make a single entry in the table, indicating the router through which the path to all these networks runs. This router is called default router ( default router).

The routing problem is solved not only by intermediate nodes (routers), but also by final nodes - computers. Solving this problem begins with the fact that the IP protocol installed on the end node determines whether the packet is directed to another network or addressed to some node on the same network. If the destination network number matches the given network number, this means that the packet does not need to be routed. Otherwise, routing is needed.

The routing table structures of end nodes and transit routers are similar.

End nodes, even more so than routers, use default routing. Although they are also general case have at their disposal a routing table, its volume is usually insignificant, which is explained by the peripheral location of all end nodes. The end node often operates without a routing table at all, having only knowledge of the default router address. If there is one router on the local network, this option is the only one possible for all end nodes. But even if there are several routers on the local network, when the end node is faced with the problem of choosing them, computers often resort to setting a default route to improve performance.

Another difference between the operation of a router and an end node is the way the routing table is built. If routers, as a rule, automatically create routing tables by exchanging service information, then for end nodes routing tables are often created manually by administrators and stored in the form permanent files on disks.