UDP packet is not overwritten when it is sent

The buffer contains "JSMB" and when you receive "JSK" into that buffer, it will be "JSKB" ("JSM" is replaced with "JSK" - the last "B" remains). You need to check how much data is transmitted per packet, and only use that much data from the buffer, or you need to clear the buffer using "memset" before receiving.