Skip to content
Ondrej Lichtner edited this page Oct 10, 2013 · 2 revisions

1. Basic description

This test is built around the utility nc, which is also the main part of its execution. The utility is supplied by an endless stream of characters, from the utility yes, which are being transmitted to a specified destination.

At the same time, the module uses the tcpdump utility to filter these packets. The execution of the test will end either after a specified duration or in case of an error when tcpdump doesn't capture at least 10 packets.

It is required, at least for TCP, to have netcat listening on the target machine. This can be done by executing the netcat in background shell. For details look at the usage example below.

This test can be used to test the correctness of device set-up or for creating an artificial stream of data on the network.

2. Options

This test module accepts these options:

addr expects an address or a hostname of a machine that will be the destination of the nc command. This option is mandatory.
port expects the port of the destination machine. This option is mandatory.
stream specifies which protocol should nc be using. Accepted values are tcp and udp. The default is tcp.
ipv accepts either a value of 4 or 6, representing IPv4 and IPv6 respectively.
duration in seconds, determines how long will the module wait before killing the nc command. The default is 30 seconds.

3. Usage Example

Usage of this test is fairly easy, start with the following command, modify it to suit your environment specification and add it to your command sequence.

<run command="nc -l -u -6 5555" bg_id="netcat_in_background" host="testmachine1" bg_id="netcat_in_background"/>
<run module="NetCat" host="testmachine2">
    <options>
        <option name="addr" value="{ip(testmachine2, testifc2)}"/>
        <option name="port" value="5555"/>
        <option name="stream" value="udp"/>
        <option name="ipv" value="6"/>
        <option name="duration" value="10"/>
    </options>
</run>
<kill host="testmachine1" bg_id="netcat_in_background"/>

4. Results

The results created by the command in the previous section will look something like this:

23/01 16:11:44        (127.0.0.1)    INFO: Executing command: [type (test), machine_id (testmachine2), value (NetCat)]
23/01 16:11:42   (192.168.122.30)   DEBUG: Timeout: 5
23/01 16:11:42   (192.168.122.30)   DEBUG: 
    data:
    tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
    listening on any, link-type LINUX_SLL (Linux cooked), capture size 65535 bytes
23/01 16:11:42   (192.168.122.30)   DEBUG: Killing PID 2963
23/01 16:11:52   (192.168.122.30)   DEBUG: Process PID 2962 return 127
23/01 16:11:52   (192.168.122.30)    INFO: nc stream with duration of 10 secs
23/01 16:11:52   (192.168.122.30)   DEBUG: PASSED
23/01 16:11:54        (127.0.0.1)   DEBUG: Result: {'passed': True}

Clone this wiki locally