Skip to content

Keep incrementing sequence number when link prober is suspended and shutdown #55

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/link_prober/LinkProber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,10 @@ void LinkProber::sendHeartbeat()
{
MUXLOGTRACE(mMuxPortConfig.getPortName());

updateIcmpSequenceNo();

// check if suspend timer is running
if ((!mSuspendTx) && (!mShutdownTx)) {
updateIcmpSequenceNo();
boost::system::error_code errorCode;
mStream.write_some(boost::asio::buffer(mTxBuffer.data(), mTxPacketSize), errorCode);

Expand Down
11 changes: 11 additions & 0 deletions test/LinkProberTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,17 @@ TEST_F(LinkProberTest, UpdateSequenceNo)

EXPECT_TRUE(getRxSelfSeqNo() + 1 == ntohs(icmpHeader->un.echo.sequence));
EXPECT_TRUE(getRxPeerSeqNo() + 1 == ntohs(icmpHeader->un.echo.sequence));

// sequence number should still be updated when heartbeat is suspended
EXPECT_EQ(getRxSelfSeqNo(), 0);
EXPECT_EQ(getRxPeerSeqNo(), 0);

handleSuspendTxProbes();
EXPECT_TRUE(getSuspendTx());

handleSendHeartbeat();
EXPECT_EQ(getRxSelfSeqNo(), 1);
EXPECT_EQ(getRxPeerSeqNo(), 1);
}

TEST_F(LinkProberTest, GenerateGuid)
Expand Down
3 changes: 3 additions & 0 deletions test/LinkProberTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ class LinkProberTest: public ::testing::Test
void initializeSendBuffer() {mLinkProber.initializeSendBuffer();};
void handleUpdateEthernetFrame() {mLinkProber.handleUpdateEthernetFrame();};
void handleUpdateSequenceNumber() {mLinkProber.updateIcmpSequenceNo();};
void handleSuspendTxProbes() {mLinkProber.suspendTxProbes(300);};
void handleSendHeartbeat() {mLinkProber.sendHeartbeat();};
void resetTxBufferTlv() {mLinkProber.resetTxBufferTlv();};
size_t getTxPacketSize() {return mLinkProber.mTxPacketSize;};
size_t appendTlvCommand(link_prober::Command commandType);
Expand All @@ -54,6 +56,7 @@ class LinkProberTest: public ::testing::Test

uint16_t getRxSelfSeqNo() {return mLinkProber.mRxSelfSeqNo;};
uint16_t getRxPeerSeqNo() {return mLinkProber.mRxPeerSeqNo;};
bool getSuspendTx() {return mLinkProber.mSuspendTx;};

boost::asio::io_service mIoService;
common::MuxConfig mMuxConfig;
Expand Down