-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathCMEFeedHandler.cpp
More file actions
81 lines (53 loc) · 1.7 KB
/
Copy pathCMEFeedHandler.cpp
File metadata and controls
81 lines (53 loc) · 1.7 KB
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
// vim:sw=4:nu:expandtab:tabstop=4:ai
#include <thread>
#include <chrono>
#include "MulticastGroup.h"
#include "PacketDecoder.h"
namespace MCR
{
extern utxx::concurrent_spsc_queue< boost::shared_ptr< packet >, 4096 > udp_queue;
}
int main( int argc, char* argv[] )
{
setvbuf(stdout, NULL, _IONBF, 0);
struct in_addr mcast;
struct in_addr local;
struct event_base *base;
local.s_addr = inet_addr("xxx.xxx.xxx.xxx"); // replace with IP assigned by CME for your NR connection.
base = event_base_new();
if (!base)
return 0;
mcast.s_addr = inet_addr("224.0.28.1");
if (MCR::mcast_channel_fd_new(base, mcast, local, htons(14310)) < 0)
return 0;
mcast.s_addr = inet_addr("224.0.28.85");
if (MCR::mcast_channel_fd_new(base, mcast, local, htons(6310)) < 0)
return 0;
mcast.s_addr = inet_addr("224.0.28.43");
if (MCR::mcast_channel_fd_new(base, mcast, local, htons(6310)) < 0)
return 0;
MP::PacketDecoder decoder;
std::cout << "sizeof packet: " << sizeof(MCR::packet) << "\n";
long long deltas = 0;
long numDeltas = 0;
std::thread t([&]() {
boost::shared_ptr< MCR::packet > p;
while(true)
{
while( !MCR::udp_queue.empty() )
{
MCR::udp_queue.pop( p );
deltas += MCR::now() - p->ts;
numDeltas++;
decoder.onData(p);
if( numDeltas % 100 == 0 )
{
std::cout << "Avg: " << (deltas/static_cast<double>(numDeltas)/1000.0) << " num: " << numDeltas << "\n";
}
}
}
});
event_base_dispatch(base);
t.join();
return 0;
}