In an assignment it was required to form an ad hoc network between 2 laptops by switching the wireless LAN card in 2 laptops to the ad hoc mode then choosing a suitable SSID. I've created an adhock network between labtops. It was then required to Develop a “Sender” and a “Receiver” application to send a simple “Hello World" message from one laptop and receive it on the other one using sockets. I did it successfully using udp datagram sockets and udp packets (in java) as there is no server in adhoc networks. The only problem is that it was stated that packet format should look like the following, where data is represented as an array of bytes of maximum length = 64 KB (assume IP address is presented in 2 bytes):
| |  |  |  |  |  |  |  |  |  |H|E|L|L|O| |W|O|R|L|D|                           
Sender ID|Reciever ID|       data 
(4 bytes) (4 bytes)
I know that at the reciver side you can get the address of the sent packet using packet.getAddress(); and the address of the reciever side is already known but I dnt understand the purpose of this format or how to set the format of a packet. I just wanna know what is the actual format of a udp packet and how to set the format of udp packet in java. How does creating a dataGram packet by specifying a buffer byte array, the intelAddress and the port sets the format of the packet? Do i need to modify the buffer byte array to be of the same format as stated above (although the address of the sender is sent anyways) ? Please reply to me as soon as you can. Any help will be appreciated. Thanks in advance.