Add AutoIP option to network options for link local addressing
Purpose
Allow a zero-configuration of IP addressing a vehicle using IPv4 link local addressing.
This is enabled with bit 1 of the NET_OPTIONS parameter enabled to turn on AUTOIP.
Link local is great because you don't need to bother with all the fiddly NET_IPADDR params.
Sensor data (such as the Trimble PX-1) can take advantage of Multicast to send sensor data to the cube, and neither the Cube nor the PX1 need to know the other's address. This makes it easier to swap hardware with less configuration.
If a DHCP server is not available on the vehicle, because LWIP_DHCP_AUTOIP_COOP is enabled on our builds, this means that LWIP will automatically start a link local address in place of that. In theory, if a DHCP server started later (such as one running on a non-RTOS linux such as PI that takes a while to boot), LWIP will drop the link local address and switch to DHCP. I haven't tested that specific case yet.
Setting up a DHCP server or static addressing on a vehicle is not easy for everyone. Setting a single bit in ArduPilot NET options is easier than that.
How to reproduce
- Grab a Cube Red
- Flash it with this branch
- Set the params
NET_DHCP 1 # Enable
NET_ENABLE 1
NET_GWADDR0 192
NET_GWADDR1 168
NET_GWADDR2 13
NET_GWADDR3 1
NET_IPADDR0 192
NET_IPADDR1 168
NET_IPADDR2 13
NET_IPADDR3 14
NET_MACADDR0 168
NET_MACADDR1 176
NET_MACADDR2 40
NET_MACADDR3 98
NET_MACADDR4 199
NET_MACADDR5 62
NET_NETMASK 24
NET_OPTIONS 2.0
NET_P1_TYPE 0 # Disabled
NET_P2_TYPE 0 # Disabled
NET_P3_TYPE 0 # Disabled
NET_P4_TYPE 0 # Disabled
-
Connect the cube to your computer over ethernet
-
Configure your ethernet adapter to link local
-
Reboot the cube
-
Open mavproxy consol
-
Observe in the logs it gets a
169.254address, and so does your computer -
Ping the Cube's address