source: rtems-docs/shell/network_commands.rst @ 9aafb39

4.115
Last change on this file since 9aafb39 was 489740f, checked in by Chris Johns <chrisj@…>, on 05/20/16 at 02:47:09

Set SPDX License Identifier in each source file.

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