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

📄 c-tcpip3.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-tcpip2.html"><img border="0" alt="[Prev]" src="icons/prev.gif"></a><a href="c-tcpip4.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="86472">4.3  &nbsp;&nbsp;VxWorks Manual Network Configuration Utilities </a></i></h3></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="86474"> </a>VxWorks includes a variety of utilities you can use to assign Internet addresses to network interfaces, hosts, and broadcasting. VxWorks also includes utilities you can use to explicitly add a gateway or configure a subnet. Not included in this section is information on the automatic network configuration protocols, DHCP and BOOTP. For more information on these utilities and their configuration needs, see <a href="c-netconfig.html#84223"><i class="title">Network Configuration Protocols</i></a>. </p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="86479">4.3.1  &nbsp;&nbsp;<a href="c-network.html#123514">Assigning Internet Addresses </a></a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="86482"> </a>On a VxWorks target, you can use the functions of the <b class="library">ifLib</b> library to associate Internet addresses with network interfaces, host names, and broadcasting. For a listing of these configuration functions, see the reference entry for <b class="library">ifLib</b>. </p></dl></dl><dl class="margin"><dd><font face="Helvetica, sans-serif" size="-1" class="sans"><h5 class="HU"><i><a name="86483">Associating Internet Addresses with Network Interfaces</a></i></h5></font><dl class="margin"><dd><p class="Body"><a name="86485"> </a>A system's physical connection to a network is called a <i class="term">network interface.</i>  Each network interface must be assigned a unique Internet (<i class="term">inet</i>) address. A system can be connected to several networks and thus have several network interfaces.</p><dd><p class="Body"><a name="86487"> </a>On a UNIX system, the Internet address of a network interface is specified using the <b class="command">ifconfig</b> command.  For example, to associate the Internet address 150.12.0.1 with the interface ln0, enter:</p><dl class="margin"><dd><pre class="Code2"><b><a name="86489"></b><tt class="output">%</tt><b> ifconfig ln0 150.12.0.1</a></b></pre></dl><dd><p class="Body"><a name="86490"> </a>This is usually done in the UNIX startup file <b class="file">/etc/rc.boot</b>.  For more information, see the UNIX reference entry for <b class="command">ifconfig</b>.</p><dd><p class="Body"><a name="86491"> </a>In VxWorks, the Internet address of a network interface is specified, and a new route to that interface is constructed, by calling <b class="routine"><i class="routine">ifAddrSet</i></b><b>(</b>&nbsp;<b>)</b>.  For example, to associate the Internet address 150.12.0.1 with the interface ln0, enter:</p><dl class="margin"><dd><pre class="Code2"><b><a name="86493">ifAddrSet ("ln0", "150.12.0.1");</a></b></pre></dl></dl></dl><dl class="margin"><dd><p class="table" callout><table border="0" cellpadding="0" cellspacing="0"><tr valign="top"><td valign="top" width="40"><br><img border="0" alt="*" src="icons/note.gif"></td><td><hr><div class="CalloutCell"><a name="94330"><b class="symbol_UC"><font face="Helvetica, sans-serif" size="-1" class="sans">NOTE:  </font></b></a>The subnet mask used in determining the network portion of the address used in <b class="routine"><i class="routine">ifAddrSet</i></b><b>(&nbsp;)</b> will be that set by <b class="routine"><i class="routine">ifMaskSet</i></b><b>(&nbsp;)</b>, or the default class mask if <b class="routine"><i class="routine">ifMaskSet</i></b><b>(&nbsp;)</b> has not been called.  It is standard to call <b class="routine"><i class="routine">ifMaskSet</i></b><b>(&nbsp;)</b> prior to any calls to <b class="routine"><i class="routine">ifAddrSet</i></b><b>(&nbsp;)</b>.</div></td></tr><tr valign="top"><td></td><td><hr></td></tr><tr valign="middle"><td colspan="20"></td></tr></table></p callout><dl class="margin"><dd><p class="Body"><a name="94325"> </a>For more information, see the Tornado reference entries for <b class="library">ifLib </b>and <b class="routine"><i class="routine">ifAddrSet</i></b><b>(</b>&nbsp;<b>)</b>. </p><dd><p class="Body"><a name="86496"> </a>The VxWorks network startup routine, <b class="routine"><i class="routine">usrNetInit</i></b><b>(</b>&nbsp;<b>)</b> in <b class="library">usrNetwork.c</b>, automatically sets the address of the interface used to boot VxWorks to the Internet address specified in the VxWorks boot parameters.</p></dl></dl><dl class="margin"><dd><font face="Helvetica, sans-serif" size="-1" class="sans"><h5 class="HU"><i><a name="86498">Associating Internet Addresses with Host Names</a></i></h5></font><dl class="margin"><dd><p class="Body"><a name="86500"> </a>The underlying Internet protocol uses the 32-bit Internet addresses of systems on the network.  People, however, prefer to use system names that are more meaningful to them.  Thus VxWorks and most host development systems maintain their own maps between system names and Internet addresses.</p><dd><p class="Body"><a name="86503"> </a>On UNIX systems, <b class="file">/etc/hosts</b> contains the mapping between system names and Internet addresses.  Each line consists of an Internet address and the assigned name(s) for that address: </p><dl class="margin"><dd><pre class="Code2"><b><a name="86504">150.12.0.1 vx1</a></b></pre></dl><dd><p class="Body"><a name="86505"> </a>There must be an entry in this file for each UNIX system and for each VxWorks system on the network.  For more information on <b class="file">/etc/hosts</b>, see your UNIX system reference entry <b class="command">hosts</b>(5).</p><dd><p class="Body"><a name="91708"> </a>In VxWorks, call <b class="routine"><i class="routine">hostAdd</i></b><b>(</b>&nbsp;<b>)</b> to associate system names with Internet addresses.  Make one call to <b class="routine"><i class="routine">hostAdd</i></b><b>(</b>&nbsp;<b>)</b> for each system the VxWorks target communicates with, as follows: </p><dl class="margin"><dd><pre class="Code2"><b><a name="91709">hostAdd ("vx1", "150.12.0.1");</a></b></pre></dl></dl></dl><dl class="margin"><dd><p class="table" callout><table border="0" cellpadding="0" cellspacing="0"><tr valign="top"><td valign="top" width="40"><br><img border="0" alt="*" src="icons/note.gif"></td><td><hr><div class="CalloutCell"><a name="91727"><b class="symbol_UC"><font face="Helvetica, sans-serif" size="-1" class="sans">NOTE:  </font></b></a>In addition to <b class="routine"><i class="routine">hostAdd</i></b><b>(&nbsp;)</b>, VxWorks  also includes DNS. You can use DNS to create and automatically maintain host-name/address associations for your VxWorks target. For more information, see <a href="c-dns.html#94280"><i class="title">DNS: Domain Name System</i></a>.</div></td></tr><tr valign="top"><td></td><td><hr></td></tr><tr valign="middle"><td colspan="20"></td></tr></table></p callout><dl class="margin"><dd><p class="Body"><a name="86520"> </a>To associate more than one name with an Internet address, <b class="routine"><i class="routine">hostAdd</i></b><b>(</b>&nbsp;<b>)</b> can be called several times with different host names and the same Internet address.  The routine <b class="routine"><i class="routine">hostShow</i></b><b>(</b>&nbsp;<b>)</b> displays the current system name and Internet address associations.In the following example, 150.12.0.1 can be accessed with the names <b>host</b>, <b>myHost</b>, and <b>widget</b>:</p><dl class="margin"><dd><pre class="Code2"><b><a name="86526"></b><tt class="output">-&gt;</tt><b> hostShow  </b><tt class="output">value = 0 = 0x0</tt><b></a></b></pre></dl><dd><p class="Body"><a name="86528"> </a>The the standard output device displays the following output:</p><dl class="margin"><dd><pre class="Code2"><b><a name="86529"></b><tt class="output">hostname&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;inet&nbsp;address&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;aliases --------&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-----------&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;------- localhost&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;127.0.0.1  host&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;150.12.0.1   -&gt; </tt><b>hostAdd "myHost", "150.12.0.1" </b><tt class="output">value = 0 = 0x0 -&gt; </tt><b>hostAdd "widget", "150.12.0.1" </b><tt class="output">value = 0 = 0x0 -&gt; </tt><b>hostShow </b><tt class="output">value = 0 = 0x0</tt><b></a></b></pre></dl><dd><p class="Body"><a name="86543"> </a>Now standard output displays the following:<sup><a href="#foot"><b class="FootnoteMarker">1</b></a></sup></p><dl class="margin"><dd><pre class="Code2"><b><a name="86544"></b><tt class="output">hostname&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;inet&nbsp;address&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;aliases --------&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-----------&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;------- localhost&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;127.0.0.1  vx1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;150.12.0.1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;myHost widget  value = 0 = 0x0</tt><b> </a></b></pre></dl><dd><p class="Body"><a name="86550"> </a>The VxWorks network startup routine, <b class="routine"><i class="routine">usrNetInit</i></b><b>(</b>&nbsp;<b>)</b> in <b class="library">usrNetwork.c</b>, automatically adds the name of the host VxWorks was booted from, using the host name specified in the VxWorks boot parameters. </p></dl></dl><dl class="margin"><dd><font face="Helvetica, sans-serif" size="-1" class="sans"><h5 class="HU"><i><a name="86552">Assigning Broadcast Addresses</a></i></h5></font><dl class="margin"><dd><p class="Body"><a name="86555"> </a>Many physical networks support the notion of <i class="term">broadcasting</i> a packet to all hosts on the network.  A special Internet <i class="term">broadcast address</i> is interpreted by the network subsystem to mean "all systems" when specified as the destination address of a datagram message (UDP).  This is shown in the demo program <b class="file">target/src/demo/dg/dgTest.c</b>.</p><dd><p class="Body"><a name="86557"> </a>Unfortunately, there is some ambiguity about which address is to be interpreted as the broadcast address.  The Internet specification now states that the broadcast address is an Internet address with a host part of all ones (1).  However, some older systems use an Internet address with a host part of all zeros as the broadcast address.</p><dd><p class="Body"><a name="86558"> </a>Most newer systems, including VxWorks, <i class="emphasis">accept</i> either address on incoming packets as being a broadcast packet.  But when an application <i class="emphasis">sends </i>a broadcast packet, it must use the correct broadcast address for its system.</p><dd><p class="Body"><a name="86559"> </a>VxWorks normally uses a host part of all ones as the broadcast address.  Thus a datagram sent to Internet address 150.255.255.255 (<b class="symbol_UC">0x5AFFFFFF</b>) is broadcast to all systems on network 150.  However, to allow compatibility with other systems, VxWorks allows the broadcast address to be reassigned for each network interface by calling the routine <b class="routine"><i class="routine">ifBroadcastSet</i></b><b>(</b>&nbsp;<b>)</b>.  For more information, see the reference entry for <b class="routine"><i class="routine">ifBroadcastSet</i></b><b>(</b>&nbsp;<b>)</b>.</p><dd><p class="Body"><a name="86562"> </a>In addition, VxWorks supports multicasting--transmission to a subset of hosts on the network. For more information on multicasting, see <a href="c-netapi2.html#89256"><i class="title">Using a Datagram (UDP) Socket to Access IP Multicasting</i></a>.</p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="86567">4.3.2  &nbsp;&nbsp;Adding Gateways to a Network</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="86570"> </a>One of the primary functions of IP is to transport packets from one host to another. Communication between two hosts on the same physical network requires little effort on the part of IP. In this case, IP can deliver the packet directly to the destination. However, if the destination of a packet is not local, IP cannot deliver the packet directly. In this case, IP hands the packet off to a gateway. </p><dd><p class="Body"><a name="86571"> </a>A gateway is a machine that is able to forward packets from one network to another. Thus, a gateway has a physical connection to two or more networks. If the destination of a packet is local to the network on the other side of the gateway, the gateway can deliver the packet directly. Otherwise, the gateway passes the packet to still another gateway. This process, called routing, continues until the packet is delivered or expires.</p><dd><p class="Body"><a name="86573"> </a>To support routing, most systems contain a table that identifies a default gateway as well as gateways associated with specific IP addresses. To maintain this table and determine network connectivity, a VxWorks system uses the Routing Information Protocol (RIP) either version 1 or 2. The RIP implementation provided with VxWorks is based on the BSD 4.4 <b class="symbol_lc">routed</b> program. </p><dd><p class="Body"><a name="86576"> </a>To setup the initial routing information available on a VxWorks target, use the functions of the <b class="library">routeLib</b> library. Using the <b class="keyword">routeLib</b> routines, you can establish the default gateway you want the target to use. These routines also let you associate a destination IP address with a specific gateway. For a listing of the routing configuration functions, see the reference entry for <b class="library">routeLib</b>.</p></dl>

⌨️ 快捷键说明

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