24 #ifndef CPROTOCOLSR_HPP 25 #define CPROTOCOLSR_HPP 29 #include "messages/ProtocolMessage.pb.h" 33 #include <boost/asio/deadline_timer.hpp> 34 #include <boost/date_time/posix_time/posix_time.hpp> 45 explicit CProtocolSR(std::string uuid, boost::asio::ip::udp::endpoint endpoint);
47 void Send(
const ModuleMessage& msg);
51 bool Receive(
const ProtocolMessage& msg);
55 void SendACK(
const ProtocolMessage& msg);
61 void Write(ProtocolMessageWindow & msg);
66 void Resend(
const boost::system::error_code& err);
std::deque< ProtocolMessage > m_ack_window
Definition: CProtocolSR.hpp:89
boost::asio::deadline_timer m_timeout
Timeout for resends.
Definition: CProtocolSR.hpp:68
google::protobuf::uint64 m_outsynchash
Keeps track of the last resync that we've seen.
Definition: CProtocolSR.hpp:82
unsigned int m_inresyncs
Counts the number of times this one has been resynced.
Definition: CProtocolSR.hpp:76
CProtocolSR(std::string uuid, boost::asio::ip::udp::endpoint endpoint)
Initializes the protocol with the underlying connection.
Definition: CProtocolSR.cpp:60
A connection protocol.
Definition: IProtocol.hpp:43
unsigned int m_inseq
The expected next in sequence number.
Definition: CProtocolSR.hpp:70
bool m_insync
Marks if this has been synced.
Definition: CProtocolSR.hpp:74
bool m_sendkills
Marks if we should send the kill hash.
Definition: CProtocolSR.hpp:84
static const unsigned int SEQUENCE_MODULO
Sequence modulo.
Definition: CProtocolSR.hpp:91
void ReceiveACK(const ProtocolMessage &msg)
Public facing function that handles marking down ACKs for sent messages.
Definition: CProtocolSR.cpp:221
A reliable connection protocol with sweet as expirations.
Definition: CProtocolSR.hpp:40
unsigned int m_sendkill
The hash to... MURDER.
Definition: CProtocolSR.hpp:86
void WriteWindow()
Writes a whole window to the channel.
Definition: CProtocolSR.cpp:469
void SendSYN()
Sends a synchronizer.
Definition: CProtocolSR.cpp:413
unsigned int m_dropped
The number that have been dropped.
Definition: CProtocolSR.hpp:97
static const unsigned int MAX_DROPPED_MSGS
The number of messages that have to be dropped before the connection is dead.
Definition: CProtocolSR.hpp:95
bool m_outsync
Marks if we've sent the outsync for this connection.
Definition: CProtocolSR.hpp:80
bool m_timer_active
Indicates if the timer is active.
Definition: CProtocolSR.hpp:99
std::deque< ProtocolMessage > m_window
The window.
Definition: CProtocolSR.hpp:88
void Send(const ModuleMessage &msg)
Public facing send function that sends a message.
Definition: CProtocolSR.cpp:95
boost::posix_time::ptime m_insynctime
Time the last accepted sync was.
Definition: CProtocolSR.hpp:78
static const unsigned int REFIRE_TIME
Refire time in MS.
Definition: CProtocolSR.hpp:93
void Write(ProtocolMessageWindow &msg)
Handles writing the message to the underlying connection.
Definition: CProtocolSR.cpp:494
General FREEDM Namespace.
Definition: CBroker.cpp:53
void SetStopped(bool v)
Handles setting the stopped variable.
Definition: IProtocol.hpp:67
bool Receive(const ProtocolMessage &msg)
deterimines if a messageshould be given to the dispatcher
Definition: CProtocolSR.cpp:281
void Stop()
Stops the timers.
Definition: CProtocolSR.hpp:59
void OnReceive()
Writes the window (with acks on message receipt)
Definition: CProtocolSR.cpp:456
void Resend(const boost::system::error_code &err)
Resend outstanding messages.
Definition: CProtocolSR.cpp:141
void SendACK(const ProtocolMessage &msg)
Handles Writing an ack for the input message to the channel.
Definition: CProtocolSR.cpp:393
unsigned int m_outseq
The next number to assign to an outgoing message.
Definition: CProtocolSR.hpp:72