p2p.simulator.network
Class Network

java.lang.Object
  extended by p2p.simulator.network.Network

public class Network
extends java.lang.Object

This class simulates the underlying network. A vector is used to store the messages that are sent using the sendMsg method. A peer can retrive a message, if there is any, using the recvMsg and its Id as parameter.


Field Summary
static int BROADCAST
           
static int MULTICAST
           
static int POINT_TO_POINT
           
 
Constructor Summary
Network()
          Instatiates and initializes the uderlying network.
 
Method Summary
 void broadcastMsg(Message msg)
          Should not be used.
 java.util.Vector<Message> getNetQueue()
          Returns the queue that stores the messages.
 void multicastMsg(Message msg, long begin, long end)
          Sends a message to a range of peers.
 Message recvMsg(long id)
          Receives a message destinate to peer with the specific id.
 void sendMsg(Message msg)
          Sends a message to peer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

POINT_TO_POINT

public static final int POINT_TO_POINT
See Also:
Constant Field Values

BROADCAST

public static final int BROADCAST
See Also:
Constant Field Values

MULTICAST

public static final int MULTICAST
See Also:
Constant Field Values
Constructor Detail

Network

public Network()
Instatiates and initializes the uderlying network.

Method Detail

sendMsg

public void sendMsg(Message msg)
Sends a message to peer.

Parameters:
msg - The message is beeing sent.

recvMsg

public Message recvMsg(long id)
Receives a message destinate to peer with the specific id.

Parameters:
id - The peer's id that calls the method.
Returns:
A message if there is a message for the peer id or null otherwise.

broadcastMsg

public void broadcastMsg(Message msg)
Should not be used.

Parameters:
msg -

multicastMsg

public void multicastMsg(Message msg,
                         long begin,
                         long end)
Sends a message to a range of peers.

Parameters:
msg - The message that is beeing sent.
begin - The first peer id of the range.
end - The last peer id of the range.

getNetQueue

public java.util.Vector<Message> getNetQueue()
Returns the queue that stores the messages.

Returns:
The message queue.