aboutsummaryrefslogtreecommitdiffstats
path: root/libtransport/src/protocols
diff options
context:
space:
mode:
authorAngelo Mantellini <manangel@cisco.com>2021-04-30 12:26:57 +0200
committerAngelo Mantellini <angelo.mantellini@cisco.com>2021-04-30 14:54:00 +0200
commit07133ac060c2af721941f7b47c52c075df3168ba (patch)
treea3a618442fc9f1adb5f1cf2e3d442c70fd787d2b /libtransport/src/protocols
parent39e15ebb3805efb6c71a1dd16f18061cd86487cf (diff)
[HICN-703] Update windows-sdk and hicn code
Signed-off-by: Angelo Mantellini <@ngelo.mantellini@cisco.com> Change-Id: I05e4c92ce7de3640f0272afae127e1377862bd3e Signed-off-by: Angelo Mantellini <angelo.mantellini@cisco.com>
Diffstat (limited to 'libtransport/src/protocols')
-rw-r--r--libtransport/src/protocols/prod_protocol_rtc.cc18
-rw-r--r--libtransport/src/protocols/rtc/rtc.cc6
-rw-r--r--libtransport/src/protocols/rtc/rtc_consts.h2
-rw-r--r--libtransport/src/protocols/rtc/rtc_data_path.cc6
-rw-r--r--libtransport/src/protocols/rtc/rtc_ldr.cc22
-rw-r--r--libtransport/src/protocols/rtc/rtc_packet.h22
-rw-r--r--libtransport/src/protocols/rtc/rtc_rc_queue.cc6
-rw-r--r--libtransport/src/protocols/rtc/rtc_state.cc2
-rw-r--r--libtransport/src/protocols/rtc/rtc_state.h2
9 files changed, 45 insertions, 41 deletions
diff --git a/libtransport/src/protocols/prod_protocol_rtc.cc b/libtransport/src/protocols/prod_protocol_rtc.cc
index 8081923e3..049752876 100644
--- a/libtransport/src/protocols/prod_protocol_rtc.cc
+++ b/libtransport/src/protocols/prod_protocol_rtc.cc
@@ -90,8 +90,8 @@ void RTCProductionProtocol::updateStats() {
uint32_t prev_packets_production_rate = packets_production_rate_;
- bytes_production_rate_ = ceil((double)produced_bytes_ * per_second);
- packets_production_rate_ = ceil((double)produced_packets_ * per_second);
+ bytes_production_rate_ = (uint32_t)ceil((double)produced_bytes_ * per_second);
+ packets_production_rate_ = (uint32_t)ceil((double)produced_packets_ * per_second);
TRANSPORT_LOGD("Updating production rate: produced_bytes_ = %u bps = %u",
produced_bytes_, bytes_production_rate_);
@@ -99,7 +99,7 @@ void RTCProductionProtocol::updateStats() {
// update the production rate as soon as it increases by 10% with respect to
// the last round
max_packet_production_ =
- produced_packets_ + ceil((double)produced_packets_ * 0.1);
+ produced_packets_ + (uint32_t)ceil((double)produced_packets_ * 0.1);
if (max_packet_production_ < rtc::WIN_MIN)
max_packet_production_ = rtc::WIN_MIN;
@@ -189,8 +189,8 @@ void RTCProductionProtocol::produceInternal(
content_object->setPathLabel(prod_label_);
// update stats
- produced_bytes_ +=
- content_object->headerSize() + content_object->payloadSize();
+ produced_bytes_ += (uint32_t)(
+ content_object->headerSize() + content_object->payloadSize());
produced_packets_++;
if (produced_packets_ >= max_packet_production_) {
@@ -318,14 +318,14 @@ void RTCProductionProtocol::onInterest(Interest &interest) {
if (!consumer_in_sync_ && on_consumer_in_sync_) {
// we consider the remote consumer to be in sync as soon as it covers 70%
// of the production window with interests
- uint32_t perc = ceil((double)max_gap * 0.7);
+ uint32_t perc = (uint32_t)ceil((double)max_gap * 0.7);
if (interest_seg > (perc + current_seg_)) {
consumer_in_sync_ = true;
on_consumer_in_sync_(*socket_->getInterface(), interest);
}
}
- uint64_t expiration =
- now + floor((double)lifetime * rtc::INTEREST_LIFETIME_REDUCTION_FACTOR);
+ uint64_t expiration =(uint32_t)(
+ now + floor((double)lifetime * rtc::INTEREST_LIFETIME_REDUCTION_FACTOR));
addToInterestQueue(interest_seg, expiration);
}
}
@@ -377,7 +377,7 @@ void RTCProductionProtocol::sendNacksForPendingInterests() {
uint32_t packet_gap = 100000; // set it to a high value (100sec)
if (packets_production_rate_ != 0)
- packet_gap = ceil(rtc::MILLI_IN_A_SEC / (double)packets_production_rate_);
+ packet_gap = (uint32_t)ceil(rtc::MILLI_IN_A_SEC / (double)packets_production_rate_);
uint64_t now = std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::steady_clock::now().time_since_epoch())
diff --git a/libtransport/src/protocols/rtc/rtc.cc b/libtransport/src/protocols/rtc/rtc.cc
index bb95ab686..46659ac74 100644
--- a/libtransport/src/protocols/rtc/rtc.cc
+++ b/libtransport/src/protocols/rtc/rtc.cc
@@ -220,11 +220,11 @@ void RTCTransportProtocol::updateSyncWindow() {
// if some of the info are not available do not update the current win
if (prod_rate != 0.0 && rtt != 0.0 && packet_size != 0.0) {
current_sync_win_ = (uint32_t)ceil(prod_rate * rtt / packet_size);
- current_sync_win_ +=
+ current_sync_win_ += (uint32_t)
ceil(prod_rate * (PRODUCER_BUFFER_MS / MILLI_IN_A_SEC) / packet_size);
if(current_state_ == SyncState::catch_up) {
- current_sync_win_ = current_sync_win_ * CATCH_UP_WIN_INCREMENT;
+ current_sync_win_ = (uint32_t) (current_sync_win_ * CATCH_UP_WIN_INCREMENT);
}
current_sync_win_ = std::min(current_sync_win_, max_sync_win_);
@@ -515,7 +515,7 @@ void RTCTransportProtocol::onContentObject(Interest &interest,
ContentObject &content_object) {
TRANSPORT_LOGD("Received content object of size: %zu",
content_object.payloadSize());
- uint32_t payload_size = content_object.payloadSize();
+ uint32_t payload_size = (uint32_t) content_object.payloadSize();
uint32_t segment_number = content_object.getName().getSuffix();
if (segment_number >= MIN_PROBE_SEQ) {
diff --git a/libtransport/src/protocols/rtc/rtc_consts.h b/libtransport/src/protocols/rtc/rtc_consts.h
index 0cf9516ab..e172fc7a1 100644
--- a/libtransport/src/protocols/rtc/rtc_consts.h
+++ b/libtransport/src/protocols/rtc/rtc_consts.h
@@ -97,7 +97,7 @@ const double MAX_CACHED_PACKETS = 262144; // 2^18
// about 50 sec of traffic at 50Mbps
// with 1200 bytes packets
-const uint32_t MAX_ROUND_WHIOUT_PACKETS =
+const uint32_t MAX_ROUND_WHIOUT_PACKETS = (const uint32_t)
(20 * MILLI_IN_A_SEC) / ROUND_LEN; // 20 sec in rounds;
// used in ldr
diff --git a/libtransport/src/protocols/rtc/rtc_data_path.cc b/libtransport/src/protocols/rtc/rtc_data_path.cc
index c098088a3..a545225cb 100644
--- a/libtransport/src/protocols/rtc/rtc_data_path.cc
+++ b/libtransport/src/protocols/rtc/rtc_data_path.cc
@@ -69,7 +69,7 @@ void RTCDataPath::insertOwdSample(int64_t owd) {
if (avg_owd != DBL_MAX)
avg_owd = (avg_owd * (1 - ALPHA_RTC)) + (owd * ALPHA_RTC);
else {
- avg_owd = owd;
+ avg_owd = (double)owd;
}
int64_t queueVal = owd - std::min(getMinOwd(), min_owd);
@@ -77,7 +77,7 @@ void RTCDataPath::insertOwdSample(int64_t owd) {
if (queuing_delay != DBL_MAX)
queuing_delay = (queuing_delay * (1 - ALPHA_RTC)) + (queueVal * ALPHA_RTC);
else {
- queuing_delay = queueVal;
+ queuing_delay = (double)queueVal;
}
// keep track of the jitter computed as for RTP (RFC 3550)
@@ -100,7 +100,7 @@ void RTCDataPath::computeInterArrivalGap(uint32_t segment_number) {
largest_recv_seq_ = segment_number;
largest_recv_seq_time_ = now;
if (avg_inter_arrival_ == DBL_MAX)
- avg_inter_arrival_ = delta;
+ avg_inter_arrival_ = (double)delta;
else
avg_inter_arrival_ =
(avg_inter_arrival_ * (1 - ALPHA_RTC)) + (delta * ALPHA_RTC);
diff --git a/libtransport/src/protocols/rtc/rtc_ldr.cc b/libtransport/src/protocols/rtc/rtc_ldr.cc
index e91b29c04..0ef381fe1 100644
--- a/libtransport/src/protocols/rtc/rtc_ldr.cc
+++ b/libtransport/src/protocols/rtc/rtc_ldr.cc
@@ -40,7 +40,7 @@ RTCLossDetectionAndRecovery::~RTCLossDetectionAndRecovery() {}
void RTCLossDetectionAndRecovery::turnOnRTX() {
rtx_on_ = true;
- scheduleSentinelTimer(state_->getRTT() * CATCH_UP_RTT_INCREMENT);
+ scheduleSentinelTimer((uint32_t)(state_->getRTT() * CATCH_UP_RTT_INCREMENT));
}
void RTCLossDetectionAndRecovery::turnOffRTX() {
@@ -182,8 +182,8 @@ uint64_t RTCLossDetectionAndRecovery::computeNextSend(uint32_t seq,
if (prod_rate != 0) {
double packet_size = state_->getAveragePacketSize();
- estimated_iat = ceil(1000.0 / (prod_rate / packet_size));
- jitter = ceil(state_->getJitter());
+ estimated_iat = (uint32_t)ceil(1000.0 / (prod_rate / packet_size));
+ jitter = (uint32_t)ceil(state_->getJitter());
}
uint32_t wait = estimated_iat + jitter;
@@ -202,20 +202,20 @@ uint64_t RTCLossDetectionAndRecovery::computeNextSend(uint32_t seq,
}
double packet_size = state_->getAveragePacketSize();
- uint32_t estimated_iat = ceil(1000.0 / (prod_rate / packet_size));
+ uint32_t estimated_iat = (uint32_t)ceil(1000.0 / (prod_rate / packet_size));
uint64_t rtt = state_->getRTT();
if (rtt == 0) rtt = SENTINEL_TIMER_INTERVAL;
- wait = rtt;
+ wait = (uint32_t)rtt;
if (estimated_iat > rtt) wait = estimated_iat;
- uint32_t jitter = ceil(state_->getJitter());
+ uint32_t jitter = (uint32_t)ceil(state_->getJitter());
wait += jitter;
// it may happen that the channel is congested and we have some additional
// queuing delay to take into account
- uint32_t queue = ceil(state_->getQueuing());
+ uint32_t queue = (uint32_t)ceil(state_->getQueuing());
wait += queue;
TRANSPORT_LOGD(
@@ -389,8 +389,8 @@ void RTCLossDetectionAndRecovery::sentinelTimer() {
} else {
double prod_rate = state_->getProducerRate();
double packet_size = state_->getAveragePacketSize();
- uint32_t estimated_iat = ceil(1000.0 / (prod_rate / packet_size));
- uint32_t jitter = ceil(state_->getJitter());
+ uint32_t estimated_iat = (uint32_t)ceil(1000.0 / (prod_rate / packet_size));
+ uint32_t jitter = (uint32_t)ceil(state_->getJitter());
// try to reduce the number of timers if the estimated IAT is too small
next_timer = std::max((estimated_iat + jitter) * 20, (uint32_t)1);
@@ -400,7 +400,7 @@ void RTCLossDetectionAndRecovery::sentinelTimer() {
if (!expired) {
// discount the amout of time that is already passed
- uint32_t discount = now - last_event_;
+ uint32_t discount = (uint32_t)(now - last_event_);
if (next_timer > discount) {
next_timer = next_timer - discount;
} else {
@@ -411,7 +411,7 @@ void RTCLossDetectionAndRecovery::sentinelTimer() {
} else if (sent) {
// wait at least one producer stats interval + owd to check if the
// production rate is reducing.
- uint32_t min_wait = PRODUCER_STATS_INTERVAL + ceil(state_->getQueuing());
+ uint32_t min_wait = PRODUCER_STATS_INTERVAL + (uint32_t)ceil(state_->getQueuing());
next_timer = std::max(next_timer, min_wait);
TRANSPORT_LOGD("wait for updates from prod, next timer: %u", next_timer);
}
diff --git a/libtransport/src/protocols/rtc/rtc_packet.h b/libtransport/src/protocols/rtc/rtc_packet.h
index abb1323a3..2f2b19fb9 100644
--- a/libtransport/src/protocols/rtc/rtc_packet.h
+++ b/libtransport/src/protocols/rtc/rtc_packet.h
@@ -25,7 +25,11 @@
*/
#pragma once
+#ifndef _WIN32
#include <arpa/inet.h>
+#else
+#include <hicn/transport/portability/win_portability.h>
+#endif
namespace transport {
@@ -37,14 +41,14 @@ inline uint64_t _ntohll(const uint64_t *input) {
uint64_t return_val;
uint8_t *tmp = (uint8_t *)&return_val;
- tmp[0] = *input >> 56;
- tmp[1] = *input >> 48;
- tmp[2] = *input >> 40;
- tmp[3] = *input >> 32;
- tmp[4] = *input >> 24;
- tmp[5] = *input >> 16;
- tmp[6] = *input >> 8;
- tmp[7] = *input >> 0;
+ tmp[0] = (uint8_t)(*input >> 56);
+ tmp[1] = (uint8_t)(*input >> 48);
+ tmp[2] = (uint8_t)(*input >> 40);
+ tmp[3] = (uint8_t)(*input >> 32);
+ tmp[4] = (uint8_t)(*input >> 24);
+ tmp[5] = (uint8_t)(*input >> 16);
+ tmp[6] = (uint8_t)(*input >> 8);
+ tmp[7] = (uint8_t)(*input >> 0);
return return_val;
}
@@ -86,4 +90,4 @@ struct nack_packet_t {
} // end namespace protocol
-} // end namespace transport
+} // end namespace transport \ No newline at end of file
diff --git a/libtransport/src/protocols/rtc/rtc_rc_queue.cc b/libtransport/src/protocols/rtc/rtc_rc_queue.cc
index a1c89e329..3c7318dae 100644
--- a/libtransport/src/protocols/rtc/rtc_rc_queue.cc
+++ b/libtransport/src/protocols/rtc/rtc_rc_queue.cc
@@ -67,11 +67,11 @@ void RTCRateControlQueue::onNewRound(double round_len) {
if (prev_congestion_state == CongestionState::Normal) {
// init the congetion window using the received rate
congestion_win_ = (uint32_t)ceil(received_rate * rtt / packet_size);
- rounds_since_last_drop_ = ROUNDS_BEFORE_TAKE_ACTION + 1;
+ rounds_since_last_drop_ = (uint32_t)ROUNDS_BEFORE_TAKE_ACTION + 1;
}
if (rounds_since_last_drop_ >= ROUNDS_BEFORE_TAKE_ACTION) {
- uint32_t win = congestion_win_ * WIN_DECREASE_FACTOR;
+ uint32_t win = congestion_win_ * (uint32_t)WIN_DECREASE_FACTOR;
congestion_win_ = std::max(win, WIN_MIN);
rounds_since_last_drop_ = 0;
return;
@@ -88,7 +88,7 @@ void RTCRateControlQueue::onNewRound(double round_len) {
rounds_without_congestion_++;
if (rounds_without_congestion_ < ROUNDS_BEFORE_TAKE_ACTION) return;
- congestion_win_ = congestion_win_ * WIN_INCREASE_FACTOR;
+ congestion_win_ = congestion_win_ * (uint32_t)WIN_INCREASE_FACTOR;
congestion_win_ = std::min(congestion_win_, INITIAL_WIN_MAX);
}
}
diff --git a/libtransport/src/protocols/rtc/rtc_state.cc b/libtransport/src/protocols/rtc/rtc_state.cc
index eabf8942c..9c965bfed 100644
--- a/libtransport/src/protocols/rtc/rtc_state.cc
+++ b/libtransport/src/protocols/rtc/rtc_state.cc
@@ -547,7 +547,7 @@ void RTCState::checkInitRttTimer() {
double prod_rate = getProducerRate();
double rtt = (double)getRTT() / MILLI_IN_A_SEC;
double packet_size = getAveragePacketSize();
- uint32_t pkt_in_rtt_ = std::floor(((prod_rate / packet_size) * rtt) * 0.8);
+ uint32_t pkt_in_rtt_ = (uint32_t)std::floor(((prod_rate / packet_size) * rtt) * 0.8);
last_seq_nacked_ = last_production_seq_ + pkt_in_rtt_;
discovered_rtt_callback_();
diff --git a/libtransport/src/protocols/rtc/rtc_state.h b/libtransport/src/protocols/rtc/rtc_state.h
index 943a0a113..e4fefaffe 100644
--- a/libtransport/src/protocols/rtc/rtc_state.h
+++ b/libtransport/src/protocols/rtc/rtc_state.h
@@ -102,7 +102,7 @@ class RTCState : std::enable_shared_from_this<RTCState> {
return false;
}
uint32_t getPendingInterestNumber() const {
- return pending_interests_.size();
+ return (uint32_t)pending_interests_.size();
}
PacketState isReceivedOrLost(uint32_t seq) {
auto it = received_or_lost_packets_.find(seq);