aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/transport/xport_benchmarker.hpp
blob: ffafbea5a155ad6112b6e5efb68795acb8a3a5f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//
// Copyright 2010-2013 Ettus Research LLC
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
//

#ifndef INCLUDED_LIBUHD_XPORT_BENCHMARKER_HPP
#define INCLUDED_LIBUHD_XPORT_BENCHMARKER_HPP

#include <uhd/transport/zero_copy.hpp>
#include <uhd/types/device_addr.hpp>
#include <uhd/utils/log.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/thread/thread.hpp>
#include <uhd/transport/vrt_if_packet.hpp>

namespace uhd { namespace transport {

//Test class to benchmark a low-level transport object with a VITA/C-VITA data stream
class xport_benchmarker : boost::noncopyable {
public:
    const device_addr_t& benchmark_throughput_chdr(
        zero_copy_if::sptr tx_transport,
        zero_copy_if::sptr rx_transport,
        uint32_t sid,
        bool big_endian,
        uint32_t duration_ms);

private:
    void _stream_tx(
        zero_copy_if* transport,
        vrt::if_packet_info_t* pkt_info,
        bool big_endian);

    void _stream_rx(
        zero_copy_if* transport,
        const vrt::if_packet_info_t* exp_pkt_info,
        bool big_endian);

    void _initialize_chdr(
        zero_copy_if::sptr tx_transport,
        zero_copy_if::sptr rx_transport,
        uint32_t sid,
        vrt::if_packet_info_t& pkt_info);

    void _reset_counters(void);

    boost::shared_ptr<boost::thread>    _tx_thread;
    boost::shared_ptr<boost::thread>    _rx_thread;

    uint64_t     _num_tx_packets;
    uint64_t     _num_rx_packets;
    uint64_t     _num_tx_timeouts;
    uint64_t     _num_rx_timeouts;
    uint64_t     _num_data_errors;

    double              _tx_timeout;
    double              _rx_timeout;

    device_addr_t       _results;
};


}} //namespace

#endif /* INCLUDED_LIBUHD_XPORT_BENCHMARKER_HPP */