Monitoring Session - Using NST Utility Program: "monitor_serial"

I found that it would be beneficial to automate the process of serial traffic data monitoring. A bash script: "monitor_serial" was created to do this for NST. It essentially just automates the process just described above. The big advantage with monitor_serial beside automation is that traffic serial data will continue to be displayed on the screen and only blocked for a user specified collection time. The Serial Tap Cable described above is best used with the monitor_serial utility program. The reset_serial utility is called by monitor_serial for the base initialization.

The usage information for monitor_serial is presented:


[root@probe tmp]# /usr/local/bin/monitor_serial -h

Usage: monitor_serial -d1 <1st serial dev> [-s <usec>] [-b <baud>] [-u <"stty options">]
                     [-f1 <1st serial dev capture file>] [-n1 <1st serial dev nickname>]
                     [-d2 <2nd serial dev>] [-f2 <2nd serial dev capture file>]
                     [-n2 <2nd serial dev nickname>]

   This utility program will monitor serial traffic for up to 2 serial devices. Data will
   be collected for a user specific collection time (See: -s option). The "hexdump" utility
   is then used to display the serial traffic in both the Hex and ASCII format. To exit
   type the "Ctrl-c" key sequence.

  -s <microseconds> | --sleep <microseconds>
     Sleep value in microseconds to collect data before
     sending it to the hexdump utility. Default: 500000 usecs (1/2 sec)

  -b <baud rate> | --baud <baud rate>
     Baud rate for the serial device. Default: 9600 baud

  -u <"stty options"> | --stty-opts <"stty options">
     User specified stty options must be put within double quotes:
     Example (even parity): -u "parenb -parodd"

  -d1 <serial dev name> | --device-1 <serial dev name>
     Name of the first serial device to
     to monitor: Ex: "/dev/ttyS1"

  -f1 <1st capture file name> | --file-1 <1st capture file name>
     Capture file full path name for the 1st serial device.
     Default: /tmp/serial_capture_dev1

  -n1 <1st nickname> | --nickname-1 <1st nickname>
     Used to describe a more meaningful name to the first serial
     device.

  -d2 <serial dev name> | --device-2 <serial dev name>
     Optional name of a second serial device
     to monitor. Ex: "/dev/ttyUSB0"

  -f2 <2nd capture file name> | --file-2 <2nd capture file name>
     Optional capture full path file name for the
     2nd serial device.
     Default: /tmp/serial_capture_dev2

  -n2 <2nd nickname> | --nickname-2 <2nd nickname>
     Used to describe a more meaningful name to the second serial
     device.

  -h | --help
     Displays this help information



Now lets demonstrate by example the features of the monitor_serial utility program. We will analyze the NTP clock status command issued on a Cisco Router 3620. The Minicom program will be used to issue the command: "show ntp status\r". The serial port communication parameters are: (115200 baud, no parity, 8 data bits, and 1 stop bit - 115200N81).

** Note 1: The monitor_serial utility program will put the capture serial device in: "raw" mode.

** Note 2: Remember that the raw capture files are available after stopping monitor_serial. The default files are names are: /tmp/serial_capture_dev1 and /tmp/serial_capture_dev2.

In this example the DTE Serial Tap (NST Probe) is connected to serial device: /dev/ttyUSB0 and the DCE Serial Tap (Cisco 3620 Router) is connected to serial device: /dev/ttyS1.


[root@probe tmp]# /usr/local/bin/monitor_serial -d1 /dev/ttyUSB0 -s 2000000 -b 115200 -n1 "NST Probe" \
>  -d2 /dev/ttyS1 -n2 "Cisco 3620"

*** Serial Data Capture From Device: /dev/ttyUSB0  -- NST Probe --  and Device: /dev/ttyS1  -- Cisco 3620 -- ***

*** Waiting for data, collection interval: 2000000 (usecs) ***

