nachos.machine
Class Packet

java.lang.Object
  extended by nachos.machine.Packet

public class Packet
extends Object

A link-layer packet.

See Also:
NetworkLink

Field Summary
 byte[] contents
          The contents of this packet, excluding the link-layer header.
 int dstLink
          The address of the destination link of this packet.
static int headerLength
          The number of bytes in a link-layer packet header.
static int linkAddressLimit
          The upper limit on Nachos link addresses.
static int maxContentsLength
          The maximum number of content bytes (not including the header).
static int maxPacketLength
          The maximum length, in bytes, of a packet that can be sent or received on the network.
 byte[] packetBytes
          This packet, as an array of bytes that can be sent on a network.
 int srcLink
          The address of the source link of this packet.
 
Constructor Summary
Packet(byte[] packetBytes)
          Allocate a new packet using the specified array of bytes received from the network.
Packet(int dstLink, int srcLink, byte[] contents)
          Allocate a new packet to be sent, using the specified parameters.
 
Method Summary
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

packetBytes

public byte[] packetBytes
This packet, as an array of bytes that can be sent on a network.


dstLink

public int dstLink
The address of the destination link of this packet.


srcLink

public int srcLink
The address of the source link of this packet.


contents

public byte[] contents
The contents of this packet, excluding the link-layer header.


headerLength

public static final int headerLength
The number of bytes in a link-layer packet header. The header is formatted as follows:
offsetsizevalue
01network ID (collision detecting)
11destination link address
21source link address
31length of contents

See Also:
Constant Field Values

maxPacketLength

public static final int maxPacketLength
The maximum length, in bytes, of a packet that can be sent or received on the network.

See Also:
Constant Field Values

maxContentsLength

public static final int maxContentsLength
The maximum number of content bytes (not including the header). Note that this is just maxPacketLength - headerLength.

See Also:
Constant Field Values

linkAddressLimit

public static final int linkAddressLimit
The upper limit on Nachos link addresses. All link addresses fall between 0 and linkAddressLimit - 1.

See Also:
Constant Field Values
Constructor Detail

Packet

public Packet(int dstLink,
              int srcLink,
              byte[] contents)
       throws MalformedPacketException
Allocate a new packet to be sent, using the specified parameters.

Parameters:
dstLink - the destination link address.
srcLink - the source link address.
contents - the contents of the packet.
Throws:
MalformedPacketException

Packet

public Packet(byte[] packetBytes)
       throws MalformedPacketException
Allocate a new packet using the specified array of bytes received from the network.

Parameters:
packetBytes - the bytes making up this packet.
Throws:
MalformedPacketException