Hi there, I’m using the W5500-EVB-Pico board with Arduino IDE to do some testing and I just want to send a packet with the packet structure that is in the code that I’m posting below, however, it seems W5500 libraries are handling ARP, and thus I can’t send custom raw packets.
Is there something I’m doing wrong? In wireshark the operation code always shows (1) so it’s not announcing itself.
#include <Ethernet.h>
byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02 }; // MAC address of the Ethernet shield
IPAddress ipAddress(192, 168, 1, 1); // IP address of the Ethernet shield
IPAddress destIpAddress(255, 255, 255, 255); // Destination IP address
EthernetUDP udpClient;
void setup() {
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
Ethernet.init(17);
Ethernet.begin(mac, ipAddress);
Serial.begin(9600);
delay(1000);
udpClient.begin(0); // Open a random local port
sendArpRequest(destIpAddress);
//udpClient.begin(0); // Open a random local port
//sendArpRequest(destIpAddress);
}
void sendArpRequest(const IPAddress& targetIp) {
// Create the ARP request packet
uint8_t arpRequestPacket[] = {
0x08, 0x06,
0x00, 0x01, // Hardware type: Ethernet (1)
0x08, 0x00, // Protocol type: IPv4 (0x0800)
0x06, // Hardware address length: 6
0x04, // Protocol address length: 4
0x00, 0x02, // ARP operation: Request (2)
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5], // Sender MAC address
ipAddress[0], ipAddress[1], ipAddress[2], ipAddress[3], // Sender IP address
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Target MAC address (zeroed out)
targetIp[0], targetIp[1], targetIp[2], targetIp[3] // Target IP address
};
// Send the ARP request packet
udpClient.beginPacket(targetIp, 0);
udpClient.write(arpRequestPacket, sizeof(arpRequestPacket));
udpClient.endPacket();
}