⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 c-tcpip7.html

📁 Vxworks网络编程指南
💻 HTML
📖 第 1 页 / 共 3 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><link rel="STYLESHEET" type="text/css" href="wrs.css"><title>    TCP/IP Under VxWorks     </title></head><body bgcolor="FFFFFF"><p class="navbar" align="right"><a href="index.html"><img border="0" alt="[Contents]" src="icons/contents.gif"></a><a href="c-tcpip.html"><img border="0" alt="[Index]" src="icons/index.gif"></a><a href="c-tcpip.html"><img border="0" alt="[Top]" src="icons/top.gif"></a><a href="c-tcpip6.html"><img border="0" alt="[Prev]" src="icons/prev.gif"></a><a href="c-netconfig.html"><img border="0" alt="[Next]" src="icons/next.gif"></a></p><font face="Helvetica, sans-serif" class="sans"><h3 class="H2"><i><a name="87225">4.7  &nbsp;&nbsp;ARP and Proxy ARP for Transparent Subnets</a></i></h3></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="87227"> </a>ARP (Address Resolution Protocol) provides dynamic mapping from an IP address to the corresponding hardware or MAC address. Using ARP, VxWorks implements a proxy ARP scheme over the shared-memory network that can make distinct networks appear as one logical network (that is, the networks share the same address space). This proxy ARP scheme is an alternative to the use of explicit subnets for accessing the shared-memory network. See <a href="c-dll5.html#85549"><i class="title">3.5&nbsp;Shared-Memory Network on the Backplane</i></a>. <sup><a href="#foot"><b class="FootnoteMarker">1</b></a></sup></p><dd><p class="Body"><a name="87235"> </a>Previously, the shared-memory network (backplane) had to be partitioned as a separate subnet, and routes to that subnet had to be added to each host that required access to the shared-memory network.  Each shared-memory network took up an individual subnet number; therefore, if a large number of shared-memory networks were present on a network, precious subnet numbers were rapidly consumed.  However, with proxy ARP, the shared-memory network appears to use the same subnet/network as the Ethernet. Therefore, subnet numbers are not assigned. </p><dd><p class="Body"><a name="87236"> </a>If the shared-memory network is attached to a large network with many networks and subnets, network configuration becomes difficult.  Proxy ARP simplifies network configuration because there is only one network to deal with and additional configuration on the host is unnecessary.</p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="87237">4.7.1  &nbsp;&nbsp;ARP Introduction</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="87238"> </a>ARP is used to resolve a host's IP address into a hardware address.  This is done by broadcasting an ARP request on the physical medium (typically Ethernet).  The destination host sees the request and recognizes the destination IP address as its own.  It then sends a reply with its hardware address.</p><dd><p class="Body"><a name="87243"> </a>In the example in <a href="c-tcpip7.html#87247">Figure&nbsp;4-7</a>, host <b>h1</b> wants to communicate with host <b>h4</b>. It needs <b>h4</b>'s hardware address, so it broadcasts an ARP request.  Host <b>h4 </b>sees the ARP request and replies with its hardware address. <b>h1</b> records <b>h4</b>'s IP-to-hardware mapping and proceeds to communicate with it. <div class="frame"><h4 class="EntityTitle"><a name="87247"><font face="Helvetica, sans-serif" size="-1" class="sans">Figure 4-7:&nbsp;&nbsp;ARP Example</font></a></h4><dl class="margin"><div class="Anchor"><a name="87306"> </a><img class="figure" border="0" src="images/c-tcpip11.gif"></div></dl></div></p><dd><p class="Body"><a name="87307"> </a>For a host to communicate with another host on a different subnet or network (as indicated by the IP addresses and the subnet mask), it must use a gateway. In <a href="c-tcpip7.html#87321">Figure&nbsp;4-8</a>, <b class="symbol_lc">vx3</b> acts as a gateway between Network A and Network B. Each host must have a routing entry for the gateway in its routing table. The routing table for <b class="symbol_lc">vx1</b> to communicate with Network B includes entries like the following:</p><dl class="margin"><dd><pre class="Code2"><b><a name="87311">node&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;destination&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gateway </b><tt class="output">vx1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;150.12.2.0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;150.12.1.1 (network)  </tt><b></a></b></pre></dl><dd><p class="Body"><a name="87313"> </a>The routing table for <b class="symbol_lc">h1</b> to communicate with Network A includes entries like the following:</p><dl class="margin"><dd><pre class="Code2"><b><a name="87314">node&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;destination&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gateway </b><tt class="output">h1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;150.12.1.0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;150.12.2.1 (network)  </tt><b></a></b></pre></dl><dd><p class="Body"><a name="87316"> </a>A sender cannot send an ARP request for a host on another subnet or network. Instead, if it doesn't know the hardware address for the gateway listed in its routing table, it sends an ARP request for the gateway's hardware address. <div class="frame"><h4 class="EntityTitle"><a name="87321"><font face="Helvetica, sans-serif" size="-1" class="sans">Figure 4-8:&nbsp;&nbsp;Subnets and ARP</font></a></h4><dl class="margin"><div class="Anchor"><a name="87358"> </a><img class="figure" border="0" src="images/c-tcpip12.gif"></div></dl></div></p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="87360">4.7.2  &nbsp;&nbsp;Proxy ARP Overview</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="87361"> </a>With proxy ARP, nodes on different physical networks are assigned addresses with the same subnet number.  Because they appear to reside on the same network, they can communicate directly and use ARP to resolve hardware addresses.  The gateway node provides this network transparency by watching for and answering ARP requests that cross network boundaries.  The node providing this transparency is the <i class="term">proxy server</i>.</p><dd><p class="Body"><a name="87366"> </a>The example configuration shown in <a href="c-tcpip7.html#87321">Figure&nbsp;4-8</a> changes slightly when proxy ARP is used.  As shown in <a href="c-tcpip7.html#87373">Figure&nbsp;4-9</a>, the nodes <b>vx1</b> and <b>h1</b> now look as if they are on the same subnet.  Nodes <b>h1</b> and<b> vx1</b> are fooled by <b>vx3</b> into thinking they can send directly to each other, when they are actually sending to <b>vx3</b>.  The gateway node, <b>vx3</b>, ensures that the packets get to the correct destination.<div class="frame"><h4 class="EntityTitle"><a name="87373"><font face="Helvetica, sans-serif" size="-1" class="sans">Figure 4-9:&nbsp;&nbsp;Proxy ARP Example</font></a></h4><dl class="margin"><div class="Anchor"><a name="87402"> </a><img class="figure" border="0" src="images/c-tcpip14.gif"></div></dl></div></p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="87403">4.7.3  &nbsp;&nbsp;Routing Issues and the Proxy Server</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="87405"> </a>The proxy server provides network transparency by listening to and answering ARP messages, and by manipulating its routing tables. Suppose the proxy server had two interfaces: shared-memory network and Ethernet. Nodes residing on different interfaces can have the same network address if network-specific routes with an explicit mask of <b class="symbol_UC">0xFFFFFFFF</b> were used on one interface (shared-memory network) and network routing was done on the other (Ethernet). </p><dd><p class="Body"><a name="87406"> </a>The proxy clients in the shared-memory network are added with a subnet mask of <b class="symbol_UC">0xFFFFFFFF</b> so that arp route entries to the proxy clients can be cloned from the route added by the <b class="library">proxyLib</b>. In the proxy server, the backplane IP address should also have an explicit mask of <b class="symbol_UC">0xFFFFFFFF</b>. For example:</p><dl class="margin"><dd><pre class="Code2"><b><a name="87407">Inet on the backcplane (b): 150.12.1.199:FFFFFFFF</a></b></pre></dl><dd><p class="Body"><a name="87411"> </a>In the example in <a href="c-tcpip7.html#87418">Figure&nbsp;4-10</a>, <b>vx1</b> and <b>h1</b> have the same network address, 150.12.1.0. The proxy server, <b>vx3</b>, has a routing table like the following example:</p><dl class="margin"><dd><pre class="Code2"><b><a name="87412">Destination&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Gateway </b><tt class="output">150.12.1.6&nbsp;(network&nbsp;route&nbsp;with&nbsp;netmask&nbsp;0xffffffff).......)&nbsp;150.12.1.8 150.12.1.7&nbsp;(network&nbsp;route&nbsp;with&nbsp;netmask&nbsp;0xffffffff........)&nbsp;150.12.1.8 150.12.1.0&nbsp;(network)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b><tt class="output">&nbsp;</tt><b>&nbsp;</b><tt class="output">150.12.1.60</tt><b><div class="frame"></pre><h4 class="EntityTitle"><a name="87418"><font face="Helvetica, sans-serif" size="-1" class="sans">Figure 4-10:&nbsp;&nbsp;Proxy Server Example</font></a></h4><dl class="margin"><div class="Anchor"><a name="87466"> </a><img class="figure" border="0" src="images/c-tcpip15.gif"></div></dl></div></a></b></pre></dl><dd><p class="Body"><a name="87468"> </a>The network on which the proxy server performs network-specific routing (or for which it is acting as a proxy) with the mask <b class="symbol_UC">0xFFFFFFFF</b> is referred to as the <i class="term">proxy network</i>. The proxy server has a network-specific route with mask <b class="symbol_UC">0xFFFFFFFF</b> to each node on the proxy network. The network interface on which the proxy server performs network routing is called the <i class="term">main network</i>. In the example in <a href="c-tcpip7.html#87418">Figure&nbsp;4-10</a>, the shared-memory network is the proxy network and the Ethernet is the main network. The routing table of <b>vx3</b> has network-specific routes with mask <b class="symbol_UC">0xFFFFFFFF</b> for both <b>vx1 </b>and <b>vx2</b>. To send to nodes <b>h1</b> and <b>h2</b>, it uses the network route (150.12.1.0). There can be multiple proxy networks per main network. However, there can only be one main network per network/subnet number. </p><dd><p class="Body"><a name="87473"> </a>Although network-specific routes with netmask <b class="symbol_UC">0xFFFFFFFF</b> can be used on all interfaces for complete generality, a VxWorks shared-memory network usually is configured so that one side of the proxy server contains the majority of nodes (the Ethernet side). Therefore, in this case it is reasonable to use this network as the main network. </p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="87475">4.7.4  &nbsp;&nbsp;Proxy ARP Protocol</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="87476"> </a>The following subsections describe how the proxy ARP protocol responds to ARP requests for proxy clients, non-proxy clients, and how it responds to replies from the main network. </p></dl></dl><dl class="margin"><dd><font face="Helvetica, sans-serif" size="-1" class="sans"><h5 class="HU"><i><a name="87477">ARP Requests for Proxy Clients</a></i></h5></font><dl class="margin"><dd><p class="Body"><a name="87479"> </a>If the proxy server receives an ARP request from the main network for a node on a proxy network (<i class="term">proxy client</i>), the proxy server generates an ARP reply with its own hardware address as the source hardware address.  If the node that generated the request is also on the proxy network, the destination proxy client answers for itself. In the example in <a href="c-tcpip7.html#87418">Figure&nbsp;4-10</a>, if <b>vx1</b> broadcasts an ARP request for 150.12.1.7, <b>vx2</b> replies to the request, not the proxy server <b>vx3</b>.  However, if <b>h1</b> broadcasts an ARP request for 150.12.1.7, the proxy server (<b>vx3</b>) replies with its own hardware address.</p></dl><dd><font face="Helvetica, sans-serif" size="-1" class="sans"><h5 class="HU"><i><a name="87483">ARP Requests from Proxy Clients for Non-proxy Clients</a></i></h5></font><dl class="margin"><dd><p class="Body"><a name="87485"> </a>If an ARP request comes from a proxy network and the destination address is not a proxy client, the proxy server tries to resolve the request.  If the hardware address of the destination is known, the server generates and sends an ARP reply to the source proxy client.  If the hardware address is unknown, the server forwards the ARP request to the proxy network's corresponding main network, replacing the source hardware address in the ARP message with its own outgoing interface hardware address.  For example, in <a href="c-tcpip7.html#87418">Figure&nbsp;4-10</a>, <b>vx1</b> sends an ARP request for 150.12.1.62.  If <b>vx3</b> knows the hardware address, it sends an ARP reply to <b>vx1</b>.  Otherwise it forwards the request to the Ethernet.</p></dl><dd><font face="Helvetica, sans-serif" size="-1" class="sans"><h5 class="HU"><i><a name="87489">ARP Replies from the Main Network</a></i></h5></font><dl class="margin"><dd><p class="Body"><a name="87491"> </a>If the proxy server gets an ARP reply, the server checks to see if the destination is a proxy client.  If it is, and the server previously forwarded this request, then the server forwards the ARP reply back to the proxy client (replacing the source hardware address in the ARP reply message with its own).  In the previous example, if <b>h2</b> replies to the request for the Ethernet address of 150.12.1.62, the proxy server (<b class="symbol_lc">vx3</b>) records the address for itself and then forwards the reply to <b>vx1</b> (with <b class="symbol_lc">vx3</b>'s own hardware address substituted for <b class="symbol_lc">h2</b>'s).</p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="87493">4.7.5  &nbsp;&nbsp;Broadcast Datagrams</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="87495"> </a>All nodes on a logical network are expected to receive an IP broadcast for that network (for example, 150.12.1.255).  Thus, broadcasts must be passed through the proxy server so that nodes on both the proxy network and the main network receive them.  Because most broadcast traffic is extraneous, it is desirable to minimize the number of forwarded shared-memory network broadcasts, thus keeping shared-memory network traffic to a minimum.</p><dd><p class="Body"><a name="87496"> </a>To minimize and control shared-memory network broadcast traffic, the proxy server can be configured to forward broadcasts only to a specified set of destination UDP ports.  Ports are enabled using the routine <b class="routine"><i class="routine">proxyPortFwdOn</i></b><b>(</b>&nbsp;<b>)</b>, and are disabled with <b class="routine"><i class="routine">proxyPortFwdOff</i></b><b>(</b>&nbsp;<b>)</b>.  Only the BOOTP/DHCP server port (67) is enabled by default.</p><dd><p class="Body"><a name="87499"> </a>If a broadcast datagram originates from a proxy network (and the port is enabled), the server forwards the broadcast to the main network, and to all other proxy networks that have the same main network.  For example, in <a href="c-tcpip7.html#87506">Figure&nbsp;4-11</a>, if a datagram comes from <b class="symbol_lc">sm1</b>, it gets forwarded to <b class="symbol_lc">ln0</b> and <b class="symbol_lc">sm0</b>.<div class="frame"><h4 class="EntityTitle"><a name="87506"><font face="Helvetica, sans-serif" size="-1" class="sans">Figure 4-11:&nbsp;&nbsp;Broadcast Datagram Forwarding</font></a></h4><dl class="margin">

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -