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 
00023 #include <sockets/internet_address.h>
00024 #include <sockets/spocket.h>
00025 #include <sockets/tcpip_stack.h>
00026 
00027 // this structure is filled by the tester during a send data call.
00028 class testing_statistics
00029 {
00030 public:
00031   int total_runs;       // how many cycles did we successfully do?
00032   int bytes_sent;       // overall count of bytes sent.
00033   int bytes_received;   // overall count of bytes received.
00034   int send_time;        // time taken just to invoke "send" function.
00035   int receive_time;     // time taken just to invoke "recv" function.
00036   int round_trip_time;  // time taken between sending and receiving back.
00037 
00038   testing_statistics()
00039   : total_runs(0), bytes_sent(0), bytes_received(0), send_time(0),
00040     receive_time(0), round_trip_time(0) {}
00041 };
00042 
00043 // our main tester class.
00044 class broadcast_spocket_tester
00045 {
00046 public:
00047   broadcast_spocket_tester(const sockets::internet_address &where,
00048           bool unicast = false);
00049     // constructs the tester object.  "where" provides information about either
00050     // this side (for a server) or the other side (for a client).
00051     // if "unicast" is true, then we test unicasts instead of broadcasts.
00052 
00053   ~broadcast_spocket_tester();
00054     // destroys the tester object.
00055 
00056   DEFINE_CLASS_NAME("broadcast_spocket_tester");
00057 
00058   bool connect();
00059     // gets ready for sending and reception.
00060 
00061   bool do_a_send(const sockets::internet_address &where_to, basis::abyte *buffer, int size,
00062           testing_statistics &stats);
00063 
00064   bool do_a_receive(int size_expected, testing_statistics &stats);
00065 
00066   bool perform_test(const sockets::internet_address &dest, int size, int count,
00067           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   sockets::internet_address *_where;  // our communications endpoint.
00073   sockets::tcpip_stack *_stack;  // provides access to the operating system layers.
00074   sockets::spocket *_socket;  // does the communication for us.
00075   sockets::spocket *_root_server;  // used for server side testing.
00076   sockets::raw_socket *_raw;  // provides functions on sockets.
00077   bool _ucast;  // true if we're unicasting.
00078 };
00079 
00080 #endif
00081 
Generated on Sat Jan 28 04:22:54 2012 for hoople2 project by  doxygen 1.6.3