source: rtems-docs/shell/network_commands.rst @ 170418a

4.115
Last change on this file since 170418a was bcfdcef, checked in by Chris Johns <chrisj@…>, on 01/23/16 at 03:24:00

Clean up.

  • Property mode set to 100644
File size: 20.9 KB
Line 
1.. COMMENT: COPYRIGHT (c) 1988-2008.
2.. COMMENT: On-Line Applications Research Corporation (OAR).
3.. COMMENT: All rights reserved.
4
5Network Commands
6################
7
8Introduction
9============
10
11The RTEMS shell has the following network commands:
12
13- netstats_ - obtain network statistics
14
15- ifconfig_ - configure a network interface
16
17- route_ - show or manipulate the IP routing table
18
19- ping_ - ping a host or IP address
20
21Commands
22========
23
24This section details the Network Commands available.  A subsection is dedicated
25to each of the commands and describes the behavior and configuration of that
26command as well as providing an example usage.
27
28.. _netstats:
29
30netstats - obtain network statistics
31------------------------------------
32.. index:: netstats
33
34**SYNOPSYS:**
35
36.. code:: shell
37
38    netstats [-Aimfpcut]
39
40**DESCRIPTION:**
41
42This command is used to display various types of network statistics.  The
43information displayed can be specified using command line arguments in various
44combinations.  The arguments are interpreted as follows:
45
46*-A*
47    print All statistics
48
49*-i*
50    print Inet Routes
51
52*-m*
53    print MBUF Statistics
54
55*-f*
56    print IF Statistics
57
58*-p*
59    print IP Statistics
60
61*-c*
62    print ICMP Statistics
63
64*-u*
65    print UDP Statistics
66
67*-t*
68    print TCP Statistics
69
70**EXIT STATUS:**
71
72This command returns 0 on success and non-zero if an error is encountered.
73
74**NOTES:**
75
76NONE
77
78**EXAMPLES:**
79
80The following is an example of using the ``netstats`` command to print the IP
81routing table:
82
83.. code:: shell
84
85    [/] $ netstats -i
86    Destination     Gateway/Mask/Hw    Flags     Refs     Use Expire Interface
87    default         192.168.1.14       UGS         0        0      0 eth1
88    192.168.1.0     255.255.255.0      U           0        0      1 eth1
89    192.168.1.14    00:A0:C8:1C:EE:28  UHL         1        0   1219 eth1
90    192.168.1.51    00:1D:7E:0C:D0:7C  UHL         0      840   1202 eth1
91    192.168.1.151   00:1C:23:B2:0F:BB  UHL         1       23   1219 eth1
92
93The following is an example of using the ``netstats`` command to print the MBUF
94statistics:
95
96.. code:: shell
97
98    [/] $ netstats -m
99    ************ MBUF STATISTICS ************
100    mbufs:2048    clusters: 128    free:  63
101    drops:   0       waits:   0  drains:   0
102    free:1967          data:79          header:2           socket:0
103    pcb:0           rtable:0           htable:0           atable:0
104    soname:0           soopts:0           ftable:0           rights:0
105    ifaddr:0          control:0          oobdata:0
106
107The following is an example of using the ``netstats`` command to print the
108print the interface statistics:
109
110.. code:: shell
111
112    [/] $ netstats -f
113    ************ INTERFACE STATISTICS ************
114    ***** eth1 *****
115    Ethernet Address: 00:04:9F:00:5B:21
116    Address:192.168.1.244   Broadcast Address:192.168.1.255   Net mask:255.255.255.0
117    Flags: Up Broadcast Running Active Multicast
118    Send queue limit:50   length:1    Dropped:0
119    Rx Interrupts:889            Not First:0               Not Last:0
120    Giant:0              Non-octet:0
121    Bad CRC:0                Overrun:0              Collision:0
122    Tx Interrupts:867             Deferred:0         Late Collision:0
123    Retransmit Limit:0               Underrun:0             Misaligned:0
124
125The following is an example of using the ``netstats`` command to print the
126print IP statistics:
127
128.. code:: shell
129
130    [/] $ netstats -p
131    ************ IP Statistics ************
132    total packets received                    894
133    packets rcvd for unreachable dest          13
134    datagrams delivered to upper level        881
135    total ip packets generated here           871
136
137The following is an example of using the ``netstats`` command to print the ICMP
138statistics:
139
140.. code:: shell
141
142    [/] $ netstats -c
143    ************ ICMP Statistics ************
144    Type 0 sent                 843
145    number of responses         843
146    Type 8 received             843
147
148The following is an example of using the ``netstats`` command to print the UDP
149statistics:
150
151.. code:: shell
152
153    [/] $ netstats -u
154    ************ UDP Statistics ************
155
156The following is an example of using the ``netstats`` command to print the TCP
157statistics:
158
159.. code:: shell
160
161    [/] $ netstats -t
162    ************ TCP Statistics ************
163    connections accepted           1
164    connections established           1
165    segs where we tried to get rtt          34
166    times we succeeded          35
167    delayed acks sent           2
168    total packets sent          37
169    data packets sent          35
170    data bytes sent        2618
171    ack-only packets sent           2
172    total packets received          47
173    packets received in sequence          12
174    bytes received in sequence         307
175    rcvd ack packets          35
176    bytes acked by rcvd acks        2590
177    times hdr predict ok for acks          27
178    times hdr predict ok for data pkts          10
179
180**CONFIGURATION:**
181
182.. index:: CONFIGURE_SHELL_NO_COMMAND_NETSTATS
183.. index:: CONFIGURE_SHELL_COMMAND_NETSTATS
184
185This command is included in the default shell command set.  When building a
186custom command set, define ``CONFIGURE_SHELL_COMMAND_NETSTATS`` to have this
187command included.
188
189This command can be excluded from the shell command set by defining
190``CONFIGURE_SHELL_NO_COMMAND_NETSTATS`` when all shell commands have been
191configured.
192
193**PROGRAMMING INFORMATION:**
194
195.. index:: rtems_shell_rtems_main_netstats
196
197The ``netstats`` is implemented by a C language function
198which has the following prototype:
199
200.. code:: c
201
202    int rtems_shell_rtems_main_netstats(
203        int    argc,
204        char **argv
205    );
206
207The configuration structure for the ``netstats`` has the following prototype:
208
209.. code:: c
210
211    extern rtems_shell_cmd_t rtems_shell_NETSTATS_Command;
212
213.. _ifconfig:
214
215ifconfig - configure a network interface
216----------------------------------------
217.. index:: ifconfig
218
219**SYNOPSYS:**
220
221.. code:: shell
222
223    ifconfig
224    ifconfig interface
225    ifconfig interface \[up|down]
226    ifconfig interface \[netmask|pointtopoint|broadcast] IP
227
228**DESCRIPTION:**
229
230This command may be used to display information about the network interfaces in
231the system or configure them.
232
233**EXIT STATUS:**
234
235This command returns 0 on success and non-zero if an error is encountered.
236
237**NOTES:**
238
239Just like its counterpart on GNU/Linux and BSD systems, this command is
240complicated.  More example usages would be a welcome submission.
241
242**EXAMPLES:**
243
244The following is an example of how to use ``ifconfig``:
245
246.. code:: shell
247
248    ************ INTERFACE STATISTICS ************
249    ***** eth1 *****
250    Ethernet Address: 00:04:9F:00:5B:21
251    Address:192.168.1.244   Broadcast Address:192.168.1.255   Net mask:255.255.255.0
252    Flags: Up Broadcast Running Active Multicast
253    Send queue limit:50   length:1    Dropped:0
254    Rx Interrupts:5391           Not First:0               Not Last:0
255    Giant:0              Non-octet:0
256    Bad CRC:0                Overrun:0              Collision:0
257    Tx Interrupts:5256            Deferred:0         Late Collision:0
258    Retransmit Limit:0               Underrun:0             Misaligned:0
259
260**CONFIGURATION:**
261
262.. index:: CONFIGURE_SHELL_NO_COMMAND_IFCONFIG
263.. index:: CONFIGURE_SHELL_COMMAND_IFCONFIG
264
265This command is included in the default shell command set.  When building a
266custom command set, define ``CONFIGURE_SHELL_COMMAND_IFCONFIG`` to have this
267command included.
268
269This command can be excluded from the shell command set by defining
270``CONFIGURE_SHELL_NO_COMMAND_IFCONFIG`` when all shell commands have been
271configured.
272
273**PROGRAMMING INFORMATION:**
274
275.. index:: rtems_shell_rtems_main_ifconfig
276
277The ``ifconfig`` is implemented by a C language function which has the
278following prototype:
279
280.. code:: c
281
282    int rtems_shell_rtems_main_ifconfig(
283        int    argc,
284        char **argv
285    );
286
287The configuration structure for the ``ifconfig`` has the following prototype:
288
289.. code:: c
290
291    extern rtems_shell_cmd_t rtems_shell_IFCONFIG_Command;
292
293.. _route:
294
295route - show or manipulate the ip routing table
296-----------------------------------------------
297.. index:: route
298
299**SYNOPSYS:**
300
301.. code:: shell
302
303    route [subcommand] [args]
304
305**DESCRIPTION:**
306
307This command is used to display and manipulate the routing table.  When invoked
308with no arguments, the current routing information is displayed.  When invoked
309with the subcommands ``add`` or ``del``, then additional arguments must be
310provided to describe the route.
311
312Command templates include the following:
313
314.. code:: shell
315
316    route [add|del] -net IP_ADDRESS gw GATEWAY_ADDRESS [netmask MASK]
317    route [add|del] -host IP_ADDRESS gw GATEWAY_ADDRES [netmask MASK]
318
319When not provided the netmask defaults to ``255.255.255.0``
320
321**EXIT STATUS:**
322
323This command returns 0 on success and non-zero if an error is encountered.
324
325**NOTES:**
326
327Just like its counterpart on GNU/Linux and BSD systems, this command is
328complicated.  More example usages would be a welcome submission.
329
330**EXAMPLES:**
331
332The following is an example of how to use ``route`` to display, add, and delete
333a new route:
334
335.. code:: c
336
337    [/] $ route
338    Destination     Gateway/Mask/Hw    Flags     Refs     Use Expire Interface
339    default         192.168.1.14       UGS         0        0      0 eth1
340    192.168.1.0     255.255.255.0      U           0        0      1 eth1
341    192.168.1.14    00:A0:C8:1C:EE:28  UHL         1        0   1444 eth1
342    192.168.1.51    00:1D:7E:0C:D0:7C  UHL         0    10844   1202 eth1
343    192.168.1.151   00:1C:23:B2:0F:BB  UHL         2       37   1399 eth1
344    [/] $ route add -net 192.168.3.0 gw 192.168.1.14
345    [/] $ route
346    Destination     Gateway/Mask/Hw    Flags     Refs     Use Expire Interface
347    default         192.168.1.14       UGS         0        0      0 eth1
348    192.168.1.0     255.255.255.0      U           0        0      1 eth1
349    192.168.1.14    00:A0:C8:1C:EE:28  UHL         2        0   1498 eth1
350    192.168.1.51    00:1D:7E:0C:D0:7C  UHL         0    14937   1202 eth1
351    192.168.1.151   00:1C:23:B2:0F:BB  UHL         2       96   1399 eth1
352    192.168.3.0     192.168.1.14       UGS         0        0      0 eth1
353    [/] $ route del -net 192.168.3.0 gw 192.168.1.14
354    [/] $ route
355    Destination     Gateway/Mask/Hw    Flags     Refs     Use Expire Interface
356    default         192.168.1.14       UGS         0        0      0 eth1
357    192.168.1.0     255.255.255.0      U           0        0      1 eth1
358    192.168.1.14    00:A0:C8:1C:EE:28  UHL         1        0   1498 eth1
359    192.168.1.51    00:1D:7E:0C:D0:7C  UHL         0    15945   1202 eth1
360    192.168.1.151   00:1C:23:B2:0F:BB  UHL         2      117   1399 eth1
361
362**CONFIGURATION:**
363
364.. index:: CONFIGURE_SHELL_NO_COMMAND_ROUTE
365.. index:: CONFIGURE_SHELL_COMMAND_ROUTE
366
367This command is included in the default shell command set.  When building a
368custom command set, define ``CONFIGURE_SHELL_COMMAND_ROUTE`` to have this
369command included.
370
371This command can be excluded from the shell command set by defining
372``CONFIGURE_SHELL_NO_COMMAND_ROUTE`` when all shell commands have been
373configured.
374
375**PROGRAMMING INFORMATION:**
376
377.. index:: rtems_shell_rtems_main_route
378
379The ``route`` is implemented by a C language function which has the following
380prototype:
381
382.. code:: c
383
384    int rtems_shell_rtems_main_route(
385        int    argc,
386        char **argv
387    );
388
389The configuration structure for the ``route`` has the following prototype:
390
391.. code:: c
392
393    extern rtems_shell_cmd_t rtems_shell_ROUTE_Command;
394
395.. _ping:
396
397ping - ping a host or IP address
398--------------------------------
399.. index:: ping
400
401**SYNOPSYS:**
402
403.. code:: shell
404
405    ping [-AaDdfnoQqRrv] [-c count] [-G sweepmaxsize] [-g sweepminsize]
406    [-h sweepincrsize] [-i wait] [-l preload] [-M mask | time] [-m ttl]
407    [-p pattern] [-S src_addr] [-s packetsize] [-t timeout]
408    [-W waittime] [-z tos] host
409    ping [-AaDdfLnoQqRrv] [-c count] [-I iface] [-i wait] [-l preload]
410    [-M mask | time] [-m ttl] [-p pattern] [-S src_addr]
411    [-s packetsize] [-T ttl] [-t timeout] [-W waittime]
412    [-z tos] mcast-group
413
414**DESCRIPTION:**
415
416The ping utility uses the ICMP protocol's mandatory ECHO_REQUEST datagram to
417elicit an ICMP ECHO_RESPONSE from a host or gateway.  ECHO_REQUEST datagrams
418("pings") have an IP and ICMP header, followed by a "struct timeval" and then
419an arbitrary number of "pad" bytes used to fill out the packet.  The options
420are as follows:
421
422*-A*
423    Audible.  Output a bell (ASCII 0x07) character when no packet is received
424    before the next packet is transmitted.  To cater for round-trip times that
425    are longer than the interval between transmissions, further missing packets
426    cause a bell only if the maximum number of unreceived packets has
427    increased.
428
429*-a*
430    Audible.  Include a bell (ASCII 0x07) character in the output when any
431    packet is received.  This option is ignored if other format options are
432    present.
433
434*-c count*
435    Stop after sending (and receiving) count ECHO_RESPONSE packets.  If this
436    option is not specified, ping will operate until interrupted.  If this
437    option is specified in conjunction with ping sweeps, each sweep will
438    consist of count packets.
439
440*-D*
441    Set the Don't Fragment bit.
442
443*-d*
444    Set the SO_DEBUG option on the socket being used.
445
446*-f*
447    Flood ping. Outputs packets as fast as they come back or one hundred times
448    per second, whichever is more.  For every ECHO_REQUEST sent a period "." is
449    printed, while for every ECHO_REPLY received a backspace is printed.  This
450    provides a rapid display of how many packets are being dropped.  Only the
451    super-user may use this option.  This can be very hard on a network and
452    should be used with caution.
453
454*-G sweepmaxsize*
455    Specify the maximum size of ICMP payload when sending sweeping pings.  This
456    option is required for ping sweeps.
457
458*-g sweepminsize*
459    Specify the size of ICMP payload to start with when sending sweeping pings.
460    The default value is 0.
461
462*-h sweepincrsize*
463    Specify the number of bytes to increment the size of ICMP payload after
464    each sweep when sending sweeping pings.  The default value is 1.
465
466*-I iface*
467    Source multicast packets with the given interface address.  This flag only
468    applies if the ping destination is a multicast address.
469
470*-i wait*
471    Wait wait seconds between sending each packet.  The default is to wait for
472    one second between each packet.  The wait time may be fractional, but only
473    the super-user may specify values less than 1 second.  This option is
474    incompatible with the -f option.
475
476*-L*
477    Suppress loopback of multicast packets.  This flag only applies if the ping
478    destination is a multicast address.
479
480*-l preload*
481    If preload is specified, ping sends that many packets as fast as possible
482    before falling into its normal mode of behavior.  Only the super-user may
483    use this option.
484
485*-M mask | time*
486    Use ICMP_MASKREQ or ICMP_TSTAMP instead of ICMP_ECHO.  For mask, print the
487    netmask of the remote machine.  Set the net.inet.icmp.maskrepl MIB variable
488    to enable ICMP_MASKREPLY.  For time, print the origination, reception and
489    transmission timestamps.
490
491*-m ttl*
492    Set the IP Time To Live for outgoing packets.  If not specified, the kernel
493    uses the value of the net.inet.ip.ttl MIB variable.
494
495*-n*
496    Numeric output only.  No attempt will be made to lookup symbolic names for
497    host addresses.
498
499*-o*
500    Exit successfully after receiving one reply packet.
501
502*-p pattern*
503    You may specify up to 16 "pad" bytes to fill out the packet you send.  This
504    is useful for diagnosing data-dependent problems in a network.  For
505    example, "-p ff" will cause the sent packet to be filled with all ones.
506
507*-Q*
508    Somewhat quiet output.  Don't display ICMP error messages that are in
509    response to our query messages.  Originally, the -v flag was required to
510    display such errors, but -v displays all ICMP error messages.  On a busy
511    machine, this output can be overbear- ing.  Without the -Q flag, ping
512    prints out any ICMP error mes- sages caused by its own ECHO_REQUEST
513    messages.
514
515*-q*
516    Quiet output.  Nothing is displayed except the summary lines at startup
517    time and when finished.
518
519*-R*
520    Record route.  Includes the RECORD_ROUTE option in the ECHO_REQUEST packet
521    and displays the route buffer on returned packets.  Note that the IP header
522    is only large enough for nine such routes; the traceroute(8) command is
523    usually better at determining the route packets take to a particular
524    destination.  If more routes come back than should, such as due to an
525    illegal spoofed packet, ping will print the route list and then truncate it
526    at the correct spot.  Many hosts ignore or discard the RECORD_ROUTE option.
527
528*-r*
529    Bypass the normal routing tables and send directly to a host on an attached
530    network.  If the host is not on a directly-attached network, an error is
531    returned.  This option can be used to ping a local host through an
532    interface that has no route through it (e.g., after the interface was
533    dropped).
534
535*-S src_addr*
536    Use the following IP address as the source address in outgoing packets.  On
537    hosts with more than one IP address, this option can be used to force the
538    source address to be something other than the IP address of the interface
539    the probe packet is sent on.  If the IP address is not one of this
540    machine's interface addresses, an error is returned and nothing is sent.
541
542*-s packetsize*
543    Specify the number of data bytes to be sent.  The default is 56, which
544    translates into 64 ICMP data bytes when combined with the 8 bytes of ICMP
545    header data.  Only the super-user may specify val- ues more than default.
546    This option cannot be used with ping sweeps.
547
548*-T ttl*
549    Set the IP Time To Live for multicasted packets.  This flag only applies if
550    the ping destination is a multicast address.
551
552*-t timeout*
553    Specify a timeout, in seconds, before ping exits regardless of how many
554    packets have been received.
555
556*-v*
557    Verbose output.  ICMP packets other than ECHO_RESPONSE that are received
558    are listed.
559
560*-W waittime*
561    Time in milliseconds to wait for a reply for each packet sent.  If a reply
562    arrives later, the packet is not printed as replied, but considered as
563    replied when calculating statistics.
564
565*-z tos*
566    Use the specified type of service.
567
568**EXIT STATUS:**
569
570The ping utility exits with one of the following values:
571
5720    At least one response was heard from the specified host.
573
5742    The transmission was successful but no responses were
575     received.
576
577any other value an error occurred.  These values are defined in <sysexits.h>.
578
579**NOTES:**
580
581When using ping for fault isolation, it should first be run on the local host,
582to verify that the local network interface is up and running.  Then, hosts and
583gateways further and further away should be "pinged".  Round-trip times and
584packet loss statistics are computed.  If duplicate packets are received, they
585are not included in the packet loss calculation, although the round trip time
586of these packets is used in calculating the round-trip time statistics.  When
587the specified number of packets have been sent a brief summary is displayed,
588showing the number of packets sent and received, and the minimum, mean,
589maximum, and standard deviation of the round-trip times.
590
591This program is intended for use in network testing, measurement and
592management.  Because of the load it can impose on the network, it is unwise to
593use ping during normal operations or from automated scripts.
594
595This command can fail if more than the FD_SET size number of file descriptors
596are open.
597
598**EXAMPLES:**
599
600The following is an example of how to use ``oing`` to ping:
601
602.. code:: shell
603
604    [/] # ping 10.10.10.1
605    PING 10.10.10.1 (10.10.10.1): 56 data bytes
606    64 bytes from 10.10.10.1: icmp_seq=0 ttl=63 time=0.356 ms
607    64 bytes from 10.10.10.1: icmp_seq=1 ttl=63 time=0.229 ms
608    64 bytes from 10.10.10.1: icmp_seq=2 ttl=63 time=0.233 ms
609    64 bytes from 10.10.10.1: icmp_seq=3 ttl=63 time=0.235 ms
610    64 bytes from 10.10.10.1: icmp_seq=4 ttl=63 time=0.229 ms
611    --- 10.10.10.1 ping statistics ---
612    5 packets transmitted, 5 packets received, 0.0% packet loss
613    round-trip min/avg/max/stddev = 0.229/0.256/0.356/0.050 ms
614    [/] # ping -f -c 10000  10.10.10.1
615    PING 10.10.10.1 (10.10.10.1): 56 data bytes
616    .
617    --- 10.10.10.1 ping statistics ---
618    10000 packets transmitted, 10000 packets received, 0.0% packet loss
619    round-trip min/avg/max/stddev = 0.154/0.225/0.533/0.027 ms
620
621**CONFIGURATION:**
622
623.. index:: CONFIGURE_SHELL_NO_COMMAND_PING
624.. index:: CONFIGURE_SHELL_COMMAND_PING
625
626This command is included in the default shell command set.  When building a
627custom command set, define ``CONFIGURE_SHELL_COMMAND_PING`` to have this
628command included.
629
630This command can be excluded from the shell command set by defining
631``CONFIGURE_SHELL_NO_COMMAND_PING`` when all shell commands have been
632configured.
633
634**PROGRAMMING INFORMATION:**
635
636.. index:: rtems_shell_rtems_main_ping
637
638The ``ping`` is implemented by a C language function which has the following
639prototype:
640
641.. code:: c
642
643    int rtems_shell_rtems_main_ping(
644        int    argc,
645        char **argv
646    );
647
648The configuration structure for the ``ping`` has the following prototype:
649
650.. code:: c
651
652    extern rtems_shell_cmd_t rtems_shell_PING_Command;
653
Note: See TracBrowser for help on using the repository browser.