How to get raw ip packets without ip headers in esp32/lwip
Posted: 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
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
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);
}
Thank you