verinec.netsim.components.layers
Class abstractNetworkLayer

java.lang.Object
  extended by desmoj.core.simulator.NamedObject
      extended by desmoj.core.simulator.ModelComponent
          extended by verinec.netsim.components.layers.abstractNetworkLayer
All Implemented Interfaces:
Observer, Subject
Direct Known Subclasses:
ApplicationLayer, DataLinkLayer, NetworkLayer, PhysicalNetworkLayer, TransportLayer

public abstract class abstractNetworkLayer
extends ModelComponent
implements Subject, Observer

A Network Layer with basic functionalities. A NetworkLayer has an Address and one or more PacketProcessors (Protocollimplementations) each Network Layer has a upper and a lower Layer(Observer).

Version:
$Revision:835 $
Author:
Dominik Jungo

Field Summary
private  Vector addresses
           
private  String layerName
           
private  Observer lowerobserver
           
private  Node node
           
private  Vector processors
           
private  Observer upperobserver
           
 
Constructor Summary
abstractNetworkLayer(Model owner, EventProcessor processor, String name)
          Constructs a new NetworkLayer
 
Method Summary
 void addAddress(IAddress address)
          adds an address to the layer.
 void addProcessor(EventProcessor processor)
          adds an packet processor to the layer.
 Iterator addresses()
           
 void attachLower(Observer observer)
          Attaches a Observer to this Subject
 void attachUpper(Observer observer)
          Attaches a Observer to this Subject
 boolean compareAddress(IAddress address)
          Checks if an address is associated with this layer.
 void detachLower()
          Detaches the lower Observer
 void detachUpper()
          Detaches the upper Observer
 void getDownEvent(PacketArrivedEventDown event)
          Receives a PacketEventArrived from above.
 IAddress getFirstAddress()
           
 String getLayerName()
          gets this layers name
 Observer getLowerobserver()
          gets the lower observer (layer)
 Node getNode()
          gets the node in which this layer lies
 EventProcessor getProcessor(String name)
          gets a PacketProcessor that is instancaied in this layer.
 void getUpEvent(PacketArrivedEventUp event)
          Receives a PacketEventArrived from below.
protected  Enumeration processorelements()
          enummerates all Processors in this Layer
 void sendDown(Packet packet, double timeoffset, ILogger logger)
          Sends a Packet to the lower Layers(Observers).
 void sendUp(Packet packet, double timeoffset, ILogger logger)
          Sends a Packet to the upper Layers(Observers).
private  void setLayerName(String string)
          sets this Layers name
 void setNode(Node node)
          sets the node in which this layer lies
 
Methods inherited from class desmoj.core.simulator.ModelComponent
current, currentEntity, currentEvent, currentModel, currentSimProcess, currentTime, debugIsOn, debugOff, debugOn, epsilon, getModel, isExperimentCompatible, isModelCompatible, sendDebugNote, sendMessage, sendTraceNote, sendWarning, skipTraceNote, skipTraceNote, traceIsOn, traceOff, traceOn
 
Methods inherited from class desmoj.core.simulator.NamedObject
getName, getQuotedName, rename, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

addresses

private Vector addresses

layerName

private String layerName

lowerobserver

private Observer lowerobserver

upperobserver

private Observer upperobserver

node

private Node node

processors

private Vector processors
Constructor Detail

abstractNetworkLayer

public abstractNetworkLayer(Model owner,
                            EventProcessor processor,
                            String name)
Constructs a new NetworkLayer

Parameters:
owner - a Model
processor - a packet processor in this layer
name - Name of this layer
Method Detail

addAddress

public void addAddress(IAddress address)
adds an address to the layer. From now on the layer can be address using this adddress.

Parameters:
address - an address

addProcessor

public void addProcessor(EventProcessor processor)
adds an packet processor to the layer.

Parameters:
processor - a processor

attachLower

public void attachLower(Observer observer)
Description copied from interface: Subject
Attaches a Observer to this Subject

Specified by:
attachLower in interface Subject
Parameters:
observer - The observing Object
See Also:
Subject.attachLower(verinec.netsim.components.layers.Observer)

attachUpper

public void attachUpper(Observer observer)
Description copied from interface: Subject
Attaches a Observer to this Subject

Specified by:
attachUpper in interface Subject
Parameters:
observer - The observing Object
See Also:
Subject.attachUpper(verinec.netsim.components.layers.Observer)

compareAddress

public boolean compareAddress(IAddress address)
Checks if an address is associated with this layer.

Parameters:
address - an address to compare with
Returns:
true if the address is in this layers address list, false otherwise.

detachLower

public void detachLower()
Description copied from interface: Subject
Detaches the lower Observer

Specified by:
detachLower in interface Subject
See Also:
Subject.detachLower()

detachUpper

public void detachUpper()
Description copied from interface: Subject
Detaches the upper Observer

Specified by:
detachUpper in interface Subject
See Also:
Subject.detachUpper()

getDownEvent

public void getDownEvent(PacketArrivedEventDown event)
Description copied from interface: Observer
Receives a PacketEventArrived from above. Equivalent to the update method in the Observer Designpattern

Specified by:
getDownEvent in interface Observer
Parameters:
event - a PacketEventArrived to be received
See Also:
Observer.getDownEvent(verinec.netsim.events.PacketArrivedEventDown)

getLayerName

public String getLayerName()
gets this layers name

Returns:
this layers name

getLowerobserver

public Observer getLowerobserver()
gets the lower observer (layer)

Returns:
the lower observer (layer)

getNode

public Node getNode()
gets the node in which this layer lies

Returns:
the node in which this layer lies

getProcessor

public EventProcessor getProcessor(String name)
                            throws NetSimException
gets a PacketProcessor that is instancaied in this layer.

Parameters:
name - a name of a packet processor
Returns:
the Packetprocessor with the given name
Throws:
NetSimException - if no Processor with given name is instanciated in this layer.

getUpEvent

public void getUpEvent(PacketArrivedEventUp event)
Description copied from interface: Observer
Receives a PacketEventArrived from below. Equivalent to the update method in the Observer Designpattern

Specified by:
getUpEvent in interface Observer
Parameters:
event - a PacketEventArrived to be received
See Also:
Observer.getUpEvent(verinec.netsim.events.PacketArrivedEventUp)

processorelements

protected Enumeration processorelements()
enummerates all Processors in this Layer

Returns:
a Enummeration with all Processors in this Layer

sendDown

public void sendDown(Packet packet,
                     double timeoffset,
                     ILogger logger)
Description copied from interface: Subject
Sends a Packet to the lower Layers(Observers). This is equivalent to the Notify Method

Specified by:
sendDown in interface Subject
Parameters:
packet - The Packet to be sent down
timeoffset - timeoffset added to now, when tje packet should arrive
logger - logger used to log all events caused by this event
See Also:
Subject.sendDown(verinec.netsim.entities.packets.Packet, double, verinec.netsim.loggers.ILogger)

sendUp

public void sendUp(Packet packet,
                   double timeoffset,
                   ILogger logger)
Description copied from interface: Subject
Sends a Packet to the upper Layers(Observers). This is equivalent to the Notify Method

Specified by:
sendUp in interface Subject
Parameters:
packet - The Packet to be sent up
timeoffset - timeoffset added to now, when tje packet should arrive
logger - logger used to log all events caused by this event
See Also:
Subject.sendUp(verinec.netsim.entities.packets.Packet, double, verinec.netsim.loggers.ILogger)

setLayerName

private void setLayerName(String string)
sets this Layers name

Parameters:
string - a Name

setNode

public void setNode(Node node)
sets the node in which this layer lies

Parameters:
node - a Node

getFirstAddress

public IAddress getFirstAddress()

addresses

public Iterator addresses()

Copyright © 2005 Verinec, DIUF