Results 1 to 2 of 2
  1. #1
    Mezzo is offline Member
    Join Date
    Jan 2011
    Posts
    3
    Rep Power
    0

    Default How to set the format of a udp packet ?

    Hello,

    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):
    Java Code:
    | | | | | | | | | | | |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.

  2. #2
    collemore is offline Member
    Join Date
    Jan 2011
    Posts
    1
    Rep Power
    0

Similar Threads

  1. Packet data.
    By v2kish in forum Advanced Java
    Replies: 4
    Last Post: 02-09-2011, 04:41 AM
  2. Replies: 7
    Last Post: 07-16-2010, 02:16 PM
  3. Trying to send UDP discovery packet
    By JohnST in forum New To Java
    Replies: 1
    Last Post: 12-26-2009, 08:32 PM
  4. How to identify packet type?
    By priya deshpande in forum Networking
    Replies: 0
    Last Post: 10-11-2009, 07:40 AM
  5. Replies: 2
    Last Post: 12-22-2008, 04:05 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •