Class Packet

java.lang.Object
  extended by Packet

public class Packet
extends java.lang.Object

A Packet is a protocol data unit used at the interface between a TCPEntity and an Internet. A Packet has a type, identification number, sequence number, source TCPEntity, and destination TCPEntity. All of these attributes except for the identification number and the sequence number are specified when the Packet is constructed and cannot be changed.

The sequence number is normally assigned by the send side of a reliable data transfer protocol when it is initialized. The identification number can be set to simulate filling the packet with data, allowing a fixed set of packets to be reused for the duration of a connection.


Field Summary
static java.lang.String ACK_TYPE
          Packet.ACK_TYPE is the type for acknowledgement packets.
static java.lang.String CLOSE_TYPE
          Packet.CLOSE_TYPE is the type for packets that close a connection.
static java.lang.String DATA_TYPE
          Packet.DATA_TYPE is the type for data packets.
static java.lang.String NACK_TYPE
          Packet.NACK_TYPE is the type for negative acknowledgement packets.
 
Constructor Summary
Packet(TCPEntity src, TCPEntity dest)
          new Packet(src, dest) returns a new Packet.
 
Method Summary
 Packet getCopy()
          pkt.getCopy() returns a clone of pkt.
 TCPEntity getDestination()
          pkt.getDestination() returns the destination TCPEntity of pkt.
 int getIdentificationNumber()
          pkt.getIdentificationNumber() returns the identification number of pkt.
 int getSequenceNumber()
          pkt.getSequenceNumber() returns the sequence number of pkt.
 TCPEntity getSource()
          pkt.getSource() returns the source TCPEntity of pkt.
 java.lang.String getType()
          pkt.getType() returns the type of pkt.
 void setIdentificationNumber(int id)
          pkt.setIdentificationNumber(id) sets the identification number of pkt to id.
 void setSequenceNumber(int seq)
          pkt.setSequenceNumber(seq) sets the sequence number of pkt to seq.
 void setType(java.lang.String typ)
          pkt.setType(typ) sets the type of pkt to typ.
 java.lang.String toString()
          pkt.toString() returns a String describing pkt.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DATA_TYPE

public static final java.lang.String DATA_TYPE
Packet.DATA_TYPE is the type for data packets.

See Also:
Constant Field Values

ACK_TYPE

public static final java.lang.String ACK_TYPE
Packet.ACK_TYPE is the type for acknowledgement packets.

See Also:
Constant Field Values

NACK_TYPE

public static final java.lang.String NACK_TYPE
Packet.NACK_TYPE is the type for negative acknowledgement packets.

See Also:
Constant Field Values

CLOSE_TYPE

public static final java.lang.String CLOSE_TYPE
Packet.CLOSE_TYPE is the type for packets that close a connection.

See Also:
Constant Field Values
Constructor Detail

Packet

public Packet(TCPEntity src,
              TCPEntity dest)
new Packet(src, dest) returns a new Packet. Its source TCPEntity is src and its destination TCPEntity is dest. The sequence number of the new Packet should be assigned by its source RDTProtocol.

Method Detail

getCopy

public Packet getCopy()
pkt.getCopy() returns a clone of pkt.


getType

public java.lang.String getType()
pkt.getType() returns the type of pkt.


setType

public void setType(java.lang.String typ)
pkt.setType(typ) sets the type of pkt to typ. The parameter typ should be one of the constants Packet.DATA_TYPE, Packet.ACK_TYPE, Packet.NACK_TYPE, or Packet.CLOSE_TYPE.


getIdentificationNumber

public int getIdentificationNumber()
pkt.getIdentificationNumber() returns the identification number of pkt.


setIdentificationNumber

public void setIdentificationNumber(int id)
pkt.setIdentificationNumber(id) sets the identification number of pkt to id.


getSequenceNumber

public int getSequenceNumber()
pkt.getSequenceNumber() returns the sequence number of pkt.


setSequenceNumber

public void setSequenceNumber(int seq)
pkt.setSequenceNumber(seq) sets the sequence number of pkt to seq.


getSource

public TCPEntity getSource()
pkt.getSource() returns the source TCPEntity of pkt.


getDestination

public TCPEntity getDestination()
pkt.getDestination() returns the destination TCPEntity of pkt.


toString

public java.lang.String toString()
pkt.toString() returns a String describing pkt. This String has the form type.identificationNumber.sequenceNumber.source->destination. The identification number is preceeded by the letter "I" and the sequence number is preceeded by the letter "S".

Overrides:
toString in class java.lang.Object