Arduino sketch does not repeat I have a Problem with my code.

My Goal is to receive a Ethernet message via UDP and send the message back via CAN.

It works fine but only with the first packet I send. When I send the same packet again there is no Response as you can see in the screenshot.
I´m using the Arduino Due with a Transceiver. The Programm which sends and reads the Messages is Vector Canoe

#include "variant.h"
#include "due_can.h"
#include "Arduino.h"

#include &lt;SPI.h&gt;        
#include &lt;Ethernet.h&gt;
#include &lt;EthernetUdp.h&gt; 

byte mac[] = {
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
};
IPAddress ip(192, 168, 1, 177);

unsigned int localPort = 8888;      // local port to listen on

// buffers for receiving and sending data
char packetBuffer[UDP_TX_PACKET_MAX_SIZE]; //buffer to hold incoming packet,


EthernetUDP Udp;

void setup() {

Can0.init(250000);
Serial.begin(9600);

Ethernet.begin(mac, ip);
Udp.begin(localPort);

}

void loop() {

    int packetSize = Udp.parsePacket();
    Udp.read(packetBuffer,packetSize);

   if (packetSize)
  {

    int Canframestosend= packetSize/8;    //Divides the Ethernet packet by 8 to match with CAN packet
    int count =0;
    int Rest=packetSize%8;                //Needed if the Ethernet packetsize isn´t a multiple of 8 


    for(int j=0;j&lt;=Canframestosend;j++){

    CAN_FRAME NewFrame;                   //CAN frames which are sent
    NewFrame.id=0xFA;                     //ID of the frames
    NewFrame.length=8;                    //Maximum of bytes a Can frame can have

    for (int i=0;i&lt;8;i++){

       NewFrame.data.byte[i] = packetBuffer[count]; //Write the Ethernet info byte by byte on the CAN frames
       count++;
       }
    if(packetSize&lt;count){
      NewFrame.length=Rest;                         //Shortens the last frame to avoid unnessecary zeros
      }
       Can0.sendFrame(NewFrame);

      }     

   }
   delay(10);
}


Maybe there is an endless Loop but I don´t know which and why.

Hope anybody can help me with that!
I'd guess it's in the if(packetsize) logic -- if you get a packetsize of zero, you still try to read into a zero-size buffer and who knows what would happen.  Move the read inside the if(){...}

See https://www.arduino.cc/en/Reference/EthernetUDPRead  

Also, you want to limit the reading to the UDP_TX_PACKET_MAX_SIZE size of the buffer, not to the size of the packet.

Update: The UDP_TX_PACKET_MAX_SIZE is only used in the user code, and nowhere else within the Ethernet Library.  You could use a larger buffer if you need to by defining and allocating a larger buffer and specifying its size in  EthernetUDP.read()  (see https://www.arduino.cc/en/Reference/EthernetUDPRead).