Class Network

java.lang.Object
   |
   +----Network

public class Network
extends Object
implements EventDestination
This class represents a generic multiprocessor network


Variable Index

 o ASYNCHRONOUS
If the network is ASYNCHRONOUS
 o SYNCHRONOUS
If the network is SYNCHRONOUS

Constructor Index

 o Network()
Creates a new network, does not create any processors or connections, use other method for this
 o Network(TheSimulator, FileInputStream)
Creates a new network with the specified characteristics

Method Index

 o addLink(int, int, int)
Add a link between two processors usinf processor id's
 o addLink(String, String, int)
Add a link between two processors using processor names
 o addProcessor(int, int, int)
Add a processor to the network
 o addProcessor(int, int, int, float, float, float)
 o addProcessor(Processor, Processor[])
Add a processor to the network
 o addProcessor(String, int, int)
Add a processor to the network, timeslicelength default to 10
 o addProcessor(String, int, int, int)
Add a processor to the network
 o allIdleProcessors()
 o allProcessors()
 o dispatchEvent(SimEvent)

If this network is ASYNCHRONOUS this method simply passes the event on to the simulator if the network is SYNCHRONOUS it makes sure all the events arrive to the simulator at the same time

 o getAverageTimeslice()
 o getNeighbours(int)
return the neighbours of the processor
 o getProcessor(int)
get the processor with the corresponding ID
 o getRandomProcessor()
 o getType()
Get the network type
 o handleEvent(SimEvent)

Receives events from the simulator, implements the interface EventDestination

 o nrProcessors()
return the number of processors in this network
 o readConfigStream(FileInputStream)
Creates a network according to the supplied instream for a specification of the file format see configfile.spec
 o removeEvent(SimEvent)
Removes an already existing event from the global simulation queue
 o setType(int)
Set the network type
 o setType(int, int)
Set the network type

Variables

 o SYNCHRONOUS
 public static final int SYNCHRONOUS
If the network is SYNCHRONOUS

 o ASYNCHRONOUS
 public static final int ASYNCHRONOUS
If the network is ASYNCHRONOUS

Constructors

 o Network
 public Network()
Creates a new network, does not create any processors or connections, use other method for this

 o Network
 public Network(TheSimulator sim,
                FileInputStream is)
Creates a new network with the specified characteristics

Parameters:
sim - An instance of TheSimulator
is - An input stream specifying how the networks topology looks (see detailed description in here)

Methods

 o dispatchEvent
 public void dispatchEvent(SimEvent se)

If this network is ASYNCHRONOUS this method simply passes the event on to the simulator if the network is SYNCHRONOUS it makes sure all the events arrive to the simulator at the same time

Parameters:
se - the event to be dispatched
 o addProcessor
 public int addProcessor(String name,
                         int speed,
                         int bufferSize,
                         int tslc)
Add a processor to the network

Parameters:
name - The name used for this processor when using the addLink method
speed - The processor speed
bufferSize - The size of the processors communications buffer
tslc - the length of this processors timeslice
Returns:
the id of the new processor
 o addProcessor
 public int addProcessor(int speed,
                         int bufferSize,
                         int tslc,
                         float L,
                         float o,
                         float g)
 o addProcessor
 public int addProcessor(int speed,
                         int bufferSize,
                         int tslc)
Add a processor to the network

Parameters:
speed - The processor speed
bufferSize - The size of the processors communications buffer
tslc - the length of this processors timeslice
Returns:
the id of the new processor
 o getProcessor
 public Processor getProcessor(int peId)
get the processor with the corresponding ID

Parameters:
peId - the processor ID
 o addProcessor
 public int addProcessor(String name,
                         int speed,
                         int bufferSize)
Add a processor to the network, timeslicelength default to 10

Parameters:
name - The name used for this processor when using the addLink method
speed - The processor speed
bufferSize - The size of the processors communications buffer
Returns:
the id of the new processor
 o addLink
 public void addLink(String proc1,
                     String proc2,
                     int speed)
Add a link between two processors using processor names

Parameters:
proc1 - The first processor
proc2 - The second processor
See Also:
addProcessor
 o addLink
 public void addLink(int proc1,
                     int proc2,
                     int speed)
Add a link between two processors usinf processor id's

Parameters:
proc1 - The first processors id
proc2 - The second processorid id
See Also:
addProcessor
 o addProcessor
 public void addProcessor(Processor p,
                          Processor ns[])
Add a processor to the network

Parameters:
p - the processor to add
ns, - p:s neighbours
 o readConfigStream
 public void readConfigStream(FileInputStream fs)
Creates a network according to the supplied instream for a specification of the file format see configfile.spec

 o getType
 public int getType()
Get the network type

Returns:
the network type
See Also:
Network
 o setType
 public void setType(int s)
Set the network type

Parameters:
s - The type of the Network
 o setType
 public void setType(int s,
                     int timeSliceLength)
Set the network type

Parameters:
s - The type of the Network
timeSliceLength - the length of the time slice. This set a global timeslice for all processors
 o removeEvent
 public void removeEvent(SimEvent e)
Removes an already existing event from the global simulation queue

Parameters:
e - The event to remove from the simulators queue
 o handleEvent
 public void handleEvent(SimEvent e)

Receives events from the simulator, implements the interface EventDestination

Parameters:
e - the event
 o getAverageTimeslice
 public int getAverageTimeslice()
Returns:
the average timeslice for all this networks processors
 o getRandomProcessor
 public int getRandomProcessor()
Returns:
a processorID selected at uniform random from this netwoek
 o nrProcessors
 public int nrProcessors()
return the number of processors in this network

Returns:
the number of processors
 o getNeighbours
 public int[] getNeighbours(int PeId)
return the neighbours of the processor

Returns:
An array with the id of the neighbours
 o allIdleProcessors
 public int[] allIdleProcessors()
Returns:
An array with id:s for the processors that are currently idle
 o allProcessors
 public int[] allProcessors()
Returns:
An array with all processor id's This method relies on this class representation of processors.