summaryrefslogtreecommitdiffstats
path: root/libtransport/src/protocols
diff options
context:
space:
mode:
Diffstat (limited to 'libtransport/src/protocols')
-rw-r--r--libtransport/src/protocols/protocol.cc11
-rw-r--r--libtransport/src/protocols/rtc.cc26
-rw-r--r--libtransport/src/protocols/rtc.h3
3 files changed, 17 insertions, 23 deletions
diff --git a/libtransport/src/protocols/protocol.cc b/libtransport/src/protocols/protocol.cc
index d1bd566a0..451fef80d 100644
--- a/libtransport/src/protocols/protocol.cc
+++ b/libtransport/src/protocols/protocol.cc
@@ -48,12 +48,6 @@ int TransportProtocol::start() {
// If the protocol is already running, return otherwise set as running
if (is_running_) return -1;
- // Reset the protocol state machine
- reset();
-
- // Set it is the first time we schedule an interest
- is_first_ = true;
-
// Get all callbacks references before starting
socket_->getSocketOption(ConsumerCallbacksOptions::INTEREST_RETRANSMISSION,
&on_interest_retransmission_);
@@ -75,6 +69,11 @@ int TransportProtocol::start() {
&on_payload_);
socket_->getSocketOption(GeneralTransportOptions::ASYNC_MODE, is_async_);
+ // Set it is the first time we schedule an interest
+ is_first_ = true;
+
+ // Reset the protocol state machine
+ reset();
// Schedule next interests
scheduleNextInterests();
diff --git a/libtransport/src/protocols/rtc.cc b/libtransport/src/protocols/rtc.cc
index 3b10c7467..b1502f51f 100644
--- a/libtransport/src/protocols/rtc.cc
+++ b/libtransport/src/protocols/rtc.cc
@@ -38,24 +38,11 @@ RTCTransportProtocol::RTCTransportProtocol(
sentinel_timer_ =
std::make_unique<asio::steady_timer>(portal_->getIoService());
round_timer_ = std::make_unique<asio::steady_timer>(portal_->getIoService());
- reset();
+ initParams();
}
RTCTransportProtocol::~RTCTransportProtocol() {}
-int RTCTransportProtocol::start() {
- if (is_running_) return -1;
-
- reset();
- is_first_ = true;
-
- probeRtt();
- sentinelTimer();
- newRound();
-
- return TransportProtocol::start();
-}
-
void RTCTransportProtocol::resume() {
if (is_running_) return;
@@ -72,7 +59,7 @@ void RTCTransportProtocol::resume() {
}
// private
-void RTCTransportProtocol::reset() {
+void RTCTransportProtocol::initParams() {
portal_->setConsumerCallback(this);
// controller var
currentState_ = HICN_RTC_SYNC_STATE;
@@ -125,7 +112,14 @@ void RTCTransportProtocol::reset() {
socket_->setSocketOption(GeneralTransportOptions::INTEREST_LIFETIME,
(uint32_t)HICN_RTC_INTEREST_LIFETIME);
- // XXX this should be done by the application
+}
+
+// private
+void RTCTransportProtocol::reset() {
+ initParams();
+ probeRtt();
+ sentinelTimer();
+ newRound();
}
uint32_t max(uint32_t a, uint32_t b) {
diff --git a/libtransport/src/protocols/rtc.h b/libtransport/src/protocols/rtc.h
index a12c96b69..9f1bcc25b 100644
--- a/libtransport/src/protocols/rtc.h
+++ b/libtransport/src/protocols/rtc.h
@@ -93,7 +93,7 @@ class RTCTransportProtocol : public TransportProtocol,
~RTCTransportProtocol();
- int start() override;
+ using TransportProtocol::start;
using TransportProtocol::stop;
@@ -103,6 +103,7 @@ class RTCTransportProtocol : public TransportProtocol,
private:
// algo functions
+ void initParams();
void reset() override;
// CC functions