J-Sim v1.2.1-p7 API

drcl.inet
Class NodeBuilder

java.lang.Object
  extended bydrcl.DrclObj
      extended bydrcl.comp.Component
          extended bydrcl.inet.NodeBuilder
All Implemented Interfaces:
java.lang.Cloneable, InetConstants, ObjectDuplicable, java.io.Serializable

public class NodeBuilder
extends Component
implements InetConstants

The container class for automating the process of constructing a network node.

This class has a set of build(...) methods to build the internal structure of nodes. But before using this class to build other nodes, one needs to build the NodeBuilder first. Building a NodeBuilder is no difference from building a real node (i.e., adding components and connecting them). But since the relation between the modules in the upper protocol layer (UPL) and the core service layer (CSL) is defined, we can further automate the process by having a set of port naming rules for a protocol:

Rules How NodeBuilder Behaves
If a protocol wants to have 
(service), or listen to (event)...
then it must have (port) when sees this port, NodeBuilder
connects it with (port) of CSL
data services down@ <protocol ID>@up
packet arrival events .pktarrival@ .pktarrival@
identity services .service_id@ .service_id@
identity events .id@ .id@
routing table services .service_rt@ .service_rt@
unicast route query .ucastquery@ .ucastquery@
multicast route query .mcastquery@ .mcastquery@
unicast route events .rt_ucast@ .rt_ucast@
multicast route events .rt_mcast@ .rt_mcast@
interface/neighbor services .service_if@ .service_if@
neighbor events (physical) .if@ .if@
neighbor events (virtual) .vif@ .vif@
packet filter configuration service .configswitch@ .configswitch@

If a protocol follows the rules, then we can simply add the protocol to NodeBuilder and NodeBuilder will take care of the connections between the protocol and CSL. At the end of build(...), NodeBuilder uses CSL builder to build the internal structure of CSL. If CSL builder is not specified in the build(...) method, the default CSL builder is used.

Node Map

If the upper-protocol-layer modules in a node forms a layered protocol stack, then one may use a node map to further ease the task of building a NodeBuilder. A node map is a plain text which describes the layering relation between modules.  For example, the node map for a UDP application laying on top of UDP at port 1100 is as follows:

udp	17/csl		drcl.inet.transport.UDP
app	1100/udp	Application_Class

And then we can use the loadmap(String) method to load a node map into a NodeBuilder.  Each line in a node map corresponds to a module. The syntax is as follows:

<module_id>	<port>/<lower_layer_module_id>	<module_class>

After parsing a line, NodeBuilder creates the module and connects the down@ port of the module to the <port>@up port of the lower layer module.  If the lower layer module does not multiplex/demultiplex, then <port> should be given by "-" (the "minus" sign).  In this case, NodeBuilder connects the down@ port of the module to the up@ port of the lower layer module.

The current implementation of NodeBuilder requires that the lower layer module be defined ahead. The core service layer (csl) is pre-defined.  One may use it as lower layer module without defining it.

If the lower layer module is the core service layer (csl), then we may omit the <port>/csl field if the protocol is known to INET. (INET recognizes many Internet standard protocols such as TCP, UDP, IGMP, DV, OSPF and so on). 

There are four build(...) methods in NodeBuilder for including a node map as an argument:

public void build(Object c_, String nodemap_);
public void build(Object[] cc_, String nodemap_);
public void build(Object c_, CSLBuilder cb_, String nodemap_);
public void build(Object[] cc_, CSLBuilder cb_, String nodemap_);

These methods call loadmap(String) first and then calls the corresponding build(...) methods without the node map argument.

Note that loading a node map overrides the existing structure in the NodeBuilder.  One may use the same NodeBuilder instance to build different types of nodes with different node maps.

NodeBuilder Properties

Some properties can be set in the NodeBuilder. When the build(...) method is called, these properties are conveyed and set in the nodes being built. It is particularly useful when one wishes to set these properties that are common to the nodes being built. The following table lists the properties defined in the this class:

Property "Set" Method Description
interface bandwidth setBandwidth(double) Sets the bandwidth (in bps) of interfaces. The default value applies if non-positive value is given.
interface buffer size setBufferSize(int) Sets the buffer size (in bytes or packets, depending on the buffer mode) of interfaces. The default value applies if non-positive value is given.
interface buffer mode setBufferMode(String mode_) Sets the buffer mode. The mode_ argument could be "byte" or "packet".
interface maximum 
transmission unit
(MTU)
setMTU(int) Sets the MTU (in bytes) of interfaces, including the size of the packet header (if there is any) for link transimission. The default value applies if negative value is given. Giving zero turns off MTU check (e.g., fragmentation in CSL).