%%%%%% Capture From Serial Device 2: /dev/ttyS1  -- Cisco 3620 -- %%%%%%
00000000  0d 0a 73 68 6f 70 72 6f  75 74 65 3e 20           |..shoproute> |
0000000d

###### Capture From Serial Device 1: /dev/ttyUSB0  -- NST Probe -- ######
00000000  73 68 6f 77 20 6e 74 70  20 73 74 61 74 75 73 0d  |show ntp status.|
00000010

%%%%%% Capture From Serial Device 2: /dev/ttyS1  -- Cisco 3620 -- %%%%%%
00000000  73 68 6f 77 20 6e 74 70  20 73 74 61 74 75 73 0d  |show ntp status.|
00000010  0a 43 6c 6f 63 6b 20 69  73 20 73 79 6e 63 68 72  |.Clock is synchr|
00000020  6f 6e 69 7a 65 64 2c 20  73 74 72 61 74 75 6d 20  |onized, stratum |
00000030  32 2c 20 72 65 66 65 72  65 6e 63 65 20 69 73 20  |2, reference is |
00000040  32 30 34 2e 33 34 2e 31  39 38 2e 34 30 0d 0a 6e  |204.34.198.40..n|
00000050  6f 6d 69 6e 61 6c 20 66  72 65 71 20 69 73 20 32  |ominal freq is 2|
00000060  35 30 2e 30 30 30 30 20  48 7a 2c 20 61 63 74 75  |50.0000 Hz, actu|
00000070  61 6c 20 66 72 65 71 20  69 73 20 32 35 30 2e 30  |al freq is 250.0|
00000080  30 31 30 20 48 7a 2c 20  70 72 65 63 69 73 69 6f  |010 Hz, precisio|
00000090  6e 20 69 73 20 32 2a 2a  31 38 0d 0a 72 65 66 65  |n is 2**18..refe|
000000a0  72 65 6e 63 65 20 74 69  6d 65 20 69 73 20 43 33  |rence time is C3|
000000b0  32 38 33 30 37 43 2e 45  31 42 45 31 42 41 36 20  |28307C.E1BE1BA6 |
000000c0  28 31 33 3a 32 39 3a 33  32 2e 38 38 31 20 45 44  |(13:29:32.881 ED|
000000d0  54 20 46 72 69 20 4f 63  74 20 33 20 32 30 30 33  |T Fri Oct 3 2003|
000000e0  29 0d 0a 63 6c 6f 63 6b  20 6f 66 66 73 65 74 20  |)..clock offset |
000000f0  69 73 20 30 2e 34 36 31  37 20 6d 73 65 63 2c 20  |is 0.4617 msec, |
00000100  72 6f 6f 74 20 64 65 6c  61 79 20 69 73 20 31 31  |root delay is 11|
00000110  30 2e 32 36 20 6d 73 65  63 0d 0a 72 6f 6f 74 20  |0.26 msec..root |
00000120  64 69 73 70 65 72 73 69  6f 6e 20 69 73 20 34 2e  |dispersion is 4.|
00000130  30 39 20 6d 73 65 63 2c  20 70 65 65 72 20 64 69  |09 msec, peer di|
00000140  73 70 65 72 73 69 6f 6e  20 69 73 20 33 2e 35 31  |spersion is 3.51|
00000150  20 6d 73 65 63 0d 0a 73  68 6f 70 72 6f 75 74 65  | msec..shoproute|
00000160  3e 20                                             |> |
00000162

The Minicom screen appearance for the above command:


shoproute> show ntp status
Clock is synchronized, stratum 2, reference is 204.34.198.40
nominal freq is 250.0000 Hz, actual freq is 250.0010 Hz, precision is 2**18
reference time is C328307C.E1BE1BA6 (13:29:32.881 EDT Fri Oct 3 2003)
clock offset is 0.4617 msec, root delay is 110.26 msec
root dispersion is 4.09 msec, peer dispersion is 3.51 msec
shoproute>