Skip to content

First UDP packet always lost #3481

Closed
@AndreKR

Description

@AndreKR

Hardware: ESP-12F
Core Version: 2.3.0

I'm sending four UDP packets, with payload "aaa", "bbb", "ccc" and "ddd".

The first of those packets never appears on the receiving machine. It happens absolutely every time, the first packet is always missing.

void setup() 
{ 
  Serial.begin(115200);
  Serial.println("Start");
  Serial.println("Re-setting Wifi credentials");
  WiFi.begin(ssid, password); 

  while(WiFi.status() != WL_CONNECTED)
    delay(50);
  
  Serial.println("My IP address:");
  Serial.println(WiFi.localIP());
  Serial.println("Sending");
  Serial.println(Udp.beginPacket("192.168.10.2", 7827));
  Serial.println(Udp.print("aaa"));
  Serial.println(Udp.endPacket());
  Serial.println(Udp.beginPacket("192.168.10.2", 7827));
  Serial.println(Udp.print("bbb"));
  Serial.println(Udp.endPacket());
  Serial.println(Udp.beginPacket("192.168.10.2", 7827));
  Serial.println(Udp.print("ccc"));
  Serial.println(Udp.endPacket());
  Serial.println(Udp.beginPacket("192.168.10.2", 7827));
  Serial.println(Udp.print("ddd"));
  Serial.println(Udp.endPacket());
  delay(100); // TODO: find out when sending is finished
  goToSleep();
}

Serial output:

Start
Re-setting Wifi credentials
My IP address:
192.168.10.196
Sending
1
3
1
1
3
1
1
3
1
1
3
1
Going to sleep

TCP dump on the receiving machine:

21:27:29.474470 IP 192.168.10.196.4097 > 192.168.10.2.7827: UDP, length 3
        0x0000:  4500 001f 0003 0000 8011 a4b4 c0a8 0ac4  E...............
        0x0010:  c0a8 0a02 1001 1e93 000b 76ca 6262 6200  ..........v.bbb.
        0x0020:  0000 0000 0000 0000 0000 0000 0000       ..............
21:27:29.476750 IP 192.168.10.196.4097 > 192.168.10.2.7827: UDP, length 3
        0x0000:  4500 001f 0004 0000 8011 a4b3 c0a8 0ac4  E...............
        0x0010:  c0a8 0a02 1001 1e93 000b 74c9 6363 6300  ..........t.ccc.
        0x0020:  0000 0000 0000 0000 0000 0000 0000       ..............
21:27:29.477491 IP 192.168.10.196.4097 > 192.168.10.2.7827: UDP, length 3
        0x0000:  4500 001f 0005 0000 8011 a4b2 c0a8 0ac4  E...............
        0x0010:  c0a8 0a02 1001 1e93 000b 72c8 6464 6400  ..........r.ddd.
        0x0020:  0000 0000 0000 0000 0000 0000 0000       ..............

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions