3#include "imr/mold/downstream/heartbeat.h"
4#include "imr/mold/packet_builder.h"
5#include "imr/mold/retransmission_buffer.h"
6#include "imr/mold/downstream/pacer.h"
8#include "imr/mold/types.h"
9#include "imr/util/file_descriptor.h"
10#include "imr/util/zstring_view.h"
12#include <netinet/in.h>
14#include <sys/socket.h>
19
20
21
22
23
39
40
41
42
45
46
47
56
57
58
59
60
63 std::span<
const char> file,
67
68
69
74 sockaddr_in mcast_group_;
77 std::span<
const char> file_;
78 std::size_t file_pos_{0};
80 std::atomic<
types::
header::SequenceNumber> sent_sequence_number_{1};
84 Pacer<std::chrono::steady_clock> pacer_;
88 std::chrono::nanoseconds end_of_session_duration_;
91 sockaddr_in configure_socket(
const Config& cfg)
const;
94 void send_packet()
noexcept;
96 void end_of_session(std::stop_token st);
Builds MoldUDP64 packets.
Definition packet_builder.h:24
Retransmission buffer of the last buffer_size messages.
Definition retransmission_buffer.h:15
Replays a MoldUDP64 downstream feed over multicast.
Definition feed.h:25
Feed(const Config &cfg, const PacketBuilder::Config &packet_builder_cfg, std::span< const char > file, RetransmissionBuffer &retransmission_buffer)
Constructs the feed ready to begin downstream on configured multicast group/port.
void start(std::stop_token st)
Replays the file until EOF or st stopped, then send end of session packets for configured duration.
Sends MoldUDP64 heartbeat packets at a configured interval.
Definition heartbeat.h:15
Calculates relative delay for a given message timestamp for downstream (which passes the first messag...
Definition pacer.h:47
RAII file descriptor wrapper.
Definition file_descriptor.h:19
A wrapper around std::string_view that guarantees null terminated strings for passing to C APIs.
Definition zstring_view.h:10
Definition file_descriptor.h:11
Definition packet_builder.h:30
std::uint8_t ttl
Sets IP_MULTICAST_TTL.
Definition feed.h:35
std::chrono::nanoseconds end_of_session_duration
How long end of session should send packets.
Definition feed.h:50
bool loopback
Enable/Disable IP_MULTICAST_LOOP.
Definition feed.h:37
std::chrono::nanoseconds heartbeat_period
Interval between heartbeat packets while the feed is running.
Definition feed.h:48
in_addr egress_interface
Interface to send multicast packets from (IP_MULTICAST_IF).
Definition feed.h:43
Pacer< std::chrono::steady_clock >::Config pacer_cfg
Controls playback speed and pre-market message skipping.
Definition feed.h:52
std::uint16_t port
Multicast port.
Definition feed.h:33
util::zstring_view mcast_group
Multicast group to send to.
Definition feed.h:31