de.tubs.macs.util.net
Class DDH

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--de.tubs.macs.util.net.DDH

public class DDH
extends java.lang.Thread
implements Net

DDH - Dirks Dirty Hack A simple UDP based protocol providing segmentated semi-reliable transmission of data between TWO partners. a low level DDH Packet has a 4 byte header 0 sequence number high byte 1 sequence number low byte 2 number of current segment 3 total number of segments a resend request will set total to 0 and the seqence number will reflect the requested packet. the algorithm is very simple. if a missing segment is detected the whole corresponding object is requested again. this will occure only once, that is if packets from the same object are lost again it will be ignored! To improve this the following has to be done! 1. make a list of remote sites and move all relevant data into such an entry -> cleaner design -> easier extension to multiparty (not just one communication partner) 2. move DDHBuffer and Co to seperate files -> better modularity 3. change buffer strategy by replacing oldest entries and not just first -> better recovery 4. introduce retry counter to allow variable number of retries -> better recovery and felxibility 5. introduce remote hardbeat (including sequence number) -> faster repair -> enable detection of loss of contact -> allows to flush buffer and to stop sending 6. enable multiparty support

Author:
D. Sturzebecher

Inner Class Summary
 class DDH.DDHBuffer
           
 class DDH.DDHBufferEntry
           
 
Field Summary
static java.lang.String name
           
static DDH primary
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY, values
 
Constructor Summary
DDH(java.lang.String typeID, NetManager netManager)
           
 
Method Summary
 void close()
          Close the connections.
 void flush()
          Flush the send Queue (if applicable).
 NetAddress getAddress()
          Get address.
 DDHAddress getLocalAddress()
           
 java.lang.Object getOptions()
          Get options.
 DDHAddress getRemoteAddress()
           
 int getTTL()
          return the scope of the Network in form of a TTL.
 java.lang.String getType()
          return the type id of the Network
 void init(NetReceiver receiver, NetAddress otherAddress)
          Initialise the system and set the receiver for data.
 void run()
          process incoming packets
 boolean send(java.lang.Object object)
          Send a Object and return its size in byte.
 boolean setRemoteAddress(java.net.InetAddress address, int port, long seq)
          Set remote address.
 
Methods inherited from class java.lang.Thread
, activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

name

public static final java.lang.String name

primary

public static DDH primary
Constructor Detail

DDH

public DDH(java.lang.String typeID,
           NetManager netManager)
Method Detail

getType

public java.lang.String getType()
Description copied from interface: Net
return the type id of the Network
Specified by:
getType in interface Net

getTTL

public int getTTL()
Description copied from interface: Net
return the scope of the Network in form of a TTL. This should be replaced by a better mechanism sometime.
Specified by:
getTTL in interface Net

getLocalAddress

public DDHAddress getLocalAddress()

getRemoteAddress

public DDHAddress getRemoteAddress()

init

public void init(NetReceiver receiver,
                 NetAddress otherAddress)
          throws NetException
Initialise the system and set the receiver for data.

This should only be used by the NetManager !

Specified by:
init in interface Net
Parameters:
receiver - NetReciever
group - address of the net group
Throws:
NetException - see NetException doc for detail

run

public void run()
process incoming packets
Overrides:
run in class java.lang.Thread

send

public boolean send(java.lang.Object object)
             throws NetException
Send a Object and return its size in byte.
Specified by:
send in interface Net
Throws:
NetException - see NetException doc for detail

getAddress

public NetAddress getAddress()
                      throws NetException
Get address.
Specified by:
getAddress in interface Net
Throws:
NetException - see NetException doc for detail

setRemoteAddress

public boolean setRemoteAddress(java.net.InetAddress address,
                                int port,
                                long seq)
                         throws java.io.IOException
Set remote address.
Throws:
NetException - see NetException doc for detail

getOptions

public java.lang.Object getOptions()
Get options.
Specified by:
getOptions in interface Net
Throws:
NetException - see NetException doc for detail

flush

public void flush()
           throws NetException
Flush the send Queue (if applicable).
Specified by:
flush in interface Net
Throws:
NetException - see NetException doc for detail

close

public void close()
           throws NetException
Close the connections.
Specified by:
close in interface Net
Throws:
NetException - see NetException doc for detail