blob: 0e5b5ad66cfb78cd1c179392f64ef82f96c952d9 [file] [log] [blame] [view]
Davide Pesavento3f13f352021-05-21 20:53:35 -04001# Testing NetworkMonitor functionality
Davide Pesavento2bf35a62017-04-02 00:41:06 -04002
Davide Pesavento3f13f352021-05-21 20:53:35 -04003> These instructions are only for Linux and macOS.
Davide Pesavento2bf35a62017-04-02 00:41:06 -04004
Davide Pesavento394977c2020-04-25 21:40:31 -04005Run the network-monitor integration test binary, e.g.:
Davide Pesavento3f13f352021-05-21 20:53:35 -04006
7```sh
8# sudo not required
Davide Pesavento394977c2020-04-25 21:40:31 -04009./build/tests/integration/network-monitor
Davide Pesavento2bf35a62017-04-02 00:41:06 -040010```
Davide Pesavento2bf35a62017-04-02 00:41:06 -040011
12You should see an `onInterfaceAdded` message for each ethernet and loopback
13network interface present on the system, followed by an `onAddressAdded`
14message for each IPv4/IPv6 address on each interface. Finally,
15`onEnumerationCompleted` is printed, along with a summary of all interfaces
16discovered thus far.
17
Alexander Afanasyev3b3355c2017-03-26 11:57:13 -050018## Linux
19
Davide Pesavento3f13f352021-05-21 20:53:35 -040020The following commands assume `eth0` is the name of an ethernet interface
21on the machine. If your interfaces are named differently, replace `eth0`
22with the name of any ethernet interface that you have available.
Davide Pesavento2bf35a62017-04-02 00:41:06 -040023
24Command | Expected output
25--------|----------------
26sudo ip link add link eth0 name nmtest0 type vlan id 42 | `nmtest0: onInterfaceAdded`
27sudo ip link set dev nmtest0 mtu 1342 | `nmtest0: onMtuChanged <old_mtu> -> 1342` (`old_mtu` is most likely 1500)
28sudo ip link set dev nmtest0 up | `nmtest0: onStateChanged down -> <new_state>` (`new_state` is one of: running, dormant, no-carrier)
29sudo ip address add 198.51.100.100/24 dev nmtest0 | `nmtest0: onAddressAdded 198.51.100.100/24`
30sudo ip address del 198.51.100.100/24 dev nmtest0 | `nmtest0: onAddressRemoved 198.51.100.100/24`
31sudo ip address add 2001:db8::1/80 dev nmtest0 | `nmtest0: onAddressAdded 2001:db8::1/80`
32sudo ip address del 2001:db8::1/80 dev nmtest0 | `nmtest0: onAddressRemoved 2001:db8::1/80`
33sudo ip link delete dev nmtest0 | `nmtest0: onInterfaceRemoved`
34
35If you unplug the ethernet cable from your network card, you should see:
Davide Pesavento3f13f352021-05-21 20:53:35 -040036
Davide Pesavento2bf35a62017-04-02 00:41:06 -040037```
38eth0: onStateChanged running -> no-carrier
39nmtest0: onStateChanged running -> no-carrier
40```
41
42Plugging the cable back in should produce the following messages:
Davide Pesavento3f13f352021-05-21 20:53:35 -040043
Davide Pesavento2bf35a62017-04-02 00:41:06 -040044```
45eth0: onStateChanged no-carrier -> running
46nmtest0: onStateChanged no-carrier -> running
47```
Alexander Afanasyev3b3355c2017-03-26 11:57:13 -050048
49## macOS
50
Davide Pesavento3f13f352021-05-21 20:53:35 -040051The following commands assume `en0` is the name of an ethernet interface
52on the machine. If your interfaces are named differently, replace `en0`
53with the name of any ethernet interface that you have available.
Alexander Afanasyev3b3355c2017-03-26 11:57:13 -050054
55Command | Expected output
56--------|----------------
57sudo ifconfig vlan1 create | `vlan1: onInterfaceAdded`
58sudo ifconfig vlan1 vlan 1 vlandev en0 | `vlan1: onStateChanged down -> running`
59sudo ifconfig vlan1 198.51.100.100/24 | `vlan1: onAddressAdded 198.51.100.100/24`
60sudo ifconfig vlan1 198.51.100.100/24 remove | `vlan1: onAddressRemoved 198.51.100.100/24`
61sudo ifconfig vlan1 inet6 2001:db8::1/80 | `vlan1: onAddressAdded 2001:db8::1/80` (and potentially link-local addresses)
62sudo ifconfig vlan1 inet6 2001:db8::1/80 remove | `vlan1: onAddressRemoved 2001:db8::1/80`
63sudo ifconfig vlan1 destroy | `vlan1: onInterfaceRemoved`
64
65If you unplug the ethernet cable from your network card, you should see:
Davide Pesavento3f13f352021-05-21 20:53:35 -040066
Alexander Afanasyev3b3355c2017-03-26 11:57:13 -050067```
68en6: onStateChanged running -> down
69```
70
71Plugging the cable back in should produce the following messages:
Davide Pesavento3f13f352021-05-21 20:53:35 -040072
Alexander Afanasyev3b3355c2017-03-26 11:57:13 -050073```
74en6: onStateChanged down -> running
75```