Service and Event Ports

In addition to relying on NodeBuilder to create service and event ports at CSL on demands (of UPL modules), one can command NodeBuilder to create some or all of those ports, including "up" ports. To make it happen, one simply adds the service and event ports to the NodeBuilder, and then, when building a node, the NodeBuilder duplicates all the service and event ports on it at the CSL created for the node.

See Also:
Service and Event Ports at CSL, CSLBuilder, Serialized Form

Nested Class Summary
 
Nested classes inherited from class drcl.comp.Component
Component.Locks
 
Field Summary
 
Fields inherited from class drcl.comp.Component
FLAG_COMPONENT_NOTIFICATION, FLAG_DEBUG_ENABLED, FLAG_DIRECT_OUTPUT_ENABLED, FLAG_ENABLED, FLAG_ERROR_ENABLED, FLAG_EVENT_ENABLED, FLAG_EXPOSED, FLAG_GARBAGE_DISPLAY_ENABLED, FLAG_GARBAGE_ENABLED, FLAG_HAS_EXPOSED_CHILD, FLAG_PORT_NOTIFICATION, FLAG_STARTED, FLAG_STOPPED, FLAG_TRACE_ENABLED, FLAG_UNDEFINED_START, id, infoPort, locks, name, parent, PortGroup_DEFAULT_GROUP, PortGroup_EVENT, PortGroup_SERVICE, Root, Trace_DATA, Trace_SEND
 
Fields inherited from interface drcl.inet.InetConstants
BYTE_MODE, DEFAULT_BANDWIDTH, DEFAULT_BUFFER_SIZE, DEFAULT_MTU, EVENT_ID_CHANGED_PORT_ID, EVENT_IDENTITY_ADDED, EVENT_IDENTITY_REMOVED, EVENT_IF_NEIGHBOR_DOWN, EVENT_IF_NEIGHBOR_UP, EVENT_IF_PORT_ID, EVENT_LINK_BROKEN, EVENT_LINK_BROKEN_PORT_ID, EVENT_MCAST_HOST_PORT_ID, EVENT_PKT_ARRIVAL, EVENT_PKT_ARRIVAL_PORT_ID, EVENT_RT_ENTRY_ADDED, EVENT_RT_ENTRY_MODIFIED, EVENT_RT_ENTRY_REMOVED, EVENT_RT_MCAST_CHANGED_PORT_ID, EVENT_RT_UCAST_CHANGED_PORT_ID, EVENT_VIF_NEIGHBOR_DOWN, EVENT_VIF_NEIGHBOR_UP, EVENT_VIF_PORT_ID, HOST_ENTRY_EXT, ID_CSL, MCAST_QUERY_PORT_ID, PACKET_MODE, PID_AODV, PID_DV, PID_DVMRP, PID_HELLO, PID_IGMP, PID_OSPF, PID_RSVP, PID_TCP, PID_UDP, SERVICE_CONFIGSW_PORT_ID, SERVICE_ID_PORT_ID, SERVICE_IF_PORT_ID, SERVICE_MCAST_PORT_ID, SERVICE_RT_PORT_ID, UCAST_QUERY_PORT_ID
 
Constructor Summary
NodeBuilder()
           
NodeBuilder(java.lang.String id_)
           
 
Method Summary
 void build(java.lang.Object c_)
          Builds the node structure inside the specified container.
 void build(java.lang.Object[] cc_)
          Builds up the node structure inside the specified containers.
 void build(java.lang.Object[] cc_, CSLBuilder cb_)
          Builds up the node structure inside the specified containers together with the CSL builder.
 void build(java.lang.Object[] cc_, CSLBuilder cb_, java.lang.String map_)
          Builds up the node structure inside the specified containers together with the CSL builder and the node map.
 void build(java.lang.Object[] cc_, java.lang.String map_)
          Builds up the node structure inside the specified containers with a node map.
 void build(java.lang.Object c_, CSLBuilder cb_)
          Builds the node structure inside the specified container together with the CSL builder.
 void build(java.lang.Object c_, CSLBuilder cb_, java.lang.String map_)
          Builds the node structure inside the specified container together with the CSL builder and a map.
 void build(java.lang.Object c_, java.lang.String map_)
          Builds the node structure inside the specified container with a node map.
 void duplicate(java.lang.Object source_)
          Duplicates the content of source_, including ID, name, child components and connections among them, to this component.
 void extract(Node node_)
          Extracts the structure of an existing Node to the builder.
 double getBandwidth()
           
 java.lang.String getBufferMode()
           
 int getBufferSize()
           
 double getLinkPropDelay()
          Returns the (global) emulated link propagation delay setting.
 int getMTU()
           
 java.lang.String info()
          Returns information regarding this component.
 boolean isLinkEmulationEnabled()
           
 void loadmap(java.lang.String map_)
          Loads the node map into this node builder.
 void setBandwidth(double bw_)
          Sets the bandwidth (in bps) for all the interfaces.
 void setBufferMode(java.lang.String mode_)
          Sets the buffer mode of all the interfaces.
 void setBufferSize(int bs_)
          Sets the buffer size (in bytes) for all the interfaces.
 void setLinkEmulationEnabled(boolean enabled_)
           
 void setLinkPropDelay(double delay_)
          Sets the (global) emulated link propagation delay setting.
 void setMTU(int mtu_)
          Sets the maximum transmission unit (MTU) for all interfaces.
 
Methods inherited from class drcl.comp.Component
_resume, _start, _stop, addComponent, addComponent, addEventPort, addEventPort, addForkPort, addPort, addPort, addPort, addPort, addPort, addPort, addPort, addPort, addServerPort, addServerPort, cancelFork, componentAdded, componentRemoved, connect, containsComponent, containsComponent, containsPort, debug, disconnectAll, disconnectAllPeers, disconnectAllPorts, drop, drop, error, error, expose, exposeEventPorts, exposePort, exposePort, exposePort, exposePort, exposePort, findAvailable, findAvailable, findAvailable, finishing, fork, forkAt, getAllComponents, getAllPorts, getAllPorts, getAllWiresInside, getAllWiresInsideOut, getAllWiresOut, getComponent, getComponentFlag, getComponentFlag, getContract, getContractHT, getContractHT, getDebugFlagsInBinary, getDebugLevelNames, getForkManager, getID, getName, getParent, getPort, getPort, getRoot, getRuntime, getTime, iduplicate, isAncestorOf, isComponentNotificationEnabled, isContainer, isDebugEnabled, isDebugEnabledAt, isDirectlyRelatedTo, isDirectOutputEnabled, isEnabled, isErrorNoticeEnabled, isEventExportEnabled, isGarbageDisplayEnabled, isGarbageEnabled, isPortNotificationEnabled, isPortRemovable, isStarted, isStopped, isTraceEnabled, lock, notify, notifyAll, operate, portAdded, portRemoved, process, reboot, removeAll, removeAllComponents, removeAllPorts, removeAllPorts, removeComponent, removeComponent, removePort, removePort, removePort, reset, resume, run, sduplicate, send, sendAt, setComponentFlag, setComponentFlag, setComponentNotificationEnabled, setContract, setDebugEnabled, setDebugEnabled, setDebugEnabledAt, setDebugEnabledAt, setDebugEnabledAt, setDirectOutputEnabled, setDirectOutputEnabled, setEnabled, setErrorNoticeEnabled, setErrorNoticeEnabled, setEventExportEnabled, setEventExportEnabled, setExecutionBoundary, setGarbageDisplayEnabled, setGarbageDisplayEnabled, setGarbageEnabled, setGarbageEnabled, setID, setID, setName, setPort, setPort, setPortNotificationEnabled, setPortRemovable, setRuntime, setTraceEnabled, setTraceEnabled, sleepFor, sleepUntil, stop, toString, unexpose, unlock, useLocalForkManager, useLocalForkManager, wait, yield
 
Methods inherited from class drcl.DrclObj
clone
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NodeBuilder

public NodeBuilder()

NodeBuilder

public NodeBuilder(java.lang.String id_)
Method Detail

duplicate

public void duplicate(java.lang.Object source_)
Description copied from class: Component
Duplicates the content of source_, including ID, name, child components and connections among them, to this component. Subclasses need to override this method to copy its own variables.

Specified by:
duplicate in interface ObjectDuplicable
Overrides:
duplicate in class Component

info

public java.lang.String info()
Description copied from class: Component
Returns information regarding this component. Subclasses should override this method to provide useful information at run time.

