TCP/IP是如何工作的(二)

2026-04-05
If the destination IP address is local, the router searches an internal store of IP addresses and local-device Media Access Control(MAC)addresses. This store is known as the Address Resolution Protocol(ARP)cache. ARP is the universal tool for matching IP addresses to MAC addresses. If the destination\'s MAC address appears, the router installs that MAC address in the packet header(removing its own MAC address because that\'s no longer needed)and sends the packet to the destination end station.

  In the event that the destination MAC address does not appear in the ARP cache ―it might have timed out, for instance― the router must broadcast an ARP request to the subnet referenced by the packet\'s destination IP address. The end station with that IP address responds, sending back its MAC address .The router updates its cache, installs the new MAC address into the packet header and launches the packet. If the route table lookup shows that the packet is destined for a non-local subnet, the router forwards the packet to the next-hop router using the next-hop router\'s MAC address. Routing tables are continuously built and rebuilt by intelligent discovery protocols, such as Routing Information Protocol or Open Shortest Path First(OSPF). Each router\'s routing table shows the best route to the destination address; for addresses that may be several hops away, it shows the best next-hop router.

  在过去几年中,写得最多的网络题目之一就是IP。但是,即使引起了这么多的注意,仍很少有(如果有的话)文章介绍此协议的基本工作原理,即路由器和第三层交换器是如何对IP信息起作用,以便在整个网络中传递以太网包的。

  作为参考,请记住,IP是TCP/IP整套协议中的一个协议。

  TCP完成开放系统互连(OSI)模型中传输层,即第四层的功能。它的主要责任是确保端至端之间的可靠连接。IP位于下一层,在OSI的网络层,即第三层,把每个包的发送者和接收者地址告诉一路上各个路由器。路由器和第三层交换器可以读出IP和其他的第三层协议。这些信息与路由表以及其他网络智能结合在一起,能通过TCP/IP在整个房间或围绕地球进行传递。

  路由过程始于对发送端站而言是的一个IP地址,端站可以被分配永久的IP地址,或者按需要从动态主机配置协议(DHCP)服务器或其他服务中借用。