This is the 24th day of my participation in the August More Text Challenge

This article introduces Router in detail

The Router Router

  1. The scope of a router is two different network segments or vlans. Routers are not needed for communication on the same network segment.

  2. The router has two functions: routing and forwarding; The so-called routing is to find a “best path” from the source IP address to the target IP address, just like we usually use the navigation function; Forwarding, that is, sending packets from one node to another node;

  3. Routers route based on IP addresses, that is, they work at the third layer of TCP, the network layer. It does not care about layer 2 and layer 1 transmission media, the underlying transmission mode is transparent to the router;

  4. The subnet connected by each port of a router is a broadcast domain, or it can be said that the router divides the broadcast domain.

  5. The router connected to the public network is merged with the NAT and modem as the default gateway.

Routing protocol

Routing protocols enable routers to parse packets, maintain local routing tables, and exchange routing information with other routers. Routers use different routing protocols for different application scenarios. Common routing protocols are as follows: RIP(Routing Information Protocol), OSPF(Open Shortest Path First), BGP(Border Gateway Protocol)

Routing table, which is the core of all routing protocols:

  • The purpose of a routing table is to indicate where to go next if you want to go to a certain address.

  • Its content includes but is not limited to: local router status, local subnet information, information about the path from the local port to the next hop port, routing path status, routing path cost, surrounding router status, etc.

  • According to the above information, after receiving a packet, the router can choose whether to send it to the local subnet or to the next router according to its source IP address and destination IP address, and select the router on the best path to forward the packet according to the information in the table.

  • Routers can broadcast their routing tables to each other.

RIP Routing protocol:

  • RIP is an application-layer protocol that uses UDP for transmission.

  • In the routing protocol based on distance vector algorithm, the distance here is “hop count number of hops”, the distance of directly connected nodes is 1, and the distance of each additional level of nodes at the remote node is +1. The optimal path is the path with short distance.

  • According to the protocol, the maximum reachable distance is 15 hops. The destination network considers that the distance beyond 15 hops is unreachable. Therefore, RIP is generally used for small-scale networks.

  • The routing table records the path and distance from the source network to the target network (hop points).

  • A router periodically broadcasts its routing table to all neighboring nodes.

  • In addition to limiting the network scale, RIP simplifies the path distance and only measures the hop count, ignoring the actual link status, such as bandwidth, load, and delay.

OSPF open shortest paths have priority

  • Routers maintain a Link State Database, which is a topology of the network on which the route resides

  • It is based on the Shortest path First (SPF) algorithm

    • When a router joins a network, it broadcasts hello messages across the network to discover neighboring nodes
    • Then broadcast its connection rate to the directly connected neighbor router
    • After receiving the broadcast, other nodes update their link-state database and broadcast it to other routers. In this way, each router on the network has complete routing information of the whole network.
  • When the link status is updated or changed, the router broadcasts only the changed part rather than the whole link table, which saves bandwidth consumption.

  • To reduce broadcast storms, OSPF also introduces the concept of area. A large network is divided into multiple areas. Link status of the same area is broadcast only in the same area.

  • Based on the above features, OSPF applies to large networks

BGP Border gateway protocol

  • The idea of boundaries introduces the concept of autonomous systems, which define boundaries. An AUTONOMOUS system (AS) is a group of one or more IP networks managed by one or more network operators that share the same routing policy. Large AS have their own unique ASN number;

  • There are also different types of autonomous systems. Multi-egress Autonomous systems (Multihomed AS) connect multiple ass, but do not allow relay routes. The Stub AS connects to only one OTHER AS. Transit AS (connecting multiple ass and allowing Transit routes).

  • The routing protocol inside an AS is IGP, and the routing protocol that interacts with other ass is EGP. RIP and OSPF belong to IGP, while BGP belongs to EGP.

  • BGP is an application-layer protocol. Routing information is transmitted through TCP to ensure reliability.

  • A BGP router must manually establish Peer relation during initialization.

  • BGP is based on the path-vector algorithm

    • A router broadcasts information about its neighboring reachable routers, and the router that receives this information adds itself to the path and sends the information to other neighboring routers.
    • If it finds that it is already in the path, the message is discarded; This can effectively avoid the generation of loop;
    • Path information consists of AS numbers
    • Finally, routing tables contain all destination networks, next hops, and complete path information.

One-armed route Router-on-a-stick

Single-arm routing is a special application scenario of routers, that is, to implement packet input and output on one port:

  • In order to realize access control within the LAN, a large LAN can be divided into multiple virtual LAN vlans. Different vlans cannot communicate with each other and must be forwarded through routers.

  • Routers use one physical port and configure multiple logical interfaces to communicate with each other on different vlans.

  • Packets from VLAN1 are sent to the default gateway through the switch. After routing through the gateway, packets are forwarded to another IP address on VLAN2 and forwarded through the same switch.

  • The same effect can be achieved with layer 3 switches, which we’ll focus on in the next section;

Above, thank you for reading, if there is inaccurate and wrong place please comment, I will immediately correct, thank you!






Summary is not easy, please do not reprint without permission, otherwise don’t blame old uncle you are welcome

Welcome technical friends to communicate with me, wechat 1296386616

References:

The OSPF Nokia infocenter.nokia.com/public/7210…

The Path – the vector routing protocol “wikipedia en.wikipedia.org/wiki/Path-v…

The Practical BGP “Russ White, Danny McPherson, Srihari Sangli www.informit.com/articles/ar…

The routing protocols of network protocol harkecho www.huaweicloud.com/articles/11…