EthernetUdp stops receiving packets after time

I am using an arduino UNO with an ethernet shield W5100. I am using EthernetUdp which works well for a while for sending and recieving UDP packets. The issue is that the Uno stops receiving packets after time. Packets are still being sent from the Uno but not being read. I have checked the network traffic and UDP packets are being sent to the arduino .
I have the following code:

//global variables
EthernetUDP Udp;

//in setup
Ethernet.begin(mac, thisIp, dns1, gateway, subnet);
Udp.begin(UDPPort);

//in loop
int packetSize = Udp.parsePacket();
Serial.print("Udp.available() ");
Serial.println(Udp.available());
Serial.print("packetSize ");
Serial.println(packetSize);
if (packetSize > 0) {
	int bufferSize = 6;
	char incomingPacket[bufferSize];  // buffer for incoming packets
// receive incoming UDP packets
	int len = Udp.read(incomingPacket, bufferSize);
	if (len > 0) {
		incomingPacket[len] = '\0';
	}

	Serial.print("UDP packet contents: ");
	Serial.print(incomingPacket);
	Serial.print(" from Udp.remoteIP():");
	Serial.println(Udp.remoteIP());
	registerIP(Udp.remoteIP(), true);

	if (strcmp(incomingPacket, offReplyPacket) == 0) {
		if (Udp.remoteIP() == ipLoad1) {
			stateLoad1 = false;
		}
		if (Udp.remoteIP() == ipLoad2) {
			stateLoad2 = false;
		}
		if (Udp.remoteIP() == ipLoad3) {
			stateLoad3 = false;
		}
	}
	if (strcmp(incomingPacket, onReplyPacket) == 0) {
		if (Udp.remoteIP() == ipLoad1) {
			stateLoad1 = true;
		}
		if (Udp.remoteIP() == ipLoad2) {
			stateLoad2 = true;
		}
		if (Udp.remoteIP() == ipLoad3) {
			stateLoad3 = true;
		}
	}
	for (int i = 0; i < bufferSize; i++)
	incomingPacket[i] = 0;

}

As an update, the attached .ino file can be used to replicate the issue.
I used packetSender to send a UDP message to the ethernet shield on an arduino UNO
The message is recieved only if a call to Udp.write has been called at somepoint before so I send a message to a seperate IP address and port. This does not seem to make sense to me either.

The programme works for an indeterminate length of time. I get pCount to go to around 40-80 with a 4 char message.

Please could someone help me to understand why this works and then stops working.

testUdp.ino (3.07 KB)

Well I have come to a blank with this one. Something seems to be blocking the port. i have tried using different ports for sending and recieving.
Is there someone who can advise me on this?

“Is there someone who can advise me on this?”

Well, all I can say is I’ve never had any luck to get Udp to work. The problem for me is that Udp is somewhat invisible to typical trouble shooting, so additional applications may be needed to see what is working and what is not working.