All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class AcmeNet.Assn1.ReliableNI

AcmeNet.Util.NetworkInterface
   |
   +----AcmeNet.Assn1.ReliableNI

public class ReliableNI
extends NetworkInterface
A reliable network interface. Acts just like an AcmeNet.Util.NetworkInterface, except that sent packets are automatically acknowledged, and unacknowledged packets are retransmitted by their sender. The result is that every packet will eventually reach its destination, unless a process or the network suffers a serious failure.


Variable Index

 o MaxPacketLength
The maximum allowable packet size that can be sent.
 o TimeoutSeconds
How long to wait before retransmitting an unacknowledged packet.

Constructor Index

 o ReliableNI()
Creates a ReliableNI at any available NetAddress.
 o ReliableNI(NetAddress)
Creates a ReliableNI at a specified NetAddress.

Method Index

 o resendBytes(NetAddress, byte[], int)
Resend a packet of data.
 o run()
Executed by a daemon thread.
 o sendBytes(NetAddress, byte[])
Send a packet of data.

Variables

 o MaxPacketLength
 public static final int MaxPacketLength
The maximum allowable packet size that can be sent.

 o TimeoutSeconds
 public static final long TimeoutSeconds
How long to wait before retransmitting an unacknowledged packet. Retransmission should normally occur between TimeoutSeconds and 2*TimeoutSeconds of the time the packet was sent.

Constructors

 o ReliableNI
 public ReliableNI()
Creates a ReliableNI at any available NetAddress.

 o ReliableNI
 public ReliableNI(NetAddress requiredAddress) throws AddressUnavailableException
Creates a ReliableNI at a specified NetAddress.

Parameters:
requiredAddress - the address at which to create the ReliableNI
Throws: AddressUnavailableException
the requested address was not available

Methods

 o sendBytes
 protected void sendBytes(NetAddress dest,
                          byte data[]) throws IOException
Send a packet of data. If there is no Acme process at the destination address, the packet will silently vanish into oblivion. But if there is a process at the destination, the packet will eventually be delivered.

Parameters:
dest - the address to send the packet to
data - an array containing the data to be sent
Throws: IOException
some I/O error occured
Throws: PacketTooLargeException
the packet would have been larger than MaxPacketLength
Overrides:
sendBytes in class NetworkInterface
 o resendBytes
 protected void resendBytes(NetAddress dest,
                            byte data[],
                            int seqNum) throws IOException
Resend a packet of data. The reliable-networking software should automatically call this whenever a packet that was sent is not acknowledged.

Parameters:
dest - the address to send the packet to
data - an array containing the data to be sent
seqNum - the sequence number of the packet (must be the same sequence number the packet had the first time it was sent)
Throws: IOException
some I/O error occured
Throws: PacketTooLargeException
the packet would have been larger than MaxPacketLength
 o run
 public void run()
Executed by a daemon thread. Grabs arriving packets and causes them to be processed appropriately.

Overrides:
run in class NetworkInterface

All Packages  Class Hierarchy  This Package  Previous  Next  Index