Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3792262
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T12:35:43+00:00 2026-05-19T12:35:43+00:00

In an assignment it was required to form an ad hoc network between 2

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T12:35:44+00:00Added an answer on May 19, 2026 at 12:35 pm

    The UDP packet has an implied format. http://en.wikipedia.org/wiki/User_Datagram_Protocol Java will take care of the 8 header bytes that must be there (source port, destination port, length, checksum). Even if you provide only a single byte of data, the 8 byte header will still be correctly created by Java. You are not responsible for forming those headers, only in providing the values that go in them.

    All you have control of is the Data section of the packet. That can be formatted any way you like. It sounds like you are required to format it as you have shown above. The value of the that format may be debatable (source, destination addresses), but it sounds like you must adhere to it regardless.

    Yes, you must modify the buffer byte array to be the same format as you provide. The other values (IP address and Port) are used either for forming the header, or actually sending the packet on the wire.

    EDIT: Sorry, replaced 4 byte header with 8. My bad. You’d think I could read a protocol spec by now.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For a homework assignment I was given a Card class that has enumerated types
Is the assignment and check for null explicitly required in the below snippet to
I have an assignment in college in which we are required to read in
I've been working on a class assignment for C++ and we're required to acquire
i am required to produce something similar to ptree in solaris for my assignment.
For the assignment I am working on, I am required to use functions to
I'm a blind student who's taking a required UI class. One of the assignments
For a school assignment I have to write x86 assembly code, except I can't
For my university assignment I have to design some basic managment system for sicknesses
For a database assignment I have to model a system for a school. Part

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.