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

📄 c-tcpip2.html

📁 vxworks相关论文
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<td width="10">&nbsp;</td><td colspan=1 rowspan=1><div class="CellBodyC" align="center"><a name="86334"> </a>1110</div></td><td width="10">&nbsp;</td><td colspan=1 rowspan=1><div class="CellBodyC" align="center"><a name="86336"> </a>None </div></td><td width="10">&nbsp;</td><td colspan=1 rowspan=1><div class="CellBodyC" align="center"><a name="86339"> </a>224.0.0.0 to 239.255.255.255</div></td><td width="10">&nbsp;</td></tr><tr><td colspan="20"><hr class="tablerule"></td></tr><tr valign="middle"><td colspan="20"></td></tr></table></p></p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="86341">4.2.2  &nbsp;&nbsp;Packet Routing</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="86343"> </a>The IP protocol handles packet routing.  Each route entry in the routing table is a mapping between a destination address and the network interface through which the packet is transmitted. <div class="frame"><h4 class="EntityTitle"><a name="86347"><font face="Helvetica, sans-serif" size="-1" class="sans">Figure 4-2:&nbsp;&nbsp;Internet Routing </font></a></h4><dl class="margin"><div class="Anchor"><a name="86406"> </a><img class="figure" border="0" src="images/c-tcpipa1.gif"></div></dl></div></p><dd><p class="Body"><a name="86407"> </a>The route entries in a routing table are of two types:  host-specific and network-specific.  Host-specific route entries contain the host destination address and the address of the gateway to use for packets destined for this host.  Network-specific route entries contain a network destination address and the Internet address of the gateway to use for packets destined for this network. </p><dd><p class="Body"><a name="86408"> </a>The VxWorks networking software establishes a route before transmitting each packet. Given a destination address, VxWorks searches the routing table to find a matching route entry and thus the network interface through which it transmits the packet. A route entry is considered a match if the logical <b class="symbol_UC">AND</b> of the network mask and the given search key (destination address) equals the destination address stored in the route entry. For example, if a route entry has 147.11.44.00 as a destination and <b class="symbol_UC">0xFFFFFF00</b> as a network mask, a search key of 147.11.44.155 matches. However, a search key of 147.11.43.155 does not match. </p><dd><p class="Body"><a name="86409"> </a>For a host route, a mask of <b class="symbol_UC">0xFFFFFFFF</b> is assumed. If a default route is added with the destination address as "0.0.0.0", an implicit netmask of <b class="symbol_UC">0x00000000</b> is assumed. The destination address for a default route entry is always "0.0.0.0". An implicit network mask of <b class="symbol_UC">0x00000000</b> is assumed for this route entry.</p><dd><p class="Body"><a name="86413"> </a>When searching<sup><a href="#foot"><b class="FootnoteMarker">2</b></a></sup> the routing table for a destination address, the search algorithm first tries to match the complete host address. If the host address match is not found, the search tries to match the network address of the provided destination address. If a network address match is not found, the search returns the route entry of the default address (if any). </p><dd><p class="Body"><a name="86414"> </a>If the search of the routing table finds a matching entry which has a clone flag set, a new route entry is created (cloned) from the found entry. For example:</p></dl><dl class="margin"><dd><div class="Item"><a name="86415"> </a><i class="emphasis">If:</i> </div><dl class="margin"><dl class="margin"><dd><div class="Indent2"><a name="86416"> </a>The routing table on a VxWorks target contains a route to an Ethernet network interface whose IP address is 147.11.44.155.</div><br></dl></dl><dd><div class="Item"><a name="86417"> </a><i class="emphasis">And:</i> </div><dl class="margin"><dl class="margin"><dd><div class="Indent2"><a name="86418"> </a>The subnet mask is <b class="symbol_UC">0xFFFFFF00</b>. </div><br></dl></dl><dd><div class="Item"><a name="86419"> </a><i class="emphasis">And:</i> </div><dl class="margin"><dl class="margin"><dd><div class="Indent2"><a name="86420"> </a>The <b class="symbol_UC">RTF_CLONING</b> (0x100) flag is set. </div><br></dl></dl><dd><div class="Item"><a name="86421"> </a><i class="emphasis">Then:</i> </div><dl class="margin"><dl class="margin"><dd><div class="Indent2"><a name="86422"> </a>A search for 147.11.44.156 matches the 147.11.44.155 entry and creates a new route entry, a copy (clone) of the route entry for 147.11.44.155. </div><br></dl></dl></dl><dl class="margin"><dd><p class="Body"><a name="86423"> </a>This new route entry for 147.11.44.156 is used by the link level address resolution protocol (ARP) to supply the corresponding Ethernet hardware address to the gateway address field. The route flags <b class="symbol_UC">RTF_HOST</b> (0x004) and <b class="symbol_UC">RTF_LLINFO</b> (0x400) are set to specify that it is host route and the gateway address is a link level address rather than a regular Internet address. </p><dd><p class="Body"><a name="86426"> </a>For information on configuring and adding routes to the routing table, see <a href="c-tcpip3.html#86609"><i class="title">Adding a Route on VxWorks</i></a>. </p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="86430">4.2.3  &nbsp;&nbsp;Network Byte Order</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="86432"> </a>A single network can contain CPUs using different internal architectures.  The numeric representation schemes of these architectures can differ: some use <i class="term">big-endian</i> numbers, and some use <i class="term">little-endian</i> numbers.  To permit exchanging numeric data over a network, some overall convention is necessary. <i class="term">Network byte order</i> is the convention that governs exchange of numeric data related to the network itself, such as socket addresses or shared-semaphore IDs.  Numbers in network byte order are big-endian. </p><dd><p class="Body"><a name="86439"> </a>The routines in <a href="c-tcpip2.html#86443">Table&nbsp;4-2</a> convert longs and shorts between host and network byte order.  To minimize overhead, macro implementations (which have no effect on architectures where no conversion is needed) are also available, in <b class="file">h/netinet/in.h</b>.<p class="table"><h4 class="EntityTitle"><a name="86443"><font face="Helvetica, sans-serif" size="-1" class="sans">Table 4-2:&nbsp;&nbsp;Network Address Conversion Macros</font></a></h4><table border="0" cellpadding="0" cellspacing="0"><tr><td colspan="20"><hr class="tablerule"></td></tr><tr valign="middle"><th rowspan="1" colspan="1"><div class="CellHeading"><b><a name="86447"> </a><font face="Helvetica, sans-serif" size="-1" class="sans">Macro</font></b></div></th><td width="10">&nbsp;</td><th rowspan="1" colspan="1"><div class="CellHeading"><b><a name="86449"> </a><font face="Helvetica, sans-serif" size="-1" class="sans">Description</font></b></div></th><td width="10">&nbsp;</td></tr><tr><td colspan="20"><hr class="tablerule2"></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="86451"> </a><b class="symbol_lc">htonl</b></div></td><td width="10">&nbsp;</td><td colspan=1 rowspan=1><div class="CellBody"><a name="86453"> </a>Convert a <b class="keyword">long</b> from host to network byte ordering.</div></td><td width="10">&nbsp;</td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="86455"> </a><b class="symbol_lc">htons</b></div></td><td width="10">&nbsp;</td><td colspan=1 rowspan=1><div class="CellBody"><a name="86457"> </a>Convert a <b class="keyword">short</b> from host to network byte ordering.</div></td><td width="10">&nbsp;</td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="86459"> </a><b class="symbol_lc">ntohl</b></div></td><td width="10">&nbsp;</td><td colspan=1 rowspan=1><div class="CellBody"><a name="86461"> </a>Convert a <b class="keyword">long</b> from network to host byte ordering.</div></td><td width="10">&nbsp;</td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="86463"> </a><b class="symbol_lc">ntohs</b></div></td><td width="10">&nbsp;</td><td colspan=1 rowspan=1><div class="CellBody"><a name="86465"> </a>Convert a <b class="keyword">short</b> from network to host byte ordering.</div></td><td width="10">&nbsp;</td></tr><tr><td colspan="20"><hr class="tablerule"></td></tr><tr valign="middle"><td colspan="20"></td></tr></table></p> </p><dd><p class="Body"><a name="86466"> </a>To avoid macro-expansion side effects, do not apply these macros directly to an expression.  The following increments <b class="symbol_lc">pBuf</b> four times (on little-endian architectures):</p><dl class="margin"><dd><pre class="Code2"><b><a name="86467">pBufHostLong = ntohl (*pBuf++);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* UNSAFE */</a></b></pre></dl><dd><p class="Body"><a name="86468"> </a>It is safer to increment separately from the macro call.  The following increments <b class="symbol_lc">pBuf</b> only once, whether the architecture is big- or little-endian:</p><dl class="margin"><dd><pre class="Code2"><b><a name="86469">pBufHostLong = ntohl (*pBuf); pBuf++; </a></b></pre></dl></dl></dl><a name="foot"><hr></a><p class="FootnoteNumberMarker">1:&nbsp;<span class="Footnote"><a name="86276"> </a>Other declarations are possible, but <b class="symbol_lc">struct in_addr</b> is more forward compatible and less subject to a change in the size of the address. </span><p class="FootnoteNumberMarker">2:&nbsp;<span class="Footnote"><a name="86412"> </a>For more information about the routing table structure and the algorithms used to search the routing table, see <i class="i">TCP/IP Illustrated, Volume 2</i>, by Gary R. Wright and W. Richard Stevens. </span><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-tcpip1.html"><img border="0" alt="[Prev]" src="icons/prev.gif"></a><a href="c-tcpip3.html"><img border="0" alt="[Next]" src="icons/next.gif"></a></p></body></html><!---by WRS Documentation (), Wind River Systems, Inc.    conversion tool:  Quadralay WebWorks Publisher 4.0.11    template:         CSS Template, Jan 1998 - Jefro --->

⌨️ 快捷键说明

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