I'm trying to receive UDP packets from an FPGA hooked via crossover cable to my computer. My computer is set to 192.168.0.5, and the FPGA has 192.168.0.1. The netmask is 255.255.255.0, but it shouldn't matter since there are no routers anywhere.
The packets the FPGA is sending are fairly long, nearly the maximum allowable frame size. They're being sent on UDP port 49153, which is just a random high port number I made up.
I'm using Windows 7 on my computer, and Wireshark has no trouble seeing the UDP packets. The source and destination IP are correct, and the destination Ethernet address is FF:FF:FF:FF:FF:FF - the broadcast address. Wireshark shows that the checksum and frame size are both correct.
Yet I'm not able to receive any packets with my Java program. It's very simple and is essentially copied from the web. Here it is:
try
{
// Open a socket on which to listen for data
DatagramSocket socket = new DatagramSocket(PORT);
socket.setBroadcast(true);
// Create a buffer in which to put data.
// Data beyond the buffer length will be lost
byte[] buffer = new byte[BUFFERSIZE];
// Create a packet object to receive the packets
DatagramPacket packet = new DatagramPacket(buffer, BUFFERSIZE);
// Receive packets until the end of time
while(true)
{
System.out.println("Waiting for packet...");
// Wait until we receive a packet
socket.receive(packet);
// Victory message
System.out.println("Received a packet!");
// Reset the possible length of a packet before reusing it
packet.setLength(BUFFERSIZE);
}
}
catch (Exception e)
{
e.printStackTrace();
System.exit(-1);
}
All of the capitalized names are static integers declared elsewhere. The program seems to run without error, but just sits there and never receives a packet. Wireshark shows that about 450 packets/sec are rolling in.
Any help would be greatly appreciated. Thanks!
-Sasha