I have a DataGramSocket and calls its receive method to get packets. What I'm not clear yet (being new on this) is decoding the data.
I've read a bit on UDP, but what I want to know is whether, by using the .receive method it also captures the IP header and UDP header part.
I'm receiving signed bytes. Do I then perform two's complement on the negative numbers? I did this, and reading at all the bits I could not see even the source address. In my text setup, the source use the 192.168.0.x address. For 192, I would expect to see something like 11000000
Again, does the packet (when .receive is used) also capture the headers? For example, the first byte I get is 00001000, which should correspong to IP version. This doesn't seem to be correct, as I would think that in UDP it would be decimal 4 (for IPv4). Perhaps, I'm missing something here.
Originally posted by Karen Baog: Again, does the packet (when .receive is used) also capture the headers?
Are you talking about an instance of java.net.DatagramPacket? It has several methods to get information about the packet, but nothing like IP version. Are you looking at the results of getData()? That only contains the data portion of the packet (see diagrams here))
So, I'm actually getting the data portion (the actual message) of the packet? And that the IP and UDP headers are not included?
You are correct. The Java Tutorial has a chapter on Datagrams in the Custom Networking tutorial, and there's a couple of simple examples at the Java Almanac. Maybe they will help you sort things out. [ August 02, 2005: Message edited by: Joe Ess ]