互联网工作原理(11.路由器是如何向目的地发送数据的)

 

Routers are the traffic cops of the Internet. They ensure that all data gets sent to where it's supposed to go via the most efficient route. When you sit down at your computer and connect to the Internet and send or receive data, generally that information first must go through at least one routerand often more than one routerbefore it reaches its final destination.

Routers open the IP packets of data to read the destination address, calculate the best route, and then send the packet toward its final destination. If the destination is on the same network as the sending computer, such as within a corporation, the router sends the packet directly to the destination computer. If the packet is going to a destination outside the local network, the router instead sends the packet to another router closer to the destination. That router in turn sends the packet to a yet-closer router, and so on, until the packet reaches its final destination.

When routers determine the next router to receive packets, factors such as traffic congestion and the number of hops (routers or gateways on any given path) come into play. The IP packet carries a segment that holds the maximum hop counts it can travel, and a router will not use a path that would exceed that predefined number of hops.

Routers have two or more physical ports: receiving (input) ports and sending (output) ports. When an input port receives a packet, a software routine called a routing process is run. This process looks inside the header information in the IP packet and finds the address to which the data is being sent. It then compares this address against an internal database called a routing table. The routing table has detailed information about the ports to which packets with various IP addresses should be sent. Based on what it finds in the routing table, the router sends the packet to a specific output port. This output port then sends the data to the next router or to the destination itself.

There are two kinds of routing tables: static routing tables and dynamic routing tables. The static table is simpler, and specifies specific paths for packets to use to get to their final destination. The dynamic table allows a packet to have multiple routes to get to its destination.

At times, packets are sent to a router's input port faster than the port can process them. When this happens, the packets are sent to a special holding area called an input queue, which is an area of RAM on the router. That specific input queue is associated with a specific input port. A router can have more than one input queue. Each input port processes packets from the queue in the order in which they were received, so the first packets sent in are the first to get processed and sent out.

If the number of packets received exceeds the capacity of the queue (called the length of the queue), packets might be lost. When this occurs, the TCP protocol on the sending and receiving computers have the packets re-sent.

Note that the router in the following illustration is of the type that routes data throughout the Internet, and isn't the same as a home router that forms the basis of a home network. For information about how a home router works, see Chapter 10, "How Home Networks Work."

转载于:https://www.cnblogs.com/nio-nio/archive/2009/03/14/1411704.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值