1 #ifndef TEST_CROMP_CLASS
2 #define TEST_CROMP_CLASS
4 /*****************************************************************************\
6 * Name : broadcast_spocket_tester *
7 * Author : Chris Koeritz *
11 * Puts the spocket class in broadcast mode through some test paces. *
13 *******************************************************************************
14 * Copyright (c) 2000-$now By Author. This program is free software; you can *
15 * redistribute it and/or modify it under the terms of the GNU General Public *
16 * License as published by the Free Software Foundation; either version 2 of *
17 * the License or (at your option) any later version. This is online at: *
18 * http://www.fsf.org/copyleft/gpl.html *
19 * Please send any updates to: fred@gruntose.com *
20 \*****************************************************************************/
22 ////#include <basis/definitions.h>
23 #include <sockets/internet_address.h>
24 #include <sockets/spocket.h>
25 #include <sockets/tcpip_stack.h>
27 // this structure is filled by the tester during a send data call.
28 class testing_statistics
31 int total_runs; // how many cycles did we successfully do?
32 int bytes_sent; // overall count of bytes sent.
33 int bytes_received; // overall count of bytes received.
34 int send_time; // time taken just to invoke "send" function.
35 int receive_time; // time taken just to invoke "recv" function.
36 int round_trip_time; // time taken between sending and receiving back.
39 : total_runs(0), bytes_sent(0), bytes_received(0), send_time(0),
40 receive_time(0), round_trip_time(0) {}
43 // our main tester class.
44 class broadcast_spocket_tester
47 broadcast_spocket_tester(const sockets::internet_address &where,
48 bool unicast = false);
49 // constructs the tester object. "where" provides information about either
50 // this side (for a server) or the other side (for a client).
51 // if "unicast" is true, then we test unicasts instead of broadcasts.
53 ~broadcast_spocket_tester();
54 // destroys the tester object.
56 DEFINE_CLASS_NAME("broadcast_spocket_tester");
59 // gets ready for sending and reception.
61 bool do_a_send(const sockets::internet_address &where_to, basis::abyte *buffer, int size,
62 testing_statistics &stats);
64 bool do_a_receive(int size_expected, testing_statistics &stats);
66 bool perform_test(const sockets::internet_address &dest, int size, int count,
67 testing_statistics &stats_to_fill);
68 // sends "count" random data chunks of the "size" specified. the measured
69 // performance during this sending is reported in "stats_to_fill".
72 sockets::internet_address *_where; // our communications endpoint.
73 sockets::tcpip_stack *_stack; // provides access to the operating system layers.
74 sockets::spocket *_socket; // does the communication for us.
75 sockets::spocket *_root_server; // used for server side testing.
76 sockets::raw_socket *_raw; // provides functions on sockets.
77 bool _ucast; // true if we're unicasting.