Testing NetworkMonitor functionality

These instructions are only for Linux and macOS.

Run the network-monitor integration test binary, e.g.:

# sudo not required
./build/tests/integration/network-monitor

You should see an onInterfaceAdded message for each ethernet and loopback network interface present on the system, followed by an onAddressAdded message for each IPv4/IPv6 address on each interface. Finally, onEnumerationCompleted is printed, along with a summary of all interfaces discovered thus far.

Linux

The following commands assume eth0 is the name of an ethernet interface on the machine. If your interfaces are named differently, replace eth0 with the name of any ethernet interface that you have available.

CommandExpected output
sudo ip link add link eth0 name nmtest0 type vlan id 42nmtest0: onInterfaceAdded
sudo ip link set dev nmtest0 mtu 1342nmtest0: onMtuChanged <old_mtu> -> 1342 (old_mtu is most likely 1500)
sudo ip link set dev nmtest0 upnmtest0: onStateChanged down -> <new_state> (new_state is one of: running, dormant, no-carrier)
sudo ip address add 198.51.100.100/24 dev nmtest0nmtest0: onAddressAdded 198.51.100.100/24
sudo ip address del 198.51.100.100/24 dev nmtest0nmtest0: onAddressRemoved 198.51.100.100/24
sudo ip address add 2001:db8::1/80 dev nmtest0nmtest0: onAddressAdded 2001:db8::1/80
sudo ip address del 2001:db8::1/80 dev nmtest0nmtest0: onAddressRemoved 2001:db8::1/80
sudo ip link delete dev nmtest0nmtest0: onInterfaceRemoved

If you unplug the ethernet cable from your network card, you should see:

eth0: onStateChanged running -> no-carrier
nmtest0: onStateChanged running -> no-carrier

Plugging the cable back in should produce the following messages:

eth0: onStateChanged no-carrier -> running
nmtest0: onStateChanged no-carrier -> running

macOS

The following commands assume en0 is the name of an ethernet interface on the machine. If your interfaces are named differently, replace en0 with the name of any ethernet interface that you have available.

CommandExpected output
sudo ifconfig vlan1 createvlan1: onInterfaceAdded
sudo ifconfig vlan1 vlan 1 vlandev en0vlan1: onStateChanged down -> running
sudo ifconfig vlan1 198.51.100.100/24vlan1: onAddressAdded 198.51.100.100/24
sudo ifconfig vlan1 198.51.100.100/24 removevlan1: onAddressRemoved 198.51.100.100/24
sudo ifconfig vlan1 inet6 2001:db8::1/80vlan1: onAddressAdded 2001:db8::1/80 (and potentially link-local addresses)
sudo ifconfig vlan1 inet6 2001:db8::1/80 removevlan1: onAddressRemoved 2001:db8::1/80
sudo ifconfig vlan1 destroyvlan1: onInterfaceRemoved

If you unplug the ethernet cable from your network card, you should see:

en6: onStateChanged running -> down

Plugging the cable back in should produce the following messages:

en6: onStateChanged down -> running