Build with AutoIP not working as expected (at all)

Melbourne
Posts: 9
Joined: Mon May 23, 2022 1:20 am

Build with AutoIP not working as expected (at all)

Postby Melbourne » Wed May 25, 2022 1:08 am

I included AutoIP, (IPV4 link-local, Automatic Private IP Addressing) in the build I've inherited, and it's not working as expected. Wireshark shows ARP probe then Gratuitous ARP, as expected, and the GARP is repeated periodically, as expected, but the device does not respond to ARP for the advertised IP (169.254.x.x).

Before I enabled AutoIP (using menuconfig), the device was working correctly with DHCP.

My main code is

Code: Select all

  dnet_init();
  ESP_ERROR_CHECK(rest_start());
}

Code: Select all

bool dnet_init(void) {
  ... MAC stuff ...

  ESP_ERROR_CHECK(esp_netif_init());
  ESP_ERROR_CHECK(esp_event_loop_create_default());

  start_wifi();

  start_ethernet();

  initialise_mdns();
  netbiosns_init();
  netbiosns_set_name(wifhst);

  
  rest_api_register_get_handler("config", dnet_get_handler);
  rest_api_register_post_handler("config", dnet_post_handler);

  xTaskCreate(&dnet_task, "dnet_task", 4096, NULL, 10, NULL);
  ESP_LOGI(TAG, "DNET task started");

  return true;
}

Code: Select all

static esp_err_t start_ethernet() {
  // configure ethernet parameters
  eth_set_hostname(ethsid);
  char eth_mod[kStringSize];
  if (getParamater("ethmod", eth_mod) != ESP_OK)
    return ESP_FAIL;

  // esp_log_level_set("dhcpc", ESP_LOG_DEBUG);

  if (strcmp(eth_mod, dnet_kDHCPClient) == 0) {
    return eth_start_dhcp_client();
  } else if (strcmp(eth_mod, dnet_kStaticIPAddress) == 0) {
      esp_netif_ip_info_t eth_info;
      memset(&eth_info, 0, sizeof(eth_info));
      char eth_ip[kStringSize];
      if (getParamater("ethipa", eth_ip) != ESP_OK)
          return ESP_FAIL;
      if (dnet_str2ip4(&eth_info.ip, eth_ip) == false)
          return ESP_FAIL;
      if (getParamater("ethipg", eth_ip) != ESP_OK)
          return ESP_FAIL;
      if (dnet_str2ip4(&eth_info.gw, eth_ip) == false)
          return ESP_FAIL;
    if (getParamater("ethipm", eth_ip) != ESP_OK)
      return ESP_FAIL;
    if (dnet_str2ip4(&eth_info.netmask, eth_ip) == false)
      return ESP_FAIL;
    return eth_start_dhcp_static(&eth_info);
  }

  // if ethmod is garbage default to dhcp client mode
  setParamater("ethmod", dnet_kDHCPClient);
  return eth_start_dhcp_client();
}

Melbourne
Posts: 9
Joined: Mon May 23, 2022 1:20 am

Re: Build with AutoIP not working as expected (at all)

Postby Melbourne » Fri May 27, 2022 3:47 am

https://github.com/espressif/arduino-esp32/issues/2396
https://github.com/esp8266/Arduino/issues/6886
https://www.esp32.com/viewtopic.php?t=15443

Note that it's not clear what kind of problem this is. Is it an ARP problem? An AutoIP problem? A problem with the multi-homed stack? Or has the stack crashed completely?

In my case, WiFi is configured as an Access Point, and continues to respond after the ethernet fails to respond to the ARP request.

Melbourne
Posts: 9
Joined: Mon May 23, 2022 1:20 am

Re: Build with AutoIP not working as expected (at all)

Postby Melbourne » Fri May 27, 2022 4:49 am

I've avoided the problem by changing the GARP interval from 60 seconds to 14 seconds, thus eliminating the requirement in my network to send ARP requests.

Win10/Server 2016 uses the (IPv6) neighborhood table rather than an ARP cache. Network traffic suggests that Windows is setting the table entry to 'STALE' after the NDP timeout (15~45 seconds} triggering an ARP request for which there is no reply from the ESP32 device (bug).

Win7 (and other OS from the same time frame) used 2 minutes for ARP timeout, and Win2K was even longer. My device was previously tested from a linux distribution, which because of the longer ARP timeout did not expose the problem.

I need to repeat the testing.

Note that it is not clear if this is a lwip bug, a configuration (or RTOS) problem, or a EBKC application bug

ESP_YJM
Posts: 300
Joined: Fri Feb 26, 2021 10:30 am

Re: Build with AutoIP not working as expected (at all)

Postby ESP_YJM » Fri May 27, 2022 7:07 am

Auto IP i only when you not set static IP and DHCP not get IP, now auto IP will work. You can enable LWIP_DEBUG by menuconfig and AUTOIP_DEBUG(#define AUTOIP_DEBUG LWIP_DBG_ON) in lwip module(components/lwip/lwip/src/include/lwip/opt.h).

Who is online

Users browsing this forum: Bing [Bot] and 127 guests