primitive
Class Packet

java.lang.Object
  extended byprimitive.Packet

public class Packet
extends java.lang.Object

Packet.java This class provides a representation of a Packet. A Packet contains a destination IP address, a source IP address, the port for the destination and a byte array consisting of the 'data payload'.

Author:
Avi TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates

Constructor Summary
Packet(java.lang.String IP, byte[] payload)
           
Packet(java.lang.String destIP, int port, byte[] payload, java.lang.String srcIP)
          Constructor for a Packet.
Packet(java.lang.String destIP, java.lang.Object message)
           
 
Method Summary
 java.lang.String getIP()
          Get the destination IP address.
 java.lang.Object getMessage()
           
 byte[] getPayload()
          Get the data stored in the byte array of this packet.
 int getPort()
          Get the port to which this packet is to be sent.
 java.lang.String getSrcIP()
          Get the source IP address
 void setPayload(byte[] b)
          Method to set the data payload in a packet.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Packet

public Packet(java.lang.String destIP,
              int port,
              byte[] payload,
              java.lang.String srcIP)
Constructor for a Packet. Creates a new packet with the following parameters:

Parameters:
destIP - The destination IP Address
port - The destination port
payload - The data to be sent in the form of a byte array
srcIP - The source IP Address

Packet

public Packet(java.lang.String destIP,
              java.lang.Object message)

Packet

public Packet(java.lang.String IP,
              byte[] payload)
Method Detail

setPayload

public void setPayload(byte[] b)
Method to set the data payload in a packet.

Parameters:
b - The byte array representing the data

getPayload

public byte[] getPayload()
Get the data stored in the byte array of this packet.

Returns:
The byte array of the packet

getIP

public java.lang.String getIP()
Get the destination IP address.

Returns:
The destination IP address

getSrcIP

public java.lang.String getSrcIP()
Get the source IP address

Returns:
The source IP address

getPort

public int getPort()
Get the port to which this packet is to be sent.

Returns:
The port to which this packet is to be sent

getMessage

public java.lang.Object getMessage()