The main purpose of the work of the router
Connect multiple networks and forward packets destined for your own network or other networks .
A router is considered a Layer 3 device because it IP数据包
makes forwarding Layer 3 , esp 目的IP地址
.
When a router receives a packet
1. It searches it 路由表
to find the best match数据包的目标IP地址
between 路由表中的一个地址
( different protocols). 2. Once a match is found, the packet is encapsulated in a Layer 2 data link frame on the output
In essence, it is converted into a sealed Layer 2 envelope and
nex hop ip
sent to the next device according to the output interface (or) specified in the routing table.
- Note:
-
Routers typically do not look at packet payloads and only perform
forwarding
Additional information may also be selected (eg: QoS (QoS
) hints)
For pureIP
forwarding , routers are designed to minimize the amount of time associated with a single packet status information.
Once a packet is forwarded, the router does not keep any historical information about the packet.
Routing table:
- The routing table itself can contain information originating from a variety of different sources
- Generally divided into three categories:
- Manual configuration:
-
static route
default route - Automatic learning:
- Dynamic routing (learning routes from other routers)
- Default route usage scope:
-
Routes for all traffic whose destinations do not appear in the routing table ;
It's common - or even necessary - in a small network - in a home or small business, the default route simply sends all non-local traffic to the
Internet
service provider.
The default route can be手动配置
(as静态路由
), pass-through动态路由协议学习
, orDHCP
get-through.
Routing Protocol
A router can run multiple routing protocols at a time
- especially on border routers
- effect
- Can handle information sharing (selective sharing) between internal different routers, internal and external ( parts of the network running different routing protocols )
router is clogged
In addition to deciding which interface the packet is forwarded to (mostly via 路由表
processing)
The router also needs to deal with the congestion caused by the large number of packets
processing strategy
-
Three strategies commonly used on the Internet are
尾部丢弃
,随机早期检测(RED)
and加权随机早期检测(WRED)
. - Trailing:
-
the simplest and easiest to implement;
Once the queue length exceeds the size of the buffer in the router, the router simply drops new incoming packets.
- Random early detection:
-
When the queue exceeds the
preconfigured
portion of the buffer,
RED
drop datagrams early until a predetermined maximum value is reached (becomes tail drop) - weighted random early detection
-
When traffic will exceed the preconfigured size,
WRED
the average queue size needs to be weighted so that random drops are短脉冲串
not triggered.
Another function the router performs during this time is
Determines which packet should be processed first when there are multiple queues.
This is QoS
managed by, which is important when deploying IP语音
so as not to introduce excessive latency.
Policy-Based Routing
Because of the special rules constructed therein, the rules derived from the routing when making packet forwarding decisions .