diff options
author | Angelo Mantellini <manangel@cisco.com> | 2021-04-30 12:26:57 +0200 |
---|---|---|
committer | Angelo Mantellini <angelo.mantellini@cisco.com> | 2021-04-30 14:54:00 +0200 |
commit | 07133ac060c2af721941f7b47c52c075df3168ba (patch) | |
tree | a3a618442fc9f1adb5f1cf2e3d442c70fd787d2b /libtransport | |
parent | 39e15ebb3805efb6c71a1dd16f18061cd86487cf (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')
27 files changed, 123 insertions, 80 deletions
diff --git a/libtransport/CMakeLists.txt b/libtransport/CMakeLists.txt index 3f828c4d6..9d2b9069f 100644 --- a/libtransport/CMakeLists.txt +++ b/libtransport/CMakeLists.txt @@ -50,7 +50,9 @@ if ((BUILD_HICNPLUGIN OR BUILD_MEMIF_CONNECTOR) AND "${CMAKE_SYSTEM_NAME}" STREQ endif () set(LIBTRANSPORT ${LIBTRANSPORT} CACHE INTERNAL "" FORCE) +if (NOT WIN32) set(LIBTRANSPORT_SHARED ${LIBTRANSPORT}.shared CACHE INTERNAL "" FORCE) +endif () set(LIBTRANSPORT_STATIC ${LIBTRANSPORT}.static CACHE INTERNAL "" FORCE) set(LIBTRANSPORT_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src CACHE INTERNAL "" FORCE) @@ -79,11 +81,17 @@ else() else() set(HICN_LIBRARIES ${LIBHICN_SHARED}) list(APPEND DEPENDENCIES + ${LIBHICN_SHARED} ) endif() endif() - +if (WIN32) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4275 /wd4996 /wd4311 /wd4302") + if (CMAKE_BUILD_TYPE EQUAL "RELEASE") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /NODEFAULTLIB:\"MSVCRTD\"" ) + endif () +endif () include(Packaging) list(APPEND LIBRARIES @@ -97,6 +105,7 @@ list(APPEND LIBRARIES ${LIBCONFIG_CPP_LIBRARIES} ) + # Include dirs -- Order does matter! list(APPEND LIBTRANSPORT_INTERNAL_INCLUDE_DIRS ${HICN_INCLUDE_DIRS} diff --git a/libtransport/src/CMakeLists.txt b/libtransport/src/CMakeLists.txt index 0fa9bbe3c..079427fea 100644 --- a/libtransport/src/CMakeLists.txt +++ b/libtransport/src/CMakeLists.txt @@ -59,9 +59,9 @@ set(LIBTRANSPORT_INCLUDE_DIRS if (NOT WIN32) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread") else () - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4200") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4200 -D_WIN32_WINDOWS=0x0400") if (CMAKE_BUILD_TYPE EQUAL "RELEASE") - set(CMAKE_SHARED_LINKER_FLAGS "/NODEFAULTLIB:\"MSVCRTD\"" ) + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /NODEFAULTLIB:\"MSVCRTD\"" ) endif () endif () diff --git a/libtransport/src/auth/signer.cc b/libtransport/src/auth/signer.cc index 281b9c59a..99c3d099d 100644 --- a/libtransport/src/auth/signer.cc +++ b/libtransport/src/auth/signer.cc @@ -88,7 +88,7 @@ void Signer::signPacket(PacketPtr packet) { // Compute signature PARCSignature *signature = parcSigner_SignDigestNoAlloc( - signer_, hash.hash_, packet->getSignature(), signature_len); + signer_, hash.hash_, packet->getSignature(), (uint32_t)signature_len); PARCBuffer *buffer = parcSignature_GetSignature(signature); size_t bytes_len = parcBuffer_Remaining(buffer); diff --git a/libtransport/src/core/fec.cc b/libtransport/src/core/fec.cc index 134198b9e..0ce9625a2 100644 --- a/libtransport/src/core/fec.cc +++ b/libtransport/src/core/fec.cc @@ -55,13 +55,15 @@ * https://gcc.gnu.org/bugzilla//show_bug.cgi?id=88059 */ #ifndef __clang__ +#ifndef _WIN32 #pragma GCC diagnostic ignored "-Wstringop-overflow" #endif +#endif /* * compatibility stuff */ -#ifdef MSDOS /* but also for others, e.g. sun... */ +#if defined (MSDOS) || defined (_WIN32) /* but also for others, e.g. sun... */ #define NEED_BCOPY #define bcmp(a,b,n) memcmp(a,b,n) #endif diff --git a/libtransport/src/core/global_configuration.cc b/libtransport/src/core/global_configuration.cc index e0b6c040a..3e37a30a4 100644 --- a/libtransport/src/core/global_configuration.cc +++ b/libtransport/src/core/global_configuration.cc @@ -32,7 +32,7 @@ bool GlobalConfiguration::parseTransportConfig(const std::string& path) { try { cfg.readFile(path.c_str()); } catch (const FileIOException& fioex) { - TRANSPORT_LOGE("I/O error while reading file."); + TRANSPORT_LOGE("I/O error while reading file: %s", fioex.what()); return false; } catch (const ParseException& pex) { TRANSPORT_LOGE("Parse error at %s:%d - %s", pex.getFile(), pex.getLine(), @@ -67,6 +67,7 @@ void GlobalConfiguration::parseConfiguration(const std::string& path) { // Check if an environment variable with the configuration path exists. COnf // variable comes first. std::unique_lock<std::mutex> lck(cp_mtx_); + if (const char* env_c = std::getenv(GlobalConfiguration::conf_file)) { parseTransportConfig(env_c); } else if (!path.empty()) { diff --git a/libtransport/src/core/interest.cc b/libtransport/src/core/interest.cc index 06cbe9f81..b4a74762d 100644 --- a/libtransport/src/core/interest.cc +++ b/libtransport/src/core/interest.cc @@ -175,7 +175,7 @@ void Interest::encodeSuffixes() { // We assume interest does not hold signature for the moment. auto int_manifest_header = (InterestManifestHeader *)(writableData() + headerSize()); - int_manifest_header->n_suffixes = suffix_set_.size(); + int_manifest_header->n_suffixes = (uint32_t)suffix_set_.size(); std::size_t additional_length = int_manifest_header->n_suffixes * sizeof(uint32_t); diff --git a/libtransport/src/core/io_module.cc b/libtransport/src/core/io_module.cc index fef0c1504..7c2ec2cab 100644 --- a/libtransport/src/core/io_module.cc +++ b/libtransport/src/core/io_module.cc @@ -13,12 +13,16 @@ * limitations under the License. */ +#ifndef _WIN32 #include <dlfcn.h> +#endif #include <hicn/transport/core/io_module.h> #include <hicn/transport/utils/log.h> #ifdef ANDROID #include <io_modules/udp/hicn_forwarder_module.h> +#elif _WIN32 +#include <hicn/util/windows/windows_utils.h> #endif #include <deque> diff --git a/libtransport/src/core/portal.cc b/libtransport/src/core/portal.cc index d1d26c5b7..33335e542 100644 --- a/libtransport/src/core/portal.cc +++ b/libtransport/src/core/portal.cc @@ -33,6 +33,8 @@ static const constexpr char default_module[] = ""; static const constexpr char default_module[] = "hicnlight_module.dylib"; #elif defined(LINUX) static const constexpr char default_module[] = "hicnlight_module.so"; +#elif defined(WINDOWS) +static const constexpr char default_module[] = "hicnlight_module.lib"; #endif IoModuleConfiguration Portal::conf_; @@ -69,6 +71,8 @@ std::string getIoModulePath(const std::string& name, std::string extension = ".so"; #elif defined(MACINTOSH) std::string extension = ".dylib"; +#elif defined(WINDOWS) + std::string extension = ".lib"; #else #error "Platform not supported."; #endif diff --git a/libtransport/src/core/prefix.cc b/libtransport/src/core/prefix.cc index 1e2b2ed9d..d598cff75 100644 --- a/libtransport/src/core/prefix.cc +++ b/libtransport/src/core/prefix.cc @@ -69,7 +69,7 @@ Prefix::Prefix(const core::Name &content_name, uint16_t prefix_length) { } ip_prefix_ = content_name.toIpAddress(); - ip_prefix_.len = prefix_length; + ip_prefix_.len = (u8)prefix_length; ip_prefix_.family = family; } @@ -95,7 +95,7 @@ void Prefix::buildPrefix(std::string &prefix, uint16_t prefix_length, throw errors::InvalidIpAddressException(); } - ip_prefix_.len = prefix_length; + ip_prefix_.len = (u8)prefix_length; ip_prefix_.family = family; } @@ -123,7 +123,7 @@ std::unique_ptr<Sockaddr> Prefix::toSockaddr() const { uint16_t Prefix::getPrefixLength() const { return ip_prefix_.len; } Prefix &Prefix::setPrefixLength(uint16_t prefix_length) { - ip_prefix_.len = prefix_length; + ip_prefix_.len = (u8)prefix_length; return *this; } @@ -228,7 +228,7 @@ Name Prefix::getRandomName() const { size_t size = (size_t)ceil((float)addr_len / 8.0); uint8_t *buffer = (uint8_t *)malloc(sizeof(uint8_t) * size); - RAND_bytes(buffer, size); + RAND_bytes(buffer, (int)size); int j = 0; for (uint8_t i = (uint8_t)ceil((float)ip_prefix_.len / 8.0); diff --git a/libtransport/src/core/rs.cc b/libtransport/src/core/rs.cc index 44b5852e5..33270736d 100644 --- a/libtransport/src/core/rs.cc +++ b/libtransport/src/core/rs.cc @@ -70,8 +70,8 @@ bool BlockCode::addSymbol(const fec::buffer &packet, uint32_t i, } void BlockCode::encode() { - gf *data[n_]; - std::uint16_t old_values[k_]; + gf **data = new gf*[k_]; + uint32_t *old_values = new uint32_t[k_]; uint32_t base = operator[](0).first; // Set packet length in first 2 bytes @@ -93,9 +93,10 @@ void BlockCode::encode() { uint16_t *length = reinterpret_cast<uint16_t *>(packet->writableData()); old_values[i] = *length; - *length = htons(packet->length() - LEN_SIZE_BYTES); + *length = htons(u_short(packet->length() - LEN_SIZE_BYTES)); data[i] = packet->writableData(); + } // Finish to fill source block with the buffers to hold the repair symbols @@ -121,7 +122,7 @@ void BlockCode::encode() { TRANSPORT_LOGD("Calling encode with max_buffer_size_ = %zu", max_buffer_size_); for (uint32_t i = k_; i < n_; i++) { - fec_encode(code_, data, data[i], i, max_buffer_size_ + LEN_SIZE_BYTES); + fec_encode(code_, data, data[i], i, (int)(max_buffer_size_ + LEN_SIZE_BYTES)); } // Restore original content of buffer space used to store the length @@ -138,11 +139,13 @@ void BlockCode::encode() { TRANSPORT_LOGD("Produced repair symbol of size = %zu", packet->length()); packet->prepend(sizeof(fec_header)); } + delete [] data; + delete [] old_values; } void BlockCode::decode() { - gf *data[k_]; - uint32_t index[k_]; + gf **data = new gf*[k_]; + uint32_t *index = new uint32_t[k_]; for (uint32_t i = 0; i < k_; i++) { auto &packet = operator[](i).second; @@ -161,7 +164,7 @@ void BlockCode::decode() { packet->ensureCapacityAndFillUnused(max_buffer_size_, 0); uint16_t *length = reinterpret_cast<uint16_t *>(packet->writableData()); - *length = htons(packet->length() - LEN_SIZE_BYTES); + *length = htons(u_short(packet->length() - LEN_SIZE_BYTES)); } else { TRANSPORT_LOGD("DECODE SYMBOL - index %u - Current buffer size: %zu", index[i], packet->length()); @@ -169,12 +172,14 @@ void BlockCode::decode() { } data[i] = packet->writableData(); + delete [] data; + delete [] index; } // We decode the source block TRANSPORT_LOGD("Calling decode with max_buffer_size_ = %zu", max_buffer_size_); - fec_decode(code_, data, reinterpret_cast<int *>(index), max_buffer_size_); + fec_decode(code_, data, reinterpret_cast<int *>(index), (int)max_buffer_size_); // Find the index in the block for recovered packets for (uint32_t i = 0; i < k_; i++) { diff --git a/libtransport/src/core/rs.h b/libtransport/src/core/rs.h index d630bd233..9a8c43e4d 100644 --- a/libtransport/src/core/rs.h +++ b/libtransport/src/core/rs.h @@ -14,7 +14,9 @@ * limitations under the License. */ +#ifndef _WIN32 #include <arpa/inet.h> +#endif #include <hicn/transport/utils/membuf.h> #include <protocols/fec_base.h> diff --git a/libtransport/src/implementation/p2psecure_socket_consumer.cc b/libtransport/src/implementation/p2psecure_socket_consumer.cc index 8c7c175b2..0b5966e71 100644 --- a/libtransport/src/implementation/p2psecure_socket_consumer.cc +++ b/libtransport/src/implementation/p2psecure_socket_consumer.cc @@ -76,7 +76,7 @@ int readOld(BIO *b, char *buf, int size) { } } - return read; + return (int)read; } /* Return the number of read bytes in readbytes */ diff --git a/libtransport/src/implementation/p2psecure_socket_producer.cc b/libtransport/src/implementation/p2psecure_socket_producer.cc index 6dff2ba08..aa14f9e37 100644 --- a/libtransport/src/implementation/p2psecure_socket_producer.cc +++ b/libtransport/src/implementation/p2psecure_socket_producer.cc @@ -55,8 +55,8 @@ P2PSecureProducerSocket::P2PSecureProducerSocket( der_prk_ = parcKeyStore_GetDEREncodedPrivateKey( (identity->getSigner()->getParcKeyStore())); - int cert_size = parcBuffer_Limit(der_cert_); - int prk_size = parcBuffer_Limit(der_prk_); + int cert_size = (int)parcBuffer_Limit(der_cert_); + int prk_size = (int)parcBuffer_Limit(der_prk_); const uint8_t *cert = reinterpret_cast<uint8_t *>(parcBuffer_Overlay(der_cert_, cert_size)); const uint8_t *prk = diff --git a/libtransport/src/implementation/socket_producer.h b/libtransport/src/implementation/socket_producer.h index af69cd818..f511f7743 100644 --- a/libtransport/src/implementation/socket_producer.h +++ b/libtransport/src/implementation/socket_producer.h @@ -417,7 +417,7 @@ class ProducerSocket : public Socket { uint32_t &socket_option_value) { switch (socket_option_key) { case GeneralTransportOptions::OUTPUT_BUFFER_SIZE: - socket_option_value = production_protocol_->getOutputBufferSize(); + socket_option_value = (uint32_t)production_protocol_->getOutputBufferSize(); break; case GeneralTransportOptions::DATA_PACKET_SIZE: diff --git a/libtransport/src/implementation/tls_socket_consumer.cc b/libtransport/src/implementation/tls_socket_consumer.cc index 99bcd4360..65472b41d 100644 --- a/libtransport/src/implementation/tls_socket_consumer.cc +++ b/libtransport/src/implementation/tls_socket_consumer.cc @@ -75,7 +75,7 @@ int readOldTLS(BIO *b, char *buf, int size) { } } - return read; + return (int)read; } /* Return the number of read bytes in readbytes */ diff --git a/libtransport/src/implementation/tls_socket_producer.cc b/libtransport/src/implementation/tls_socket_producer.cc index e54d38d56..dd92e58cf 100644 --- a/libtransport/src/implementation/tls_socket_producer.cc +++ b/libtransport/src/implementation/tls_socket_producer.cc @@ -64,7 +64,7 @@ int TLSProducerSocket::readOld(BIO *b, char *buf, int size) { if ((int)membuf->length() > size) { size_to_read = size; } else { - size_to_read = membuf->length(); + size_to_read = (int)membuf->length(); socket->something_to_read_ = false; } @@ -289,7 +289,7 @@ void TLSProducerSocket::onInterest(ProducerSocket &p, Interest &interest) { SSL_read( ssl_, const_cast<unsigned char *>(interest.getPayload()->writableData()), - interest.getPayload()->length()); + (int)interest.getPayload()->length()); } ProducerInterestCallback *on_interest_input_decrypted; @@ -325,7 +325,7 @@ void TLSProducerSocket::cacheMiss(interface::ProducerSocket &p, SSL_read( ssl_, const_cast<unsigned char *>(interest.getPayload()->writableData()), - interest.getPayload()->length()); + (int)interest.getPayload()->length()); } if (on_interest_process_decrypted_ != VOID_HANDLER) @@ -360,7 +360,7 @@ uint32_t TLSProducerSocket::produceStream( size_t buf_size = buffer->length(); name_ = production_protocol_->getNamespaces().front().mapName(content_name); tls_chunks_ = to_call_oncontentproduced_ = - ceil((float)buf_size / (float)SSL3_RT_MAX_PLAIN_LENGTH); + (int)ceil((float)buf_size / (float)SSL3_RT_MAX_PLAIN_LENGTH); if (!is_last) { tls_chunks_++; @@ -368,7 +368,7 @@ uint32_t TLSProducerSocket::produceStream( last_segment_ = start_offset; - SSL_write(ssl_, buffer->data(), buf_size); + SSL_write(ssl_, buffer->data(), (int)buf_size); BIO *wbio = SSL_get_wbio(ssl_); int i = BIO_flush(wbio); (void)i; // To shut up gcc 5 diff --git a/libtransport/src/io_modules/CMakeLists.txt b/libtransport/src/io_modules/CMakeLists.txt index 6553b9a2b..b1d251632 100644 --- a/libtransport/src/io_modules/CMakeLists.txt +++ b/libtransport/src/io_modules/CMakeLists.txt @@ -26,7 +26,20 @@ if (${CMAKE_SYSTEM_NAME} MATCHES Android) set(SOURCE_FILES ${SOURCE_FILES} PARENT_SCOPE) set(HEADER_FILES ${HEADER_FILES} PARENT_SCOPE) -else() +elseif (WIN32) + list(APPEND SOURCE_FILES + ${CMAKE_CURRENT_SOURCE_DIR}/udp/hicn_forwarder_module.cc + ${CMAKE_CURRENT_SOURCE_DIR}/udp/udp_socket_connector.cc + ) + + list(APPEND HEADER_FILES + ${CMAKE_CURRENT_SOURCE_DIR}/udp/hicn_forwarder_module.h + ${CMAKE_CURRENT_SOURCE_DIR}/udp/udp_socket_connector.h + ) + + set(SOURCE_FILES ${SOURCE_FILES} PARENT_SCOPE) + set(HEADER_FILES ${HEADER_FILES} PARENT_SCOPE) +else () add_subdirectory(udp) add_subdirectory(loopback) add_subdirectory(forwarder) diff --git a/libtransport/src/io_modules/udp/CMakeLists.txt b/libtransport/src/io_modules/udp/CMakeLists.txt index 1a43492dc..93518d0a2 100644 --- a/libtransport/src/io_modules/udp/CMakeLists.txt +++ b/libtransport/src/io_modules/udp/CMakeLists.txt @@ -34,14 +34,13 @@ list(APPEND MODULE_SOURCE_FILES # MACOSX_BUNDLE_SHORT_VERSION_STRING "0.1" # # MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/cmake/customtemplate.plist.in # ) - build_module(hicnlight_module - SHARED - SOURCES ${MODULE_SOURCE_FILES} - DEPENDS ${DEPENDENCIES} - COMPONENT lib${LIBTRANSPORT} - INCLUDE_DIRS ${LIBTRANSPORT_INCLUDE_DIRS} ${LIBTRANSPORT_INTERNAL_INCLUDE_DIRS} - # LIBRARY_ROOT_DIR "vpp_plugins" - DEFINITIONS ${COMPILER_DEFINITIONS} - COMPILE_OPTIONS ${COMPILE_FLAGS} + SHARED + SOURCES ${MODULE_SOURCE_FILES} + DEPENDS ${DEPENDENCIES} + COMPONENT lib${LIBTRANSPORT} + INCLUDE_DIRS ${LIBTRANSPORT_INCLUDE_DIRS} ${LIBTRANSPORT_INTERNAL_INCLUDE_DIRS} + # LIBRARY_ROOT_DIR "vpp_plugins" + DEFINITIONS ${COMPILER_DEFINITIONS} + COMPILE_OPTIONS ${COMPILE_FLAGS} ) 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); |