All Packages Class Hierarchy This Package Previous Next Index
Class iBus.layers.IPMCAST
java.lang.Object
|
+----iBus.ProtocolObject
|
+----iBus.layers.IPMCAST
- public class IPMCAST
- extends ProtocolObject
- implements Runnable
IPMCAST implements unreliable message delivery using the
IP multicast and the UDP protocol.
IPMCAST assumes that higher layers take care of message fragmentation
and flow control. IPMCAST is typically the bottommost object in a protocol
PARAMETERS:
-
ttl: int: >= 0. TTL value for IP multicast datagrams.
Default: 1.
-
eventqueuesz: int: > 0. size of the queue that buffers incoming messages.
Default: -1 (unbounded).
-
sendelay: int: >= 0. how many milliseconds to pause after each
network send operation.
Default: 0 (no delay).
POSITION IN STACK:
DESIGN:
-
IPMCAST maintains one UDPEndp for sending to all point-to-point
destinations,
and one UDPEndp per distinct port/class A-C IP address combination the
stack is subscribed to. It further maintains one McastEndp object
for sending to all multicast destinations, and one McastEndp per
distinct port/class D IP address combination the stack is subscribed to.
IPMCAST further contains one event queue (eventQueue_)
and one thread (upHandleEventT_). For each
UDPEndp and McastEndp there is one thread that reads events from
the Socket inside the endpoint object, and puts those events into
eventQueue_. upHandleEventT_ gets events off eventQueue_ and passes
them up the stack. Hence upHandleEvent() is called always by one and the
same thread (upHandleEventT_).
EVENTS PRODUCED:
-
MessageEvent when a datagram is received
EVENTS CONSUMED:
EVENTS HANDLED:
THREADS:
-
See design notes. There is only one thread that calls upHandleEvents().
There is one thread per distinct port/IP address subscription.
-
maxDatagramSize_
- max.
-
IPMCAST()
- Create an IP multicast protocol object
-
dnFlush()
- Flush the protocol object.
-
dnGetStackURL()
- Called by the API protocol object to obtain an URL used
to reply to this stack.
-
dnInit()
-
Initialize the IPMCAST object.
-
dnPush(iBusURL, MessageEvent)
- dnPush sends a message by multicast or unicast, depending on the
IP address in the URL.
-
dnSubscribe(iBusURL)
- Subscribe to ``url''.
-
dnTerminate()
- Terminate any threads in the protocol object.
-
dnThrottle(boolean)
- The stack is getting overloaded.
-
dnUnsubscribe(iBusURL)
-
Unsubscribe from ``url''.
-
getEventQueueSize()
- Returns the size of the internal event queue.
-
getSenddelay()
- Returns the senddelay property.
-
getStackSocket()
- returns a DatagramSocket denoting this stack.
-
getSubscriptions()
- Returns the subscriptions hashtable.
-
getTTL()
- Returns the TTL property.
-
isHierarchical()
- Checks whether hierarchical matching is enabled
-
putEvent(Event)
- Puts an event into the eventQueue_.
-
run()
- Gets events off the eventQueue and passes them up the stack:
-
setSenddelay(int)
- Sets the senddelay property.
-
setTTL(int)
- Sets the TTL property.
-
subscriptionsForAddr(String)
- Checks whether there is a subscription for IP address ``address''.
maxDatagramSize_
protected static final int maxDatagramSize_
- max. UDP datagram size
IPMCAST
public IPMCAST()
- Create an IP multicast protocol object
dnInit
public synchronized void dnInit()
- Initialize the IPMCAST object. A UDP socket is created for delivering
doUnicast () messages and for receiving such point-to-point messages.
Further, a StackID is created to uniquely identify the protocol stack
the IPMCAST object belongs to. The StackID is piggybacked onto outgoing
messages such that receivers know where to send replies to.
- Overrides:
- dnInit in class ProtocolObject
dnFlush
public void dnFlush()
- Flush the protocol object. Deliver any buffered messages.
- Overrides:
- dnFlush in class ProtocolObject
dnTerminate
public void dnTerminate()
- Terminate any threads in the protocol object. The object is
unusable afterwards.
- Overrides:
- dnTerminate in class ProtocolObject
dnPush
public void dnPush(iBusURL dest,
MessageEvent msg) throws CommException
- dnPush sends a message by multicast or unicast, depending on the
IP address in the URL.
- Parameters:
- dest - the iBus URL of the destination
- msg - the iBus message to be sent
- Throws: CommException
- in case of a communication
failure
- Overrides:
- dnPush in class ProtocolObject
dnSubscribe
public synchronized void dnSubscribe(iBusURL url) throws AlreadySubscribed, CommException
- Subscribe to ``url''. If the stack is not a member of
subject.getAddress () already, create a MulticastSocket and join it.
Otherwise we just put subject.getSubject () into a local hashtable.
- Parameters:
- url - the iBus URL to subscribe for
- Throws: AlreadySubscribed
- if this stack has already
subscribed to the subject
- Throws: CommException
- in case of a communication
exception when joining the IP multicast group
- Overrides:
- dnSubscribe in class ProtocolObject
dnUnsubscribe
public synchronized void dnUnsubscribe(iBusURL url) throws NotSubscribed, CommException
- Unsubscribe from ``url''. Leave the associated IP group
if there are no more subjects we are registered to for that IP group.
- Parameters:
- url - the iBus URL to unsubscribe from
- Throws: NotSubscribed
- if this stack is
not subscribed to the subject
- Throws: CommException
- in case of a communication
exception when leaving the IP group
- Overrides:
- dnUnsubscribe in class ProtocolObject
dnGetStackURL
public synchronized iBusURL dnGetStackURL()
- Called by the API protocol object to obtain an URL used
to reply to this stack. dnGetStackURL is typically implemented by the
bottommost protocol object only.
- Returns:
- the URL of the stack
- Overrides:
- dnGetStackURL in class ProtocolObject
dnThrottle
public synchronized void dnThrottle(boolean stop)
- The stack is getting overloaded. Tell the senders to slow
down the rate at which they send messages to us.
- Parameters:
- stop - true if throttling is required, false if unthrottling
is required.
- Overrides:
- dnThrottle in class ProtocolObject
getTTL
public int getTTL()
- Returns the TTL property.
- Returns:
- the TTL property
setTTL
public void setTTL(int ttl)
- Sets the TTL property.
- Parameters:
- ttl - the TTL property
getEventQueueSize
public int getEventQueueSize()
- Returns the size of the internal event queue.
- Returns:
- the size of the internal event queue
getSenddelay
public int getSenddelay()
- Returns the senddelay property.
- Returns:
- the senddelay property
setSenddelay
public void setSenddelay(int s)
- Sets the senddelay property.
- Parameters:
- s - the senddelay property
isHierarchical
public boolean isHierarchical()
- Checks whether hierarchical matching is enabled
- Returns:
- whether hierarchical matching is enabled
run
public void run()
- Gets events off the eventQueue and passes them up the stack:
putEvent
protected synchronized void putEvent(Event e)
- Puts an event into the eventQueue_.
- Parameters:
- e - the event to put
getStackSocket
protected DatagramSocket getStackSocket()
- returns a DatagramSocket denoting this stack.
- Returns:
- a DatagramSocket denoting this stack
subscriptionsForAddr
protected synchronized int subscriptionsForAddr(String address)
- Checks whether there is a subscription for IP address ``address''.
- Parameters:
- address - the IP address to check
- Returns:
- the number of subscriptions for IP address ``address''
getSubscriptions
protected Hashtable getSubscriptions()
- Returns the subscriptions hashtable.
- Returns:
- the subscriptions hashtable
All Packages Class Hierarchy This Package Previous Next Index