Client-Server

Client
Server
Configuration
Running
Performance
Byte Array Interface  Float Array Interface  Structure Interface 

Client-server is the basic Ice mode of use. Given an interface definition as in the previous section, very little application-specific code is required, as can be seen from the following code summaries.

Client

#include <math.h>
#include <Ice/Ice.h>
#include <MessagesI.h>

using namespace std;
using namespace CODAC;

class Client : public Ice::Application
{
public:
   virtual int run(int, char*[]);
};

int
Client::run(int argc, char* argv[])
{
   // declarations (application)
   ......

   // initialize client (Ice calls)
   ......

   // create message buffer (application)
   ......

   // send messages (application)
   for (int m = 0; m < messageCount; m++) {
      // set message data
      ......

      // call MessagesI member function on server
      //oneway->publishDataMessageOneWay(message);
      result = twoway->publishDataMessageTwoWay(message);

      // record timing
      ......
   }

   // report results (application)
   ......

   return EXIT_SUCCESS;
}

int
main(int argc, char* argv[])
{
   Client app;
   return app.main(argc, argv, "config.client");
}

Server

#include <MessagesI.h>
#include <Ice/Application.h>

using namespace std;

class Server : public Ice::Application
{
public:
   virtual int run(int, char*[]);
};

int
Server::run(int argc, char* argv[])
{
   // activate server and enter message processing loop (Ice calls)
   // call MessagesI member function when a message arrives
   ......

   // exit on subscriber shutdown (Ice calls)
   return EXIT_SUCCESS;
}

int
main(int argc, char* argv[])
{
   Server app;
   return app.main(argc, argv, "config.server");
}

Configuration

These extracts from the configuration files show how the communication transport and endpoints are defined.

Client:

Messages.Proxy=messages:tcp -h 192.168.1.41 -p 10000

Server:

Messages.Endpoints=tcp 192.168.1.41 -p 10000

Running

The tests were run on bigbeast and storm08 by simply doing:

bigbeast: ./server
storm08: ./client
Different message sizes were configured by changing constants in MessagesI.h, and oneway or twoway transmission selected by editing Client.cpp, followed by recompilation.

Performance

With oneway transmission the message is sent and no return value expected; with twoway, a value is returned by the server to the client. Results varied from run to run; representative results are given here. Little difference was seen between results when the Linux OS on bigbeast was compiled as 32-bit or as 64-bit (only 2 comparisons were done, and taken as indicative). With a message size of 10kB or 100kB, throughput for oneway calls approached or achieved the maximum possible over a single Gigabit Ethernet connection. Twoway calls with a message size of 10kB are comparatively expensive. Test duration was several minutes, with the client sending messages in a continuous loop. Time measurements were made using the client's high resolution cpu timer. 1MB = 1.0e6 bytes.

Byte Array Interface

message type message size (MB) cycle time av (ms) throughput av (MB/s)
oneway 0.01 0.085 117
  0.1 0.85 117
  1.0 11.8 85
  10.0 126 80
twoway 0.01 0.37 27
  0.1 1.57 64
  1.0 14.2 70
  10.0 145 69

Float Array Interface

message type message size (MB) cycle time av (ms) throughput av (MB/s)
oneway 0.01 0.088 114
  0.1 0.91 110
  1.0 10.5 95
  10.0 120 83
twoway 0.01 0.35 28
  0.1 1.45 69
  1.0 13.3 75
  10.0 141 71

Structure Interface

message type message size (MB) cycle time av (ms) throughput av (MB/s)
oneway 0.01 0.086 116
  0.1 0.85 117
  1.0 10.6 94
  10.0 130 77
twoway 0.01 0.38 27
  0.1 1.8 55
  1.0 15.1 66
  10.0 163 61