class CAVERNnet_udp_c : public CAVERNnet_socketbase_c

UDP Class

Inheritance:


Public Methods

void enableInstrumentation ()
Enable the logging of latency and inter-message delay
void disableInstrumentation ()
Disable the logging of latency and inter-message delay
void setTimeOut (int t)
Set timeout period when performing read() or write() operations
int getTimeOut ()
Get timeout period
int init (unsigned short port = 0)
Open a socket
int setSendAddress (char *host, unsigned short port)
Set address to send to
void copyReceiveAddressToSendAddress ()
Copy the receive address to send address
CAVERNnet_udp_c* clone ()
Make a clone of the current udp object
int send (char *message, int length, int blockingType = CAVERNnet_udp_c::NULL_VALUE)
Send data
int receive (char *message, int length, int blockingType = CAVERNnet_udp_c::NULL_VALUE)
Receive data
int peek (char *message, int length)
Peek at incoming packet
void makeNonBlocking ()
Make a connection non blocking (This method is being phased out of the distribution - you can set the blocking type in send() or receive() directly)
void printInfo ()
Print information on the connection (IP address, port number etc).
void close ()
Close the udp handle
void showStats (char* streamInfo, char* comment)
Displays the resultant statistics instantaneously in the netlogger format - this should be typically done after a read/write is done a network
int logStats (char* streamInfo, char* comment, FILE* filePtr)
This logs performance statistics in a file
int sendStats (char* streamInfo, char* comment)
Sends the performance statistics to a remote perfdaemon -for further analysis of the monitored data - the initSendStats API should be called first, before calling a sendStats (In order to connect to the perfdaemon initially)

int initSendStats (char* monitorClientIP, int port = PERF_DAEMON_DEFAULT_PORT)
Initialize sendStats - provide the IP of the perfDaemon and an optional port number to connect to
void exitSendStats ()
Properly delete the perfDaemonClient after sendStats is done

Public


Status values
static const int OK
Status ok.
static const int FAILED
Status failed.

Blocking parameter values for Read/Write method.
static const int BLOCKING
Make the connection blocking but timeout eventually.
static const int NON_BLOCKING
Make the connection non blocking.
static const int NULL_VALUE
Default value used for the send() and receive().

Time out values.
static const int NO_TIME_OUT
Used to set time out period to never time out.
static const int DEFAULT_TIME_OUT
Default time out is no time out.

Return values from Read/Write methods.
static const int SOCKET_NOT_OPEN
Socket is not open.
static const int TIMED_OUT
The read/write timed out.
static const int NON_BLOCKING_NOT_READY_TO_WRITE
You attempted to write with non blocking and socket was not ready.
static const int NON_BLOCKING_HAS_NO_DATA
You attempted to read with non blocking and there was no data.

Accessor Functions
unsigned long getReceiveIP ()
Get an incoming packet's originating address.
void getReceiveIP (char *ip)
Get an incoming packet's originating address.
unsigned short getReceivePort ()
Get an incoming packet's originating port.
unsigned long getSendIP ()
Get outgoing packet's destination address.
void getSendIP (char *ip)
Get outgoing packet's destination address.
unsigned short getSendPort ()
Get outgoing packet's destination port.
unsigned long getSelfIP ()
Get your own IP.
void getSelfIP (char *ip)
Get your own IP.
unsigned short getSelfPort ()
Get your own port.
int getSocketId ()
Get the socket id

Inherited from CAVERNnet_socketbase_c:

Public Methods

