spocket_tester.h

Go to the documentation of this file.
00001 #ifndef TEST_CROMP_CLASS
00002 #define TEST_CROMP_CLASS
00003 
00004 /*****************************************************************************\
00005 *                                                                             *
00006 *  Name   : spocket_tester                                                    *
00007 *  Author : Chris Koeritz                                                     *
00008 *                                                                             *
00009 *  Purpose:                                                                   *
00010 *                                                                             *
00011 *    Puts the spocket class through some test paces.                          *
00012 *                                                                             *
00013 *******************************************************************************
00014 * Copyright (c) 2000-$now By Author.  This program is free software; you can  *
00015 * redistribute it and/or modify it under the terms of the GNU General Public  *
00016 * License as published by the Free Software Foundation; either version 2 of   *
00017 * the License or (at your option) any later version.  This is online at:      *
00018 *     http://www.fsf.org/copyleft/gpl.html                                    *
00019 * Please send any updates to: fred@gruntose.com                               *
00020 \*****************************************************************************/
00021 
00022 #include <basis/definitions.h>
00023 
00024 // forward.
00025 class internet_address;
00026 class raw_socket;
00027 class spocket;
00028 class tcpip_stack;
00029 
00030 // this structure is filled by the tester during a send data call.
00031 class testing_statistics
00032 {
00033 public:
00034   int total_runs;       // how many cycles did we successfully do?
00035   int bytes_sent;       // overall count of bytes sent.
00036   int bytes_received;   // overall count of bytes received.
00037   int send_time;        // time taken just to invoke "send" function.
00038   int receive_time;     // time taken just to invoke "recv" function.
00039   int round_trip_time;  // time taken between sending and receiving back.
00040 
00041   testing_statistics()
00042       : total_runs(0), bytes_sent(0), bytes_received(0), send_time(0),
00043         receive_time(0), round_trip_time(0) {}
00044 };
00045 
00046 // our main tester class.
00047 class spocket_tester
00048 {
00049 public:
00050   spocket_tester(const internet_address &where);
00051     // constructs the tester object.  "where" provides information about either
00052     // this side (for a server) or the other side (for a client).
00053 
00054   ~spocket_tester();
00055     // destroys the tester object.
00056 
00057   bool connect();
00058     // acts as a client and connects to a destination.
00059 
00060   bool accept();
00061     // acts as a server and accepts a connection from a client.
00062 
00063   bool do_a_send(byte *buffer, int size, testing_statistics &stats);
00064 
00065   bool do_a_receive(int size_expected, testing_statistics &stats);
00066 
00067   bool perform_test(int size, int count, testing_statistics &stats_to_fill);
00068     // sends "count" random data chunks of the "size" specified.  the measured
00069     // performance during this sending is reported in "stats_to_fill".
00070 
00071 private:
00072   internet_address *_where;  // our communications endpoint.
00073   tcpip_stack *_stack;  // provides access to the operating system layers.
00074   spocket *_socket;  // does the communication for us.
00075   spocket *_root_server;  // used for server side testing.
00076   raw_socket *_raw;  // provides functions on sockets.
00077 };
00078 
00079 #endif
00080 

Generated on Fri Nov 21 04:30:01 2008 for HOOPLE Libraries by  doxygen 1.5.1