class CAVERNnet_tcpClient_c : public CAVERNnet_socketbase_c

TCP Class for creating client connections

Inheritance:


Public Methods

void setTimeOut (int t)
Set timeout period when performing read() or write() operations
int getTimeOut ()
Get timeout period
void setClientInfo (struct sockaddr_in* info)
Set client info
void setClientSockFd (int sockfd)
Set client socket
void showStatus (int status, int nbytes)
Show status of connection in English.
void close ()
Close the current client connection.
int connectToServer (char *ip, int port)
Connect to a server
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 over 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 perFDaemon Client after sendStats is done

Public


Blocking parameter values for Read/Write method.
static const int BLOCKING
Make the connection blocking but time out eventually.
static const int NON_BLOCKING
Make the connection non blocking.

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 CONNECTION_TERMINATED
Connection you attempted to read/write is terminated.
static const int NON_BLOCKING_HAS_NO_DATA
You attempted to read with non blocking and there was not data.
static const int TIMED_OUT
The read/write timed out.
static const int OK
Read/Write succeeded.
static const int NON_BLOCKING_NOT_READY_TO_WRITE
You attempted to write with non blocking and socket was not ready.
static const int NOT_READY
Socket was not ready.
static const int READY_TO_READ
Socket ready to read.
static const int READY_TO_WRITE
Socket ready to write.
static const int READY_TO_READ_AND_WRITE
Socket ready to read and write.
static const int READ_BUFFER_SIZE
Change the socket buffer size before Read().
static const int WRITE_BUFFER_SIZE
Change the socket buffer size before Write().

Accessor functions
unsigned int getRemoteIP ()
Get the IP address of remote connection
void getRemoteIP (char* name)
Get the IP address of remote connection
unsigned int getSelfIP ()
Get IP address of self.
void getSelfIP (char *name)
Get IP address of self.
int getSelfPort ()
Get port of self.
int getRemotePort ()
Get port of client.
int getSocketId ()
Get socket id
Read and Write calls.
int read (char *ptr, int *nbytes, int blockingType)
void setSockOptions (int option, int buffersize)
Allows you to change the parameters to the setsockopt() options
int isReadyToRead ()
Determines if a socket has data available to read
int isReadyToWrite ()
Determines if a socket is ready to write
int isReady ()
Determines if a socket is ready to write or read or both
int write (char *ptr, int *nbytes, int blockingType)
Write data to socket

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

TCP Class for creating client connections. This class bypasses CAVERN's standard method for establishing connections and provides the user with direct control of TCP connections.
void setTimeOut(int t)
Set timeout period when performing read() or write() operations
Parameters:
t - Time out period in seconds. Set to CAVERNnet_tcpClient_c::NO_TIME_OUT to set no time out period.

void setClientInfo(struct sockaddr_in* info)
Set client info. For internal use.
Parameters:
info - client information

void setClientSockFd(int sockfd)
Set client socket. For internal use.
Parameters:
sockfd - client socket

unsigned int getRemoteIP()
Get the IP address of remote connection. If you are a client this returns the ip of the destination server. If you are a server this returns the ip of the destination client.

void getRemoteIP(char* name)
Get the IP address of remote connection. If you are a client this returns the ip of the destination server. If you are a server this returns the ip of the destination client.

Read and Write calls.

int read(char *ptr, int *nbytes, int blockingType)
Returns:
SOCKET_NOT_OPEN, NON_BLOCKING_HAS_NO_DATA, TIMED_OUT, CONNECTION_TERMINATED, OK, errno
Parameters:
nbytes - Fill nbytes with num bytes you want to read. nbytes will return with number of bytes successfully read.
blockingtype - BLOCKING means that it will block waiting for data or until the timeout period expires. Change the timeout period by calling setTimeOut(). NON_BLOCKING means that if there is no data to be read this call will return immediately. If it does get some data it will keep reading until the specified number of bytes is received, or if it timesout, or if the connection is broken. In the latter two cases the number of bytes it was able to read is returned. In either the BLOCKING or NON_BLOCKING case you can set the time out period to never time out by setting the timeout time to: NO_TIME_OUT.

void setSockOptions(int option, int buffersize)
Allows you to change the parameters to the setsockopt() options.Currently this member allows you to change socket buffer size.

Parameters:
option - Specify CAVERNnet_tcpClient_c::READ_BUFFER_SIZE if you want to change the size of the receive buffer. Specify CAVERNnet_tcpClient_c::WRITE_BUFFER_SIZE if you want to change the size of the send buffer
buffersize - Specify the size.

int isReadyToRead()
Determines if a socket has data available to read
Returns:
Either: CAVERNnet_tcpClient_c::NOT_READY or CAVERNnet_tcpClient_c::READY_TO_READ

int isReadyToWrite()
Determines if a socket is ready to write
Returns:
Either: CAVERNnet_tcpClient_c::NOT_READY or CAVERNnet_tcpClient_c::READY_TO_WRITE

int isReady()
Determines if a socket is ready to write or read or both
Returns:
Either: CAVERNnet_tcpClient_c::NOT_READY or CAVERNnet_tcpClient_c::READY_TO_WRITE or CAVERNnet_tcpClient_c::READY_TO_READ or CAVERNnet_tcpClient_c::READY_TO_READ_AND_WRITE

int write(char *ptr, int *nbytes, int blockingType)
Write data to socket
Returns:
SOCKET_NOT_OPEN, NON_BLOCKING_NOT_READY_TO_WRITE, TIMED_OUT, CONNECTION_TERMINATED, OK

int connectToServer(char *ip, int port)
Connect to a server
Returns:
A negative number(that is returned by a socket sonnect() call if failed. Else returns client's socket file descriptor. (note: the return value in the previous versions was a zero in case of an error - this has been changed to a negative value from version 1.2)

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 over 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.


Direct child classes:
CAVERNnet_extendedTcpClient_c

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