bcast_spocketer.h

Go to the documentation of this file.
00001 #ifndef TEST_CROMP_CLASS
00002 #define TEST_CROMP_CLASS
00003 
00004 /*****************************************************************************\
00005 *                                                                             *
00006 *  Name   : broadcast_spocket_tester                                          *
00007 *  Author : Chris Koeritz                                                     *
00008 *                                                                             *
00009 *  Purpose:                                                                   *
00010 *                                                                             *
00011 *    Puts the spocket class in broadcast mode 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 broadcast_spocket_tester
00048 {
00049 public:
00050   broadcast_spocket_tester(const internet_address &where,
00051           bool unicast = false);
00052     // constructs the tester object.  "where" provides information about either
00053     // this side (for a server) or the other side (for a client).
00054     // if "unicast" is true, then we test unicasts instead of broadcasts.
00055 
00056   ~broadcast_spocket_tester();
00057     // destroys the tester object.
00058 
00059   bool connect();
00060     // gets ready for sending and reception.
00061 
00062   bool do_a_send(const internet_address &where_to, byte *buffer, int size,
00063           testing_statistics &stats);
00064 
00065   bool do_a_receive(int size_expected, testing_statistics &stats);
00066 
00067   bool perform_test(const internet_address &dest, int size, int count,
00068           testing_statistics &stats_to_fill);
00069     // sends "count" random data chunks of the "size" specified.  the measured
00070     // performance during this sending is reported in "stats_to_fill".
00071 
00072 private:
00073   internet_address *_where;  // our communications endpoint.
00074   tcpip_stack *_stack;  // provides access to the operating system layers.
00075   spocket *_socket;  // does the communication for us.
00076   spocket *_root_server;  // used for server side testing.
00077   raw_socket *_raw;  // provides functions on sockets.
00078   bool _ucast;  // true if we're unicasting.
00079 };
00080 
00081 #endif
00082 

Generated on Thu Nov 20 04:29:09 2008 for HOOPLE Libraries by  doxygen 1.5.1