tcpip.sgml
来自「eCos操作系统源码」· SGML 代码 · 共 639 行 · 第 1/3 页
SGML
639 行
</PROGRAMLISTING></SECT1><SECT1 id="net-common-standalone-tests"><TITLE>Standalone Tests</TITLE><PROGRAMLISTING><EMPHASIS>socket_test</EMPHASIS> - trivial test of socket creation API <EMPHASIS>mbuf_test</EMPHASIS> - trivial test of mbuf allocation API</PROGRAMLISTING><PARA>These two do not communicate over the net; they just performsimple API tests then exit.</PARA><PROGRAMLISTING><EMPHASIS>ftp_test</EMPHASIS> - simple FTP test, connects to “server”</PROGRAMLISTING><PARA>This test initializes the interface(s) then connects to theFTP server on the “server” machine for for eachactive interface in turn, confirms that the connection was successful,disconnects and exits. This tests interworking with the server.</PARA><PROGRAMLISTING><EMPHASIS>ping_test</EMPHASIS> - pings “server” and non-existent host to test timeout</PROGRAMLISTING><PARA>This test initializes the interface(s) then pings the servermachine in the standard way, then pings address “32 up” fromthe server in the expectation that there is no machine there. Thisconfirms that the successful ping is not a false positive, and teststhe receive timeout. If there is such a machine, of course the2nd set of pings succeeds, confirming that we can talk to a machinenot previously mentioned by configuration or by bootp. It then doesthe same thing on the other interface, eth1.</PARA><PARA>If IPv6 is enabled, the program will also ping to the address itlast received a router advertisement from. Also a ping will be made tothat address plus 32, in a similar way the the IPv4 case.</PARA><PROGRAMLISTING><EMPHASIS>dhcp_test</EMPHASIS> - ping test, but also manipulates DHCP leases</PROGRAMLISTING><PARA>This test is very similar to the ping test, but in addition,provided the network package is not configured to do this automatically,it manually relinquishes and reclaims DHCP leases for all availableinterfaces. This tests the external API to DHCP. See section belowdescribing this.</PARA><PROGRAMLISTING><EMPHASIS>flood</EMPHASIS> - a flood ping test; use with care</PROGRAMLISTING><PARA>This test performs pings on all interfaces as quickly as possible,and only prints status information periodically. Flood pinging isbad for network performance; so do not use this test on generalpurpose networks unless protected by a switch.</PARA></SECT1><SECT1 id="net-common-performance-test"><TITLE>Performance Test</TITLE><PROGRAMLISTING><EMPHASIS>tcp_echo</EMPHASIS> - data forwarding program for performance test</PROGRAMLISTING><PARA><command>tcp_echo</command> is onepart of the standard performance test we use. The other parts arehost programs <LITERAL>tcp_source</LITERAL> and <LITERAL>tcp_sink</LITERAL>. To make these (under your <emphasis>HOST</emphasis> system) cd to the tests source directory inthe eCos repository and type “<LITERAL>make -f make.host</LITERAL>” -this should build <LITERAL>tcp_source</LITERAL> and <LITERAL>tcp_sink</LITERAL>.</PARA><PARA>The host program “<LITERAL>tcp_source</LITERAL>” sendsdata to the target. On the target, “<LITERAL>tcp_echo</LITERAL>” sendsit onwards to “<LITERAL>tcp_sink</LITERAL>” runningon your host. So the target must receive and send on all the data that <LITERAL>tcp_source</LITERAL> sendsit; the time taken for this is measured and the data rate is calculated.</PARA><PARA>To invoke the test, first start <LITERAL>tcp_echo</LITERAL> onthe target board and wait for it to become quiescent - it will reportwork to calibrate a CPU load which can be used to simulate realoperating conditions for the stack.</PARA><PARA>Then on your host machine, in one terminal window, invoke <LITERAL>tcp_sink</LITERAL> givingit the IP address (or hostname) of one interface of the target board. For example “<LITERAL>tcp_sink 10.130.39.66</LITERAL>”. <LITERAL>tcp_echo</LITERAL> on the targetwill print something like “<LITERAL>SINK connectionfrom 10.130.39.13:1143</LITERAL>” when <LITERAL>tcp_sink</LITERAL> iscorrectly invoked.</PARA><PARA>Next, in another host terminal window, invoke <LITERAL>tcp_source</LITERAL>,giving it the IP address (or hostname) of an interface of the targetboard, and optionally a background load to apply to the target whilethe test runs. For example, “<LITERAL>tcp_source194.130.39.66</LITERAL>” to run the test with noadditional target CPU load, or “<LITERAL>tcp_source194.130.39.66 85</LITERAL>” to load it up to 85% used. The target load must be a multiple of 5. <LITERAL>tcp_echo</LITERAL> onthe target will print something like “<LITERAL>SOURCEconnection from 194.130.39.13:1144</LITERAL>” whentcp_source is correctly invoked.</PARA><PARA>You can connect tcp_sink to one target interfaceand tcp_source to another, or both to the same interface. Similarly, you can run <LITERAL>tcp_sink</LITERAL> and <LITERAL>tcp_source</LITERAL> onthe same host machine or different ones. TCP/IP and ARPlook after them finding one another, as intended.</PARA><PROGRAMLISTING><EMPHASIS>nc_test_master</EMPHASIS> - network characterization master<EMPHASIS>nc_test_slave</EMPHASIS> - network characterization slave</PROGRAMLISTING><PARA>These tests talk to each other to measure network performance.They can each run on either a test target or a host computergiven some customization to your local environment. As provided, <literal>nc_test_slave</literal> mustrun on the test target, and <literal>nc_test_master</literal> mustbe run on a host computer, and be given the test target'sIP address or hostname.</PARA><PARA>The tests print network performance for various packet sizesover UDP and TCP, versus various additional CPU loads on the target.</PARA><PARA>The programs <PROGRAMLISTING><EMPHASIS>nc6_test_slave</EMPHASIS><EMPHASIS>nc6_test_master</EMPHASIS></PROGRAMLISTING>are additional forms which support both IPv4 and IPv6 addressing.</PARA></SECT1><SECT1 id="net-common-interactive-tests"><TITLE>Interactive Tests</TITLE><PROGRAMLISTING><EMPHASIS>server_test</EMPHASIS> - a very simple server example</PROGRAMLISTING><PARA>This test simply awaits a connection on port 7734 and afteraccepting a connection, gets a packet (with a timeout of a few seconds)and prints it. </PARA><PARA>The connection is then closed. We then loop to await the nextconnection, and so on. To use it, telnet to the target on port 7734then type something (quickly!)</PARA><screen>% telnet 172.16.19.171 7734 Hello target board</screen><PARA>and the test program will print something like:</PARA><screen>connection from 172.16.19.13:3369 buf = "Hello target board"</screen><PROGRAMLISTING><EMPHASIS>ga_server_test</EMPHASIS> - another very simple server example</PROGRAMLISTING><PARA>This is a variation on the <EMPHASIS>ga_server_test</EMPHASIS> testwith the difference being that it uses the <FUNCTION>getaddrinfo</FUNCTION>function to set up its addresses. On a system with IPv6 enabled, it willlisten on port 7734 for a TCP connection via either IPv4 or IPv6.</PARA><PROGRAMLISTING><EMPHASIS>tftp_client_test</EMPHASIS> - performs a tftp get and put from/to “server”</PROGRAMLISTING><PARA>This is only partially interactive. You need to set thingsup on the “server” in order for this to work,and you will need to look at the server afterwards to confirm that allwas well.</PARA><PARA>For each interface in turn, this test attempts to read bytftp from the server, a file called<filename>tftp_get</filename>andprints the status and contents it read (if any). It then writesthe same data to a file called<filename>tftp_put</filename>onthe same server.</PARA><PARA>In order for this to succeed, both files must already exist. The TFTP protocol does not require that a WRQ request _create_ afile, just that it can write it. The TFTP server on Linux certainlywill only allow writes to an existing file, given the appropriatepermission. Thus, you need to have these files in place, with proper permission,before running the test.</PARA><PARA>The conventional place for the tftp server to operate in LINUXis /tftpboot/; you will likely need root privilegesto create files there. The data contents of<filename>tftp_get</filename>canbe anything you like, but anything very large will waste lots oftime printing it on the test’s stdout, and anything above32kB will cause a buffer overflow and unpredictable failure.</PARA><PARA>Creating an empty tftp_put file (eg. by copying /dev/nullto it) is neatest. So before the test you should have somethinglike:</PARA><PROGRAMLISTING>-rw-rw-rw- 1 root 1076 May 1 11:39 tftp_get-rw-rw-rw- 1 root 0 May 1 15:52 tftp_put </PROGRAMLISTING><PARA>note that both files have public permissions wide open. Afterrunning the test,<filename>tftp_put</filename>shouldbe a copy of<filename>tftp_get</filename>.</PARA><PROGRAMLISTING>-rw-rw-rw- 1 root 1076 May 1 11:39 tftp_get-rw-rw-rw- 1 root 1076 May 1 15:52 tftp_put</PROGRAMLISTING><PARA>If the configuration contains IPv6 support, the test programwill also use IPv6. It will attempt to put/get the files listed abovefrom the address it last received a routers solicit from.</PARA><PROGRAMLISTING><EMPHASIS>tftp_server_test</EMPHASIS> - runs a tftp server for a short while</PROGRAMLISTING><PARA>This test is truly interactive, in that you can use a standardtftp application to get and put files from the server, during the5 minutes that it runs. The dummy filesystem which underlies theserver initially contains one file, called “uu” which containspart of a familiar text and some padding. It also accommodatescreation of 3 further files of up to 1Mb in size and names of upto 256 bytes. Exceeding these limits will cause a buffer overflowand unpredictable failure.</PARA><PARA>The dummy filesystem is an implementation of the generic APIwhich allows a true filesystem to be attached to the tftp serverin the network stack.</PARA><PARA>We have been testing the tftp server by running the test onthe target board, then using two different host computers connectingto the different target interfaces, putting a file from each, gettingthe “uu” file, and getting the file from the other computer. This verifies that data is preserved during the transfer as wellas interworking with standard tftp applications.</PARA></SECT1><SECT1 id="net-common-maintenance-tools"><TITLE>Maintenance Tools </TITLE><PROGRAMLISTING><EMPHASIS>set_mac_address</EMPHASIS> - set MAC address(es) of interfaces in NVRAM</PROGRAMLISTING><PARA>This program makes an example <function>ioctl()</function> call<acronym>SIOCSIFHWADDR</acronym> “Socket IO Set InterFace HardWare ADDRess”to set the MAC address on targetswhere this is supported and enabled in the configuration. You mustedit the source to choose a MAC address and further edit it to allowthis very dangerous operation. Not all ethernet drivers supportthis operation, because most ethernet hardware does not supportit — or it comes pre-set from the factory.<emphasis>Do not use this program.</emphasis></PARA></SECT1></CHAPTER><CHAPTER id="net-common-support"><title>Support Features</title><SECT1 id="net-common-tftp"><TITLE>TFTP</TITLE><PARA>The TFTP client and server are described in<filename>tftp_support.h</filename>;</PARA><PARA>The TFTP client has and new and an older, deprecated, API. Thenew API works for both IPv4 and IPv6 where as the deprecated API isIPv4 only.</PARA><PARA>The new API is as follows:
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?