static int hostnameToIP(char *hostname, char* hostIP)
static void ipNumToString(unsigned int ip, char *ipstring)
static double getTimeInSecs()
static void getHostName(char *name, int len)
static void expandHostName(char *src, char *newname, int len)
unsigned int getTotalDataSent()
unsigned int getTotalDataRead()
double getInstantReceiveBandwidth()
double getInstantSendBandwidth()
double getAverageReceiveBandwidth()
double getAverageSendBandwidth()
void setInstantLatency(double lat)
double getInstantLatency()
double getAverageLatency()
double getMaxLatency()
double getMinLatency()
void incrementDataSent(unsigned long size)
void incrementDataRead(unsigned long size)
double getInstantInterMesgDelay()
double getMaxInterMesgDelay()
double getMinInterMesgDelay()
double getAverageInterMesgDelay()
double getSTABandwidth()
double getSTALatency()
double getBurstiness()
double getJitter()
unsigned long getPacketsRead()
unsigned long getPacketsSent()
virtual int getSocketId()
int selectSock(void *ptr, int *status, int numSocks, struct timeval *timeout)

Protected Methods

void computeInstantSendBandwidth()
void computeInstantReceiveBandwidth()
void computeAverageReceiveBandwidth()
void computeAverageSendBandwidth()
void calculateJitter(double lat)
void calculateBurstiness(double bw)

Documentation

UDP Class. This class bypasses CAVERN's standard method for establishing connections and provides the user with direct control of UDP connections. The idea is that you first create a udp object and then call the init() method. (see init() method for more details). Then you can either Send data to a destination or receive any incoming data.

To send data to a destination you need to set the destination with the SetSendAddress method and then call the Send method.

To receive data, simply call the Receive method.

By default the connections are BLOCKING, which means, if you call Receive and there is no data available to read your program will block until something comes along. To make your receives or sends non blocking, use the NON_BLOCKING flag as a parameter to the receive() or send().In the previous versions the makeNonBlocking() method was used. The makeNonBlocking() is being phased out.

void enableInstrumentation()
Enable the logging of latency and inter-message delay. Note: in order for this to work, all clients and servers that use UDP connections must also enable their instrumentation or else the bit stream will become confused. Enabling logging prepends timestamp data that is used to compute latency. This affects the achievable bandwidth; so if you intend to use this class to maximize bandwidth utilization we suggest that you DO NOT ENABLE instrumentation. Bandwidth measurements will be made whether you enable instrumentation or not.

void disableInstrumentation()
Disable the logging of latency and inter-message delay. Note: in order for this to work, all clients and servers that use UDP connections must also disable their instrumentation or else the bit stream will become confused. By default instrumentation is disabled except for Bandwidth measurements.

void setTimeOut(int t)
Set timeout period when performing read() or write() operations
Parameters:
t - Time out period in seconds. Set to CAVERNnet_udp_c::NO_TIME_OUT to set no time out period.

int init(unsigned short port = 0)
Open a socket
Returns:
FAILED if failed. OK if succeeded. With the port parameter omitted a dynamic port will be established. Dynamic ports are typically used if you intend to be a client program sending packets to a server. If you are a server then you need to specify some specific port number. Port numbers must be > 6000.
Parameters:
port - Specifies port number.

int setSendAddress(char *host, unsigned short port)
Set address to send to. After a socket is open, you can create a connection to some other listener if you know their address and port
Returns:
0 if failed, 1 if success.

void copyReceiveAddressToSendAddress()
Copy the receive address to send address. You can do this if you want to send a message back to the receiver.

CAVERNnet_udp_c* clone()
Make a clone of the current udp object. This is useful when you get multiple udp messages coming in from different sources and you want to save their return addresses so that you can reply to them. Typically you do a clone and then call CopyReceiveAddresToSendAddress.
See Also:
CopyReceiveAddresToSendAddress

int send(char *message, int length, int blockingType = CAVERNnet_udp_c::NULL_VALUE)
Send data
Returns:
The number of characters sent. If a -1 is found then an error has occured. Check the global variable errno. If you are using NON blocking and errno is EWOULDBLCOK then that's ok, it simply means that you attempted a write but no the socket was not ready. If it is not EWOULDBLOCK then a real error has occured. If you are using blocking with a timeout period (set by using the setTimeOut()),you will get an error if the timeout occurs.
Parameters:
length - If length is set to smaller than the actual outgoing packet size, then the remaining bytes are not sent. If the length is set to larger than actual packet size, the whole packet * gets sent.
blockingType - Default value of this argument is CAVERNnet_udp_c::NULL_VALUE. It can be set to CAVERNnet_udp_c::BLOCKING or CAVERNnet_udp_c::NON_BLOCKING. If a value is not passed the blocking type is changed to the value stored by the private memeber 'typeOfBlocking'.

