Skip to content

Ping response ip address appears endian-swapped? #623

@shish

Description

@shish

Bug description

Small project which includes this issue: https://github.com/shish/esp-ping-leds/ (Includes a vscode devcontainer for self-contained build)

Code in question:

fn ping(host: Ipv4Addr) -> anyhow::Result<Option<Duration>> {                                                           
    let mut pinger = esp_idf_svc::ping::EspPing::new(0);                                                                
    let conf = esp_idf_svc::ping::Configuration {                                                                       
        interval: Duration::from_secs(0),                                                                               
        timeout: MAX_HEALTHY_DURATION * 5,                                                                              
        ..Default::default()                                                                                            
    };                                                                                                                  
    let summary = pinger.ping(host, &conf)?;                                                                            
    if summary.received != summary.transmitted {                                                                        
        Ok(None)                                                                                                        
    } else {                                                                                                            
        Ok(Some(summary.time / summary.transmitted))                                                                    
    }                                                                                                                   
}  

Code is set up to ping the default gateway - 10.13.37.1. But responses claim to come from 1.37.13.10 (Which is 10.13.37.1 backwards). Pinging this address manually suggests that it doesn't exist, so I guess that this is a superficial logging issue but the ping is going to the correct destination under the hood?

I (3774) esp_ping_leds: Wifi DHCP info: IpInfo { ip: 10.13.37.2, subnet: Subnet { gateway: 10.13.37.1, mask: Mask(24) }, dns: Some(10.13.37.1), secondary_dns: Some(0.0.0.0) }
I (3794) esp_ping_leds: Wifi ok
I (3794) esp_ping_leds: Main loop...
I (3804) esp_idf_svc::ping: About to run a summary ping 10.13.37.1 with configuration Configuration { count: 5, interval: 0ns, timeout: 500ms, data_size: 56, tos: 0 }
I (3814) esp_idf_svc::ping: Ping session established, got handle 0x3fca7b98
I (3824) esp_idf_svc::ping: Ping session started
I (3824) esp_idf_svc::ping: Waiting for the ping session to complete
I (3894) esp_idf_svc::ping: Ping success callback invoked
I (3894) esp_idf_svc::ping: From 1.37.13.10 icmp_seq=1 ttl=64 time=69ms bytes=56
I (3944) esp_idf_svc::ping: Ping success callback invoked
I (3944) esp_idf_svc::ping: From 1.37.13.10 icmp_seq=2 ttl=64 time=44ms bytes=56
I (3994) esp_idf_svc::ping: Ping success callback invoked
  • Would you like to work on a fix? [y/n] n

To Reproduce

"Small" rather than "minimal" repro -- if the problem isn't obvious just by looking at it, then I'll try to come up with a more minimal repro

https://github.com/shish/esp-ping-leds/

Expected behavior

Ping responses come from the address which was pinged

Environment

  • Crate (esp-idf-svc) version: 0.51
  • ESP-IDF branch or tag: v5.1.1
  • Target device (MCU): esp32c3
  • OS: wokwi simulator, inside a debian devcontainer, inside vscode, inside debian host

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions