Skip to content

Cannot loop traffic to internal real network interface - not using loopback #9089

@rrelande

Description

@rrelande

Basic Infos

  • This issue complies with the issue POLICY doc.
  • I have read the documentation at readthedocs and the issue is not addressed there.
  • I have tested that the issue is present in current master branch (aka latest git).
  • I have searched the issue tracker for a similar issue.
  • If there is a stack dump, I have decoded it.
  • I have filled out all fields below.

Platform

  • Hardware: [ESP-12]
  • Core Version: 3.1.2
  • Development Env: [Platformio]
  • Operating System: [Windows]

Settings in IDE

  • Module: [Generic ESP8266 Module|]
  • Flash Mode: [qio]
  • Flash Size: [4MB]
  • lwip Variant: [v2 Lower Memory]
  • Reset Method: [ck|nodemcu]
  • Flash Frequency: [40Mhz]
  • CPU Frequency: [80Mhz|]
  • Upload Using: [SERIAL]
  • Upload Speed: [115200

Problem Description

it it previously indicated that local loopback interface 127.0.0.1 is not available in lwip2 and advised against trying to use.
as documented in #6437
previous case suggests to use the local available real interface instead of 127.0.0.1 as loopback.
however as seen below, traffic routed to the local UDP socket is not received by the stack.

the UDP client listens to external traffic and sees traffic coming from netcat on another computer.
but not from internal stack

MCVE Sketch

#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <WiFiUdp.h>

#define WIFI_SSID "xxxxxx"
#define WIFI_PASSWORD "yyyyy"
#define SYSLOG_SERVER "lmSyslog.local"
#define SYSLOG_PORT 514

WiFiUDP udpServer, udpClient;
unsigned int received_bytes = 0;

void setup()
{
    WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
    while (WiFi.status() != WL_CONNECTED)
    {
        delay(500);
    }
    digitalWrite(LED_PIN, HIGH);

    Serial.begin(9600, SERIAL_8N1);
    udpServer.begin(SYSLOG_PORT);
    delay(100);
};

// the loop routine runs over and over again forever:
void loop()
{
    Serial.print("Sending to loopback server on local interface not loopback 127.0.0.1 ");
    delay(100);
    udpClient.beginPacket(WiFi.localIP(), SYSLOG_PORT);
    udpClient.write("Hello, world");
    udpClient.endPacket();
    delay(100);
    received_bytes = udpServer.parsePacket();
    Serial.printf("Relay loop on %s, UDP queue size %d \n", WiFi.localIP().toString().c_str(),  received_bytes);
    for (int i = 0; i < received_bytes; i++)
    {
        char c = udpServer.read();
        Serial.printf("%c", c);
    }

    delay(1000);
};

Debug Messages


ing to loopback server on local interface not loopback 127.0.0.1 Relay loop on 192.168.0.171, UDP queue size 0 
Sending to loopback server on local interface not loopback 127.0.0.1 Relay loop on 192.168.0.171, UDP queue size 0 
Sending to loopback server on local interface not loopback 127.0.0.1 Relay loop on 192.168.0.171, UDP queue size 0 
Sending to loopback server on local interface not loopback 127.0.0.1 Relay loop on 192.168.0.171, UDP queue size 0 
Sending to loopback server on local interface not loopback 127.0.0.1 Relay loop on 192.168.0.171, UDP queue size 0 
Sending to loopback server on local interface not loopback 127.0.0.1 Relay loop on 192.168.0.171, UDP queue size 0 
Sending to loopback server on local interface not loopback 127.0.0.1 Relay loop on 192.168.0.171, UDP queue size 17 
UDP test message
Sending to loopback server on local interface not loopback 127.0.0.1 Relay loop on 192.168.0.171, UDP queue size 0 
Sending to loopback server on local interface not loopback 127.0.0.1 Relay loop on 192.168.0.171, UDP queue size 0 
Sending to loopback server on local interface not loopback 127.0.0.1 Relay loop on 192.168.0.171, UDP queue size 0 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions