title: Java UDP header having additional data?
body: <p>Why UDP packet it's having additional data in header?</p>
  
  <p><img src="https://i.stack.imgur.com/Rk8nS.png" alt="enter image description here"></p>
  
  <p>I know that Java is setting UDP headers automatically, I can't modify it, but it should be 8 bytes long, not 40 ! <code>0x69 0x82 0xDB 0xAE 0x00 0x2D 0xFE 0x40</code> normally it should be the header. What is with those 32 bytes of extra data?</p>
  
  <p>The packet was captured with wireshark on loopback (on my localhost). This would be the problem?</p>
  
  <p>This is how I'm sending the packet:</p>
  
  <pre><code>byte[] responseHeader = { (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, 0x66, (byte)0x0A };
  
  LinkedList&lt;byte[]&gt; server_array = new LinkedList&lt;byte[]&gt;();
  int server_array_length = 0;
  
  byte[] temp_ip = getByteIp("89.40.233.17:27015"); // 0x59 0x28 0xE9 0x11 0x69 0x87
  server_array.add(temp_ip);
  server_array_length += temp_ip.length;
  
  temp_ip = getByteIp("89.40.233.38:27015"); // 0x59 0x28 0xE9 0x26 0x69 0x87
  server_array.add(temp_ip);
  server_array_length += temp_ip.length;
  
  temp_ip = getByteIp("89.40.233.5:27015"); // 0x59 0x28 0xE9 0x05 0x69 0x87
  server_array.add(temp_ip);
  server_array_length += temp_ip.length;
  
  temp_ip = getByteIp("89.40.233.10:27015"); // 0x59 0x28 0xE9 0x0A 0x69 0x87
  server_array.add(temp_ip);
  server_array_length += temp_ip.length;
  
  byte[] array_servers = new byte[server_array_length];
  
  int lastIndex = 0;
  for(byte[] b : server_array){
  System.arraycopy(b, 0, array_servers, lastIndex, b.length);
     lastIndex += b.length;
  }
  
  byte[] response = new byte[responseHeader.length + array_servers.length + 6];
  System.arraycopy(responseHeader, 0, response, 0, responseHeader.length);
  System.arraycopy(array_servers, 0, response, responseHeader.length, array_servers.length);
  
  byte[] footer = new byte[6];
  footer = getByteIp("0.0.0.0:0"); // 0x00 0x00 0x00 0x00 0x00 0x00
  System.arraycopy(footer, 0, response, response.length - 6, footer.length);
  
  socket.send(response);
  
  System.out.println("SENT: " + response.length + " bytes of data"); // SENT: 37 bytes of data
  
  private byte[] getByteIp(String fullData){
      String[] data = fullData.split(":");
      byte[] returnArray = new byte[6];
  
      byte[] ip = new byte[4];
      try {
          ip = InetAddress.getByName(data[0]).getAddress();
      } catch (UnknownHostException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
      byte[] port = new byte[2];
      port = ByteBuffer.allocate(2).putShort((short)Integer.parseInt(data[1])).array();
  
      System.arraycopy(ip, 0, returnArray, 0, ip.length);
      System.arraycopy(port, 0, returnArray, ip.length, port.length);
  
      return returnArray;
  }
  </code></pre>