Davide Pesavento | 2bf35a6 | 2017-04-02 00:41:06 -0400 | [diff] [blame^] | 1 | ## NetworkMonitor test |
| 2 | |
| 3 | These instructions are only for Linux. |
| 4 | |
| 5 | Run the network-monitor integrated test binary, e.g.: |
| 6 | ``` |
| 7 | ./build/tests/integrated/network-monitor |
| 8 | ``` |
| 9 | Note: sudo is not required. |
| 10 | |
| 11 | You should see an `onInterfaceAdded` message for each ethernet and loopback |
| 12 | network interface present on the system, followed by an `onAddressAdded` |
| 13 | message for each IPv4/IPv6 address on each interface. Finally, |
| 14 | `onEnumerationCompleted` is printed, along with a summary of all interfaces |
| 15 | discovered thus far. |
| 16 | |
| 17 | [The following commands assume eth0 is the name of an ethernet interface |
| 18 | on the machine. If your interfaces are named differently, replace eth0 |
| 19 | with the name of any ethernet interface that you have available.] |
| 20 | |
| 21 | Command | Expected output |
| 22 | --------|---------------- |
| 23 | sudo ip link add link eth0 name nmtest0 type vlan id 42 | `nmtest0: onInterfaceAdded` |
| 24 | sudo ip link set dev nmtest0 mtu 1342 | `nmtest0: onMtuChanged <old_mtu> -> 1342` (`old_mtu` is most likely 1500) |
| 25 | sudo ip link set dev nmtest0 up | `nmtest0: onStateChanged down -> <new_state>` (`new_state` is one of: running, dormant, no-carrier) |
| 26 | sudo ip address add 198.51.100.100/24 dev nmtest0 | `nmtest0: onAddressAdded 198.51.100.100/24` |
| 27 | sudo ip address del 198.51.100.100/24 dev nmtest0 | `nmtest0: onAddressRemoved 198.51.100.100/24` |
| 28 | sudo ip address add 2001:db8::1/80 dev nmtest0 | `nmtest0: onAddressAdded 2001:db8::1/80` |
| 29 | sudo ip address del 2001:db8::1/80 dev nmtest0 | `nmtest0: onAddressRemoved 2001:db8::1/80` |
| 30 | sudo ip link delete dev nmtest0 | `nmtest0: onInterfaceRemoved` |
| 31 | |
| 32 | If you unplug the ethernet cable from your network card, you should see: |
| 33 | ``` |
| 34 | eth0: onStateChanged running -> no-carrier |
| 35 | nmtest0: onStateChanged running -> no-carrier |
| 36 | ``` |
| 37 | |
| 38 | Plugging the cable back in should produce the following messages: |
| 39 | ``` |
| 40 | eth0: onStateChanged no-carrier -> running |
| 41 | nmtest0: onStateChanged no-carrier -> running |
| 42 | ``` |