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

sibeg94414
Posts: 3
Joined: Wed Jun 21, 2023 3:26 pm

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

Postby sibeg94414 » Wed Jun 21, 2023 3:34 pm

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

MicroController
Posts: 1733
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

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

Postby MicroController » Fri Jun 23, 2023 7:32 pm

What do you mean by "send an IP packet without an IP header"?

sibeg94414
Posts: 3
Joined: Wed Jun 21, 2023 3:26 pm

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

Postby sibeg94414 » Sat Jun 24, 2023 7:06 am

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

MicroController
Posts: 1733
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

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

Postby MicroController » Sun Jun 25, 2023 5:15 pm

Is esp_wifi_80211_tx(...) what you're looking for?

Who is online

Users browsing this forum: Google [Bot] and 73 guests