feisty meow concerns codebase  2.140
bcast_spocketer.h
Go to the documentation of this file.
1 #ifndef TEST_CROMP_CLASS
2 #define TEST_CROMP_CLASS
3 
4 /*****************************************************************************\
5 * *
6 * Name : broadcast_spocket_tester *
7 * Author : Chris Koeritz *
8 * *
9 * Purpose: *
10 * *
11 * Puts the spocket class in broadcast mode through some test paces. *
12 * *
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 \*****************************************************************************/
21 
23 #include <sockets/spocket.h>
24 #include <sockets/tcpip_stack.h>
25 
26 // this structure is filled by the tester during a send data call.
28 {
29 public:
30  int total_runs; // how many cycles did we successfully do?
31  int bytes_sent; // overall count of bytes sent.
32  int bytes_received; // overall count of bytes received.
33  int send_time; // time taken just to invoke "send" function.
34  int receive_time; // time taken just to invoke "recv" function.
35  int round_trip_time; // time taken between sending and receiving back.
36 
40 };
41 
42 // our main tester class.
44 {
45 public:
47  bool unicast = false);
48  // constructs the tester object. "where" provides information about either
49  // this side (for a server) or the other side (for a client).
50  // if "unicast" is true, then we test unicasts instead of broadcasts.
51 
53  // destroys the tester object.
54 
55  DEFINE_CLASS_NAME("broadcast_spocket_tester");
56 
57  bool connect();
58  // gets ready for sending and reception.
59 
60  bool do_a_send(const sockets::internet_address &where_to, basis::abyte *buffer, int size,
61  testing_statistics &stats);
62 
63  bool do_a_receive(int size_expected, testing_statistics &stats);
64 
65  bool perform_test(const sockets::internet_address &dest, int size, int count,
66  testing_statistics &stats_to_fill);
67  // sends "count" random data chunks of the "size" specified. the measured
68  // performance during this sending is reported in "stats_to_fill".
69 
70 private:
71  sockets::internet_address *_where; // our communications endpoint.
72  sockets::tcpip_stack *_stack; // provides access to the operating system layers.
73  sockets::spocket *_socket; // does the communication for us.
74  sockets::spocket *_root_server; // used for server side testing.
75  sockets::raw_socket *_raw; // provides functions on sockets.
76  bool _ucast; // true if we're unicasting.
77 };
78 
79 #endif
80 
bool do_a_send(const sockets::internet_address &where_to, basis::abyte *buffer, int size, testing_statistics &stats)
bool perform_test(const sockets::internet_address &dest, int size, int count, testing_statistics &stats_to_fill)
broadcast_spocket_tester(const sockets::internet_address &where, bool unicast=false)
bool do_a_receive(int size_expected, testing_statistics &stats)
DEFINE_CLASS_NAME("broadcast_spocket_tester")
this type of address describes a destination out on the internet.
Abstraction for a higher-level BSD socket that is platform independent.
Definition: spocket.h:40
Helpful functions for interacting with TCP/IP stacks.
Definition: tcpip_stack.h:38
unsigned char abyte
A fairly important unit which is seldom defined...
Definition: definitions.h:51