22 #ifndef STREAM_TEST_ENTITY_H 23 #define STREAM_TEST_ENTITY_H 33 StreamTestEntity(
HdlcdClient& a_HdlcdClient, uint16_t a_SrcSSA, uint16_t a_DstSSA): m_SrcSSA(a_SrcSSA), m_DstSSA(a_DstSSA), m_HdlcdClient(a_HdlcdClient), m_LocalSeqNbr(0), m_RemoteStatistic(
"remote "), m_LocalStatistic(
"local ") {
38 m_TotalBytesWritten = 0;
40 PacketReceived(a_PacketData);
46 SendNextProbeRequest();
56 if (l_AppMessage.
GetToken() == 0x01) {
57 HandleProbeReply(a_PacketData);
58 }
else if (l_AppMessage.
GetToken() == 0x02) {
59 HandlePeerStatistics(a_PacketData);
78 std::cout << std::endl;
80 std::cout <<
" (!!!)" << std::endl;
85 void UpdateStatistics(uint32_t a_RemoteSeed, uint32_t a_LocalSeed, uint32_t a_RemoteSeqNbr, uint32_t a_LocalSeqNbr) {
87 if (m_LocalSeed != a_LocalSeed) {
91 if (m_RemoteSeed != a_RemoteSeed) {
92 m_RemoteSeed = a_RemoteSeed;
93 m_RemoteStatistic.
Reset();
94 m_LocalStatistic.
Reset();
97 m_RemoteStatistic.
Update(a_RemoteSeqNbr);
98 m_LocalStatistic.
Update(a_LocalSeqNbr);
101 void SendNextProbeRequest() {
110 m_TotalBytesWritten += l_ProbeRequest.
GetSize();
111 if (((++m_LocalSeqNbr) % 0xFF) == 0) {
112 std::cout <<
"256 Packets written to the TCP socket (" << std::dec << m_TotalBytesWritten <<
" bytes total)" << std::endl;
120 uint32_t m_RemoteSeed;
121 uint32_t m_LocalSeed;
123 uint32_t m_LocalSeqNbr;
126 unsigned long m_TotalBytesWritten;
129 #endif // STREAM_TEST_ENTITY_H
void SetLocalSeed(uint32_t a_LocalSeed=0)
uint32_t GetRemoteSeed() const
bool Send(const HdlcdPacketData &a_PacketData, std::function< void()> a_OnSendDoneCallback=nullptr)
Send a single data packet to the peer entity.
uint32_t GetRemoteSeqNbr() const
static HdlcdPacketData CreatePacket(const std::vector< unsigned char > a_Payload, bool a_bReliable, bool a_bInvalid=false, bool a_bWasSent=false)
uint8_t GetDstServiceId() const
A set of tools to exchange and handle packets of s-net(r) devices via the HDLC Daemon. Copyright (C) 2016 Florian Evers, florian-evers@gmx.de.
uint16_t GetToken() const
uint8_t GetSrcServiceId() const
void SetLocalSeqNbr(uint32_t a_LocalSeqNbr=0)
size_t Deserialize(const std::vector< unsigned char > &a_Buffer)
uint16_t GetSrcSSA() const
size_t Deserialize(const std::vector< unsigned char > &a_Buffer)
void SetOnDataCallback(std::function< void(const HdlcdPacketData &a_PacketData)> a_OnDataCallback)
Provide a callback method to be called for received data packets.
A set of tools to exchange and handle packets of s-net(r) devices via the HDLC Daemon. Copyright (C) 2016 Florian Evers, florian-evers@gmx.de.
uint32_t GetLocalSeqNbr() const
const std::vector< unsigned char > & GetData() const
void Update(uint32_t a_SeqNbr)
size_t Deserialize(const std::vector< unsigned char > &a_Buffer)
uint32_t GetLocalSeed() const
Copyright (c) 2016, Florian Evers, florian-evers@gmx.de All rights reserved.
uint16_t GetAmountOfPackets() const
A set of tools to exchange and handle packets of s-net(r) devices via the HDLC Daemon. Copyright (C) 2016 Florian Evers, florian-evers@gmx.de.
A set of tools to exchange and handle packets of s-net(r) devices via the HDLC Daemon. Copyright (C) 2016 Florian Evers, florian-evers@gmx.de.
std::vector< unsigned char > Serialize() const
StreamTestEntity(HdlcdClient &a_HdlcdClient, uint16_t a_SrcSSA, uint16_t a_DstSSA)
uint32_t GetLocalGeneration() const