Page 1 of 1

How to get raw ip packets without ip headers in esp32/lwip

Posted: Wed Jun 21, 2023 3:34 pm
by sibeg94414
Hii all,

I am new to esp32 developement, i was trying out socket program to send raw ip packets,
the code for the same is

Code: Select all

    int sock = socket(AF_INET, SOCK_RAW, IPPROTO_RAW);
    if (sock < 0)
    {
        ESP_LOGE(TAG, "Failed to create socket: %d", errno);
        vTaskDelete(NULL);
    }

    struct sockaddr_in dest_addr;
    memset(&dest_addr, 0, sizeof(dest_addr));
    dest_addr.sin_family = AF_INET;
    dest_addr.sin_port = 0;
    dest_addr.sin_addr.s_addr = inet_addr("0.0.0.0"); // Destination IP address

    // Raw data to be sent
    char buffer[] = "Hello, raw data!";

    // Send the raw data
    if (sendto(sock, buffer, sizeof(buffer), 0, (struct sockaddr *)&dest_addr, sizeof(dest_addr)) < 0)
    {
        ESP_LOGE(TAG, "Failed to send data: %d", errno);
        close(sock);
        vTaskDelete(NULL);
    }
but while i receiving the packets on wireshark, it adds ip header, how to send only the raw packets without ip header, any help would be appreciated.

Thank you

Re: How to get raw ip packets without ip headers in esp32/lwip

Posted: Fri Jun 23, 2023 7:32 pm
by MicroController
What do you mean by "send an IP packet without an IP header"?

Re: How to get raw ip packets without ip headers in esp32/lwip

Posted: Sat Jun 24, 2023 7:06 am
by sibeg94414
My bad for phrasing it wrong, I want to send raw packets, but while sending the raw packets, the ip headers are automatically added which i don't want. How to just send the raw socket ?

Thank you

Re: How to get raw ip packets without ip headers in esp32/lwip

Posted: Sun Jun 25, 2023 5:15 pm
by MicroController
Is esp_wifi_80211_tx(...) what you're looking for?