ardupilot icon indicating copy to clipboard operation
ardupilot copied to clipboard

Add AutoIP option to network options for link local addressing

Open Ryanf55 opened this issue 1 year ago • 0 comments

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

  1. Grab a Cube Red
  2. Flash it with this branch
  3. 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
  1. Connect the cube to your computer over ethernet

  2. Configure your ethernet adapter to link local image

  3. Reboot the cube

  4. Open mavproxy consol

  5. Observe in the logs it gets a 169.254 address, and so does your computer image

  6. Ping the Cube's address

Demo

image

Ryanf55 avatar May 12 '24 07:05 Ryanf55