nachos.network
Class MailMessage

java.lang.Object
  extended by nachos.network.MailMessage

public class MailMessage
extends Object

A mail message. Includes a packet header, a mail header, and the actual payload.

See Also:
Packet

Field Summary
 byte[] contents
          The contents of this message, excluding the mail message header.
 int dstPort
          The port used by this message on the destination machine.
static int headerLength
          The number of bytes in a mail header.
static int maxContentsLength
          Maximum payload (real data) that can be included in a single mesage.
 Packet packet
          This message, as a packet that can be sent through a network link.
static int portLimit
          The upper limit on mail ports.
 int srcPort
          The port used by this message on the source machine.
 
Constructor Summary
MailMessage(int dstLink, int dstPort, int srcLink, int srcPort, byte[] contents)
          Allocate a new mail message to be sent, using the specified parameters.
MailMessage(Packet packet)
          Allocate a new mail message using the specified packet from the network.
 
Method Summary
 String toString()
          Return a string representation of the message headers.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

packet

public Packet packet
This message, as a packet that can be sent through a network link.


dstPort

public int dstPort
The port used by this message on the destination machine.


srcPort

public int srcPort
The port used by this message on the source machine.


contents

public byte[] contents
The contents of this message, excluding the mail message header.


headerLength

public static final int headerLength
The number of bytes in a mail header. The header is formatted as follows:
offsetsizevalue
01destination port
11source port

See Also:
Constant Field Values

maxContentsLength

public static final int maxContentsLength
Maximum payload (real data) that can be included in a single mesage.

See Also:
Constant Field Values

portLimit

public static final int portLimit
The upper limit on mail ports. All ports fall between 0 and portLimit - 1.

See Also:
Constant Field Values
Constructor Detail

MailMessage

public MailMessage(int dstLink,
                   int dstPort,
                   int srcLink,
                   int srcPort,
                   byte[] contents)
            throws MalformedPacketException
Allocate a new mail message to be sent, using the specified parameters.

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

MailMessage

public MailMessage(Packet packet)
            throws MalformedPacketException
Allocate a new mail message using the specified packet from the network.

Parameters:
packet - the packet containg the mail message.
Throws:
MalformedPacketException
Method Detail

toString

public String toString()
Return a string representation of the message headers.

Overrides:
toString in class Object