int receive(char *message, int length, int blockingType = CAVERNnet_udp_c::NULL_VALUE)
Receive data
Returns:
The number of bytes found in the packet. If a -1 is found then there might be a read error. Check the global variable errno. If you are using NON blocking and errno is EWOULDBLOCK then that's ok, it simply means you attempted a read but no data was available. If its not EWOULDBLOCK then you have a real error. To find out what the error means call: perror() - this is a UNIX call.If you are using blocking with a timeout period (set by using the setTimeOut()),you will get an error if the timeout occurs.
Parameters:
length - If length is set to smaller than actual incoming packet size, then the remaining bytes of packet is discarded. If length is set to larger than actual packet size, then only the number of bytes available in the packet is retrieved.
blockingType - Default value of this argument is CAVERNnet_udp_c::NULL_VALUE. It can be set to CAVERNnet_udp_c::BLOCKING or CAVERNnet_udp_c::NON_BLOCKING. If a value is not passed the blocking type is changed to the value stored by the private memeber 'typeOfBlocking'.

int peek(char *message, int length)
Peek at incoming packet. - without extracting it from the queue.
Returns:
number of bytes available to be extracted.

void close()
Close the udp handle. Must not do this as a destructor or you will disconnect a connection that might be still held by another client object. Only do this explicitly when you want to close a connection.

void showStats(char* streamInfo, char* comment)
Displays the resultant statistics instantaneously in the netlogger format - this should be typically done after a read/write is done a network.

Also, it should be noted that a showStats call should be made at the end of atleast one send and receive for two-way information (the same applies for logStats and sendStats)

Parameters:
streamInfo - A label describing the stream that is being monitored.
comment - A comment on the event that marks the time at which the stream is being monitored

int logStats(char* streamInfo, char* comment, FILE* filePtr)
This logs performance statistics in a file. The user opens a file and passes the file pointer with this function and results of monitoring are written into the logfile.

Returns:
Either CAVERNnet_perfMonitor_c::OK or CAVERNnet_perfMonitor_c::FAILED
Parameters:
streamInfo - A label describing the stream that is being monitored.
comment - A comment on the event that marks the time at which the stream is being monitored
filePtr - File pointer to the file in which the results of monitoring are to be stored

int sendStats(char* streamInfo, char* comment)
Sends the performance statistics to a remote perfdaemon -for further analysis of the monitored data - the initSendStats API should be called first, before calling a sendStats (In order to connect to the perfdaemon initially)

Returns:
Either CAVERNnet_perfMonitor_c::OK or CAVERNnet_perfMonitor_c::FAILED
Parameters:
streamInfo - A label describing the stream that is being monitored.
comment - A comment on the event that marks the time at which the stream is being monitored

int initSendStats(char* monitorClientIP, int port = PERF_DAEMON_DEFAULT_PORT)
Initialize sendStats - provide the IP of the perfDaemon and an optional port number to connect to. This should be done initially before using the sendStats API.

Returns:
Either CAVERNnet_perfMonitor_c::OK or CAVERNnet_perfMonitor_c::FAILED
Parameters:
monitorClientIP - IP address of the perfDameon to connect to
port - Port number at which the perfDaemon is running -this is optional. The default port number for perfDaemon is 9500 -so a different port number has to be specified if the perfDaemon is running ona different port.


This class has no child classes.
Author:
(C) 1996 Jason Leigh
Version:
Version 5/26/97

alphabetic index hierarchy of classes


this page has been generated automatically by doc++

(c)opyright by Malte Zöckler, Roland Wunderling
contact: doc++@zib.de