I have been given an assignment for my data communications class where I am required to encapsulate a IP packet over UDP. I then need to encapsulate this manually made packet into an actual UDP packet and send it over IP. This will yield the following protocol stack (blue denotes the headers I will create manually):
Is there an easy way to do this in Java? I understand in C I could use the struct defined for UDP and IP headers in the Linux kernel libraries, manually populate all the fields, and concatenate the information into the packet. However, in Java I will not have access to Linux networking header files. I am also trying to do this without the use of external APIs.
For clarification I plan to develop the application Linux using Eclipse.