Overrides:
info in class Component

extract

public void extract(Node node_)
Extracts the structure of an existing Node to the builder.


build

public void build(java.lang.Object[] cc_)
Builds up the node structure inside the specified containers. The method calls build(cc_, (CSLBuilder)null).

See Also:
build(Object[], CSLBuilder)

build

public void build(java.lang.Object[] cc_,
                  java.lang.String map_)
Builds up the node structure inside the specified containers with a node map. The method calls build(cc_, null, map_).

See Also:
build(Object[], CSLBuilder, String)

build

public void build(java.lang.Object[] cc_,
                  CSLBuilder cb_,
                  java.lang.String map_)
Builds up the node structure inside the specified containers together with the CSL builder and the node map. This method first calls loadmap(map_) to create protocols and applications, and then build(cc_, cb_) to build the nodes.

Parameters:
cc_ - array of components in which the node structure is constructed. Components other than drcl.inet.Node are omitted processed.
cb_ - the CSL builder.
map_ - the node map.
See Also:
loadmap(String), build(Object[], CSLBuilder)

loadmap

public void loadmap(java.lang.String map_)
Loads the node map into this node builder. Appropriate components and connections are established as the map instructs.


build

public void build(java.lang.Object[] cc_,
                  CSLBuilder cb_)
Builds up the node structure inside the specified containers together with the CSL builder. If cb_ is null, then this method finds the CSL builder inside this node builder as a child component with ID "csl". If no CSL builder exists, the default CSL builder (CSLBuilder.DEFAULT_BUILDER) is used.

Parameters:
cc_ - array of components in which the node structure is constructed. Components other than drcl.inet.Node are omitted processed.
cb_ - the CSL builder.
See Also:
CSLBuilder

build

public void build(java.lang.Object c_)
Builds the node structure inside the specified container. The method calls build(new Object[]{c_}, (CSLBuilder)null).

Parameters:
c_ - the container component.
See Also:
build(Object[], CSLBuilder)

build

public void build(java.lang.Object c_,
                  java.lang.String map_)
Builds the node structure inside the specified container with a node map. The method calls build(new Object[]{c_}, null, map_).

Parameters:
c_ - the container component.
map_ - the node map.
See Also:
build(Object[], CSLBuilder, String)

build

public void build(java.lang.Object c_,
                  CSLBuilder cb_)
Builds the node structure inside the specified container together with the CSL builder. The method calls build(new Object[]{c_}, cb_).

Parameters:
c_ - the container component.
cb_ - the CSL builder.
See Also:
build(Object[], CSLBuilder)

build

public void build(java.lang.Object c_,
                  CSLBuilder cb_,
                  java.lang.String map_)
Builds the node structure inside the specified container together with the CSL builder and a map. The method calls build(new Object[]{c_}, cb_, map_).

Parameters:
c_ - the container component.
cb_ - the CSL builder.
map_ - the node map.
See Also:
build(Object[], CSLBuilder, String)

setBandwidth

public void setBandwidth(double bw_)
Sets the bandwidth (in bps) for all the interfaces.


getBandwidth

public double getBandwidth()

setBufferSize

public void setBufferSize(int bs_)
Sets the buffer size (in bytes) for all the interfaces.


getBufferSize

public int getBufferSize()

setMTU

public void setMTU(int mtu_)
Sets the maximum transmission unit (MTU) for all interfaces. The length includes the size of the packet header for physical link transmission. A positive value also enables the fragmentation in the core service layer. Zero disables it. The default value applies if a negative value is given.


getMTU

public int getMTU()

setBufferMode

public void setBufferMode(java.lang.String mode_)
Sets the buffer mode of all the interfaces.

Parameters:
mode_ - can be either "packet" or "byte".

getBufferMode

public java.lang.String getBufferMode()

setLinkEmulationEnabled

public void setLinkEmulationEnabled(boolean enabled_)

isLinkEmulationEnabled

public boolean isLinkEmulationEnabled()

setLinkPropDelay

public void setLinkPropDelay(double delay_)
Sets the (global) emulated link propagation delay setting. Used with link emulation enabled.


getLinkPropDelay

public double getLinkPropDelay()
Returns the (global) emulated link propagation delay setting. Used with link emulation enabled.


J-Sim v1.2.1-p7 API

Copyright © 1998-2003 Distributed Real-time Computing Lab (DRCL). All Rights Reserved.     ~ To J-Sim Home ~