SSF.OS.UDP.test
Class udpStreamServer

java.lang.Object
  |
  +--SSF.OS.ProtocolSession
        |
        +--SSF.OS.UDP.test.udpStreamServer
All Implemented Interfaces:
com.renesys.raceway.DML.Configurable

public class udpStreamServer
extends ProtocolSession

A simple UDP streaming server application provided as an example. The server configures itself from the DML file that specifies the server's wellKnownPort, the maximum datagram_size ( = payload in bytes) and the send_interval (in seconds) between sending consecutive chunks of virtual data to the client.

The client-server protocol is absolutely minimal: the client sends to server's well known address just one integer that specifies the total amount of virtual data it requests. After receiving a client's request, the server spawns a slave server that periodically sends the datagrams of size datagram_size to the client until the request is fulfilled.

The default is no limit on the number of clients, unless the attribute client_limit is set.

There is no limit on the number of servers that can coexist in a single Host as long as each udpServer has a distinct wellKnownPort number.

If datagram_size is chosen to be larger than allowed by either the local UDP protocol (udpinit.send_buffer_size), or by the remote UDP receive buffer (udpinit.rcv_buffer_size), the datagrams will be dropped - with some diagnostic output if the debug options are set to true.

The datagram_size and send_interval should be chosen so that the resulting data bandwidth does not exceed the bitrate specified on the server's Host link interface, otherwise the interface will queue the outgoing datagrams and may drop them if configured with small enough buffer.


Field Summary
 
Fields inherited from class SSF.OS.ProtocolSession
name, use
 
Constructor Summary
udpStreamServer()
          Constructors
 
Method Summary
 void config(com.renesys.raceway.DML.Configuration cfg)
          Server configuration.
 void init()
          Initialization routine, called by the ProtocolGraph after instantiation.
 boolean push(ProtocolMessage message, ProtocolSession fromSession)
          Routine to call when a message is being sent to ("pushed into") this ProtocolSession by another ProtocolSession.
 void serv()
           
 
Methods inherited from class SSF.OS.ProtocolSession
close, closed, debugIdentifier, inGraph, open, opened, pushAfterDelay, pushAfterDelayFailed, setGraph, version
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

udpStreamServer

public udpStreamServer()
Constructors

Method Detail

config

public void config(com.renesys.raceway.DML.Configuration cfg)
            throws com.renesys.raceway.DML.configException
Server configuration. Supported DML attributes:
  ProtocolSession [ name server use SSF.OS.UDP.test.udpStreamServer
    port          %I      # server's well known port number
    client_limit  %I      # max number of simultaneous clients,
                          # if omitted, no limit

    request_size  %I      # client request nominal datagram size (bytes, int)
    datagram_size %I      # max server datagram payload size (virtual bytes, int)
    send_interval %F      # time interval between consecutive server datagrams, sec
                          # if omitted, datagrams are sent back to back

    show_report   %S      # print client-server session summary report, true/false
    debug         %S      # print verbose client/server diagnostics, true/false
  ]
 

Specified by:
config in interface com.renesys.raceway.DML.Configurable
Overrides:
config in class ProtocolSession
com.renesys.raceway.DML.configException

init

public void init()
Description copied from class: ProtocolSession
Initialization routine, called by the ProtocolGraph after instantiation. The order of initialization of a set of protocols is unspecified, so other methods (like open()) may be called before init(). Resources (like connection tables) that may be needed by open() should therefore be created in the ProtocolSession constructor.

Overrides:
init in class ProtocolSession

serv

public void serv()

push

public boolean push(ProtocolMessage message,
                    ProtocolSession fromSession)
             throws ProtocolException
Description copied from class: ProtocolSession
Routine to call when a message is being sent to ("pushed into") this ProtocolSession by another ProtocolSession. The pusher sends a reference to itself in the second argument. This push happens immediately, without any simulation time elapsing, regardless of other activities taking place in the ProtocolGraph.

If you desire "safe" interaction with other CPU activities, even though your push() consumes no measurable/modelable CPU cycles, define the "cpudelay true" attribute for the ProtocolGraph and use pushAfterDelay(message,fromSession,0.0). This will guarantee proper ordering; that is, the framework will wait until the CPU is free before proceeding with the requested push().

Specified by:
push in class ProtocolSession
ProtocolException