java packets byte

Posted by user303289 on Stack Overflow See other posts from Stack Overflow or by user303289
Published on 2010-03-27T18:44:14Z Indexed on 2010/03/27 18:53 UTC
Read the original article Hit count: 137

Filed under:
|

Guys, I am implementing a protocol in one of the wireless project. I am stucked at one point. In of the java file i am suppose to receive a packet and that packet is 12 byte packet and I have to write different functions for reading different parts of packets and convert it to diferent type. Like I want first four byte in one of the function and convert it to int, next two bytes in string. and again next two in string, last two hop in string and followed by last two int. I want follwing function to implement:

// here is the interface 

/*
 FloodingData should use methods defined in this class.
*/
class FloodingPacket{
public static void main(String arg[]){
byte FloodingPack[]; // just for example to test in code
FloodingPack=new byte[12];
interface IFloodingPacket
{
 // Returns the unique sequence number for the packet
 int getSequenceNumber() ;

 // Returns the source address for the packet
 String getSourceAddress();

 // Returns the destination address for the packet
 String getDestinationAddress();

 // Returns the last hop address for the packet
 String getLastHopAddress();

 // Sets the last hop address to the address of the node
 // which the packet was received from
 void updateLastHopAddress();

 // Returns the entire packet in bytes (for sending)
 byte[] getBytes();

 // Sets the bytes of the packet (for receiving)
 void setBytes(byte[] packet);
}

© Stack Overflow or respective owner

Related posts about java

Related posts about packet-capture