diff options
-rw-r--r-- | apps/CMakeLists.txt | 2 | ||||
-rw-r--r-- | apps/higet/CMakeLists.txt | 1 | ||||
-rw-r--r-- | apps/http-proxy/CMakeLists.txt | 2 | ||||
-rw-r--r-- | cmake/Modules/BuildMacros.cmake | 4 | ||||
-rw-r--r-- | ctrl/facemgr/src/api.c | 56 | ||||
-rw-r--r-- | ctrl/facemgr/src/interfaces/CMakeLists.txt | 1 | ||||
-rw-r--r-- | ctrl/facemgr/src/interfaces/hicn_light/hicn_light.c | 2 | ||||
-rw-r--r-- | ctrl/facemgr/src/interfaces/priority_controller/CMakeLists.txt | 30 | ||||
-rw-r--r-- | ctrl/facemgr/src/interfaces/priority_controller/priority_controller.c | 135 | ||||
-rw-r--r-- | ctrl/libhicnctrl/src/api.c | 4 | ||||
-rw-r--r-- | libtransport/src/hicn/transport/protocols/manifest_indexing_manager.cc | 111 | ||||
-rw-r--r-- | libtransport/src/hicn/transport/protocols/manifest_indexing_manager.h | 5 | ||||
-rw-r--r-- | libtransport/src/hicn/transport/protocols/rtc.cc | 27 | ||||
-rw-r--r-- | libtransport/src/hicn/transport/protocols/rtc_data_path.h | 2 | ||||
-rw-r--r-- | libtransport/src/hicn/transport/utils/suffix_strategy.h | 47 | ||||
-rw-r--r-- | utils/CMakeLists.txt | 5 |
16 files changed, 307 insertions, 127 deletions
diff --git a/apps/CMakeLists.txt b/apps/CMakeLists.txt index 9f4e753bb..c74be92ba 100644 --- a/apps/CMakeLists.txt +++ b/apps/CMakeLists.txt @@ -46,7 +46,7 @@ endif() set(SUFFIX "") if (${LIBTRANSPORT_LIBRARIES} MATCHES ".*-memif.*") set(SUFFIX "-memif") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,-unresolved-symbols=ignore-in-shared-libs") + set(LINK_FLAGS "-Wl,-unresolved-symbols=ignore-in-shared-libs") endif() set(HICN_APPS "${HICN_APPS}${SUFFIX}") diff --git a/apps/higet/CMakeLists.txt b/apps/higet/CMakeLists.txt index 83a13bcca..76814384d 100644 --- a/apps/higet/CMakeLists.txt +++ b/apps/higet/CMakeLists.txt @@ -37,4 +37,5 @@ build_executable(${HIGET} DEPENDS ${LIBTRANSPORT_LIBRARIES} COMPONENT ${HICN_APPS} DEFINITIONS ${COMPILER_DEFINITIONS} + LINK_FLAGS ${LINK_FLAGS} ) diff --git a/apps/http-proxy/CMakeLists.txt b/apps/http-proxy/CMakeLists.txt index 7e29edcf8..cc47e4b6f 100644 --- a/apps/http-proxy/CMakeLists.txt +++ b/apps/http-proxy/CMakeLists.txt @@ -55,6 +55,7 @@ build_library(${LIBHTTP_PROXY} LINK_LIBRARIES ${LIBRARIES} DEPENDS ${DEPENDENCIES} INCLUDE_DIRS ${LIBTRANSPORT_INCLUDE_DIRS} + LINK_FLAGS ${LINK_FLAGS} ) build_executable(${HTTP_PROXY} @@ -63,4 +64,5 @@ build_executable(${HTTP_PROXY} DEPENDS ${LIBHTTP_PROXY_STATIC} COMPONENT ${HICN_APPS} DEFINITIONS ${COMPILER_DEFINITIONS} + LINK_FLAGS ${LINK_FLAGS} ) diff --git a/cmake/Modules/BuildMacros.cmake b/cmake/Modules/BuildMacros.cmake index f89902dbc..85789a08a 100644 --- a/cmake/Modules/BuildMacros.cmake +++ b/cmake/Modules/BuildMacros.cmake @@ -21,7 +21,7 @@ macro(build_executable exec) cmake_parse_arguments(ARG "NO_INSTALL" "COMPONENT" - "SOURCES;LINK_LIBRARIES;DEPENDS;INCLUDE_DIRS;DEFINITIONS" + "SOURCES;LINK_LIBRARIES;DEPENDS;INCLUDE_DIRS;DEFINITIONS;LINK_FLAGS" ${ARGN} ) @@ -37,7 +37,7 @@ macro(build_executable exec) ARCHIVE_OUTPUT_DIRECTORY "${BUILD_ROOT}/lib" LIBRARY_OUTPUT_DIRECTORY "${BUILD_ROOT}/lib" RUNTIME_OUTPUT_DIRECTORY "${BUILD_ROOT}/bin" - LINK_FLAGS "-Wl,-unresolved-symbols=ignore-in-shared-libs" + LINK_FLAGS "${ARG_LINK_FLAGS}" ) if(ARG_LINK_LIBRARIES) diff --git a/ctrl/facemgr/src/api.c b/ctrl/facemgr/src/api.c index 13b811288..18a25d6a1 100644 --- a/ctrl/facemgr/src/api.c +++ b/ctrl/facemgr/src/api.c @@ -20,6 +20,7 @@ #ifdef __ANDROID__ //#define WITH_ANDROID_UTILITY +#define WITH_PRIORITY_CONTROLLER #endif /* __ANDROID__ */ #include <assert.h> @@ -85,6 +86,9 @@ extern interface_ops_t bonjour_ops; #ifdef WITH_ANDROID_UTILITY extern interface_ops_t android_utility_ops; #endif /* WITH_ANDROID_UTILITY */ +#ifdef WITH_PRIORITY_CONTROLLER +extern interface_ops_t priority_controller_ops; +#endif #ifdef WITH_EXAMPLE_DUMMY extern interface_ops_t dummy_ops; #endif @@ -139,13 +143,16 @@ struct facemgr_s { interface_t * au; /* android_utility */ #endif /* WITH_ANDROID_UTILITY */ +#ifdef WITH_PRIORITY_CONTROLLER + interface_t * pc; +#endif + #ifdef __APPLE__ interface_t * nf; /* network_framework */ #endif /* __APPLE__ */ #ifdef __linux__ interface_t * nl; /* netlink */ - /* * We maintain a map of dynamically created bonjour interfaces, one for each * found netdevice @@ -542,26 +549,6 @@ facelet_cache_lookup(const facelet_set_t * facelet_cache, facelet_t * facelet, facelet_t ***cached_facelets) { assert(facelet); - if (!facelet_has_family(facelet)) - return 0; -#if 0 // key is no more sufficient now that we support multiple faces per interface - /* - * If the facelet is uniquely identified by its key, it is used to perform - * an efficient lookup directly... - */ - if (facelet_has_key(facelet)) { - facelet_t * found = NULL; - if (facelet_set_get(facelet_cache, facelet, &found) < 0) { - ERROR("[facelet_cache_lookup] Error during cache lookup"); - return -1; - } - if (!found) - return 0; - *cached_facelets = malloc(sizeof(facelet_t*)); - *cached_facelets[0] = found; - return 1; - } -#endif /* ...otherwise, we iterate over the facelet * cache to find matching elements. @@ -1865,6 +1852,15 @@ facemgr_bootstrap(facemgr_t * facemgr) } #endif /* WITH_ANDROID_UTILITY */ +#ifdef WITH_PRIORITY_CONTROLLER + INFO("[facemgr_bootstrap] registering priority_controller interface"); + rc = interface_register(&priority_controller_ops); + if (rc < 0) { + ERROR("[facemgr_bootstrap] Error registering priority_controller interface"); + goto ERR_REGISTER; + } +#endif + #ifdef WITH_EXAMPLE_DUMMY rc = interface_register(&dummy_ops); if (rc < 0) { @@ -1916,6 +1912,15 @@ facemgr_bootstrap(facemgr_t * facemgr) } #endif /* WITH_ANDROID_UTILITY */ +#ifdef WITH_PRIORITY_CONTROLLER + INFO("[facemgr_bootstrap] creating priority_controller interface"); + rc = facemgr_create_interface(facemgr, "pc", "priority_controller", NULL, &facemgr->pc); + if (rc < 0) { + ERROR("Error creating 'Priority Controller' interface\n"); + goto ERR_PC_CREATE; + } +#endif + #ifdef WITH_EXAMPLE_DUMMY rc = facemgr_create_interface(facemgr, "dummy0", "dummy", NULL, &facemgr->dummy); if (rc < 0) { @@ -1948,6 +1953,10 @@ ERR_DUMMY_CREATE: facemgr_delete_interface(facemgr, facemgr->au); ERR_AU_CREATE: #endif /* WITH_ANDROID_UTILITY */ +#ifdef WITH_PRIORITY_CONTROLLER + facemgr_delete_interface(facemgr, facemgr->pc); +ERR_PC_CREATE: +#endif #ifdef __linux__ facemgr_delete_interface(facemgr, facemgr->nl); ERR_NL_CREATE: @@ -1997,6 +2006,10 @@ void facemgr_stop(facemgr_t * facemgr) facemgr_delete_interface(facemgr, facemgr->au); #endif /* WITH_ANDROID_UTILITY */ +#ifdef WITH_PRIORITY_CONTROLLER + facemgr_delete_interface(facemgr, facemgr->pc); +#endif + facemgr_delete_interface(facemgr, facemgr->hl); #ifdef WITH_EXAMPLE_DUMMY @@ -2103,3 +2116,4 @@ ERR: free(facelet_array); return rc; } + diff --git a/ctrl/facemgr/src/interfaces/CMakeLists.txt b/ctrl/facemgr/src/interfaces/CMakeLists.txt index 8d079612a..e4d4423e9 100644 --- a/ctrl/facemgr/src/interfaces/CMakeLists.txt +++ b/ctrl/facemgr/src/interfaces/CMakeLists.txt @@ -29,6 +29,7 @@ endif() if(ANDROID) add_subdirectory(android_utility) +add_subdirectory(priority_controller) endif() if(WITH_EXAMPLE_DUMMY) diff --git a/ctrl/facemgr/src/interfaces/hicn_light/hicn_light.c b/ctrl/facemgr/src/interfaces/hicn_light/hicn_light.c index 4ba4c5b1f..cb1a0040d 100644 --- a/ctrl/facemgr/src/interfaces/hicn_light/hicn_light.c +++ b/ctrl/facemgr/src/interfaces/hicn_light/hicn_light.c @@ -449,7 +449,7 @@ int hl_on_event(interface_t * interface, const facelet_t * facelet) } INFO("Admin state updated"); } - if (facelet_get_admin_state_status(facelet) == FACELET_ATTR_STATUS_DIRTY) { + if (facelet_get_priority_status(facelet) == FACELET_ATTR_STATUS_DIRTY) { hc_face.face = *face; hc_face_t * face_found; diff --git a/ctrl/facemgr/src/interfaces/priority_controller/CMakeLists.txt b/ctrl/facemgr/src/interfaces/priority_controller/CMakeLists.txt new file mode 100644 index 000000000..8d18800db --- /dev/null +++ b/ctrl/facemgr/src/interfaces/priority_controller/CMakeLists.txt @@ -0,0 +1,30 @@ +# Copyright (c) 2017-2019 Cisco and/or its affiliates. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +list(APPEND HEADER_FILES +) + +list(APPEND SOURCE_FILES + ${CMAKE_CURRENT_SOURCE_DIR}/priority_controller.c +) + +list(APPEND INCLUDE_DIRS +) + +list(APPEND LIBRARIES +) + +set(SOURCE_FILES ${SOURCE_FILES} PARENT_SCOPE) +set(HEADER_FILES ${HEADER_FILES} PARENT_SCOPE) +set(INCLUDE_DIRS ${INCLUDE_DIRS} PARENT_SCOPE) +set(LIBRARIES ${LIBRARIES} PARENT_SCOPE) diff --git a/ctrl/facemgr/src/interfaces/priority_controller/priority_controller.c b/ctrl/facemgr/src/interfaces/priority_controller/priority_controller.c new file mode 100644 index 000000000..b8e7271bb --- /dev/null +++ b/ctrl/facemgr/src/interfaces/priority_controller/priority_controller.c @@ -0,0 +1,135 @@ +#include <assert.h> +#include <sys/socket.h> +#include <sys/un.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +#include <hicn/facemgr.h> + +#include "../../common.h" +#include "../../interface.h" + +typedef struct { + int fd; +} pc_data_t; + +int priority_controller_initialize(interface_t * interface, void * cfg) +{ + INFO("Initializing priority controller"); + struct sockaddr_in addr; + + pc_data_t * data = malloc(sizeof(pc_data_t)); + if (!data) { + INFO("Priority controller data memory allocation error"); + goto ERR_MALLOC; + } + + interface->data = data; + + data->fd = socket(AF_INET, SOCK_DGRAM, 0); + //data->fd = socket(AF_INET, SOCK_STREAM, 0); + if (data->fd < 0) { + INFO("Priority controller socket error"); + perror("socket error"); + goto ERR_SOCKET; + } + + memset(&addr, 0, sizeof(addr)); + addr.sin_family = AF_INET; + addr.sin_addr.s_addr = inet_addr("127.0.0.1"); + addr.sin_port = htons(9533); + + if (bind(data->fd, (struct sockaddr*)&addr, sizeof(addr)) < 0) { + INFO("Priority controller socket bind error"); + perror("bind error"); + goto ERR_BIND; + } + if (interface_register_fd(interface, data->fd, NULL) < 0) { + ERROR("[priority_controller_initialize] Error registering fd"); + goto ERR_FD; + } + + INFO("Priority controller successfully initialized"); + return 0; + +ERR_FD: +ERR_BIND: + close(data->fd); +ERR_SOCKET: + free(data); +ERR_MALLOC: + return -1; +} + +int priority_controller_finalize(interface_t * interface) +{ + pc_data_t * data = (pc_data_t*)interface->data; + + if (data->fd > 0) {close(data->fd);} + free(data); + + return 0; +} + +int priority_controller_callback(interface_t * interface, int fd, void * unused) +{ + pc_data_t * data = (pc_data_t*)interface->data; + char buf[100]; + int rc; + + INFO("Priority controller receiving command"); + + rc = recv(data->fd, buf, 100, 0); + + if (rc < 0) { + INFO("Priority controller read error"); + return -1; + } + + INFO("Priority controller received command: %02X", buf[0]); + + facelet_t * facelet_w = facelet_create(); + facelet_t * facelet_c = facelet_create(); + facelet_set_netdevice_type(facelet_w, NETDEVICE_TYPE_WIFI); + facelet_set_netdevice_type(facelet_c, NETDEVICE_TYPE_CELLULAR); + facelet_set_status(facelet_w, FACELET_STATUS_CLEAN); + facelet_set_status(facelet_c, FACELET_STATUS_CLEAN); + switch(buf[0]) { + case '\0': + facelet_set_priority(facelet_w, 0); + facelet_set_priority(facelet_c, 10); + INFO("Priority controller configuring Cellular preferred"); + break; + case '\1': + facelet_set_priority(facelet_w, 10); + facelet_set_priority(facelet_c, 0); + INFO("Priority controller configuring Wi-Fi preferred"); + break; + case '\2': + facelet_set_priority(facelet_w, 0); + facelet_set_priority(facelet_c, 0); + INFO("Priority controller configuring both Cellular and Wi-Fi preferred"); + break; + default: + INFO("Priority cntroller invalid data received from updown server. Ignoring..."); + facelet_free(facelet_w); + facelet_free(facelet_c); + return -1; + } + + facelet_set_event(facelet_w, FACELET_EVENT_UPDATE); + facelet_set_event(facelet_c, FACELET_EVENT_UPDATE); + + interface_raise_event(interface, facelet_w); + interface_raise_event(interface, facelet_c); + + return 0; +} + +interface_ops_t priority_controller_ops = { + .type = "priority_controller", + .initialize = priority_controller_initialize, + .finalize = priority_controller_finalize, + .callback = priority_controller_callback, +}; diff --git a/ctrl/libhicnctrl/src/api.c b/ctrl/libhicnctrl/src/api.c index 8540addcf..e7caf4f1c 100644 --- a/ctrl/libhicnctrl/src/api.c +++ b/ctrl/libhicnctrl/src/api.c @@ -2283,7 +2283,7 @@ hc_face_get(hc_sock_t * s, hc_face_t * face, hc_face_t ** face_found) *face_found = NULL; return 0; } - *face_found = malloc(sizeof(face_t)); + *face_found = malloc(sizeof(hc_face_t)); hc_connection_to_face(connection_found, *face_found); free(connection_found); break; @@ -2299,7 +2299,7 @@ hc_face_get(hc_sock_t * s, hc_face_t * face, hc_face_t ** face_found) *face_found = NULL; return 0; } - *face_found = malloc(sizeof(face_t)); + *face_found = malloc(sizeof(hc_face_t)); hc_listener_to_face(listener_found, *face_found); free(listener_found); break; diff --git a/libtransport/src/hicn/transport/protocols/manifest_indexing_manager.cc b/libtransport/src/hicn/transport/protocols/manifest_indexing_manager.cc index 05cabc60d..0c3fd76cf 100644 --- a/libtransport/src/hicn/transport/protocols/manifest_indexing_manager.cc +++ b/libtransport/src/hicn/transport/protocols/manifest_indexing_manager.cc @@ -29,7 +29,6 @@ ManifestIndexManager::ManifestIndexManager( interface::ConsumerSocket *icn_socket, TransportProtocol *next_interest) : IncrementalIndexManager(icn_socket), PacketManager<Interest>(1024), - manifests_in_flight_(0), next_reassembly_segment_(suffix_queue_.end()), next_to_retrieve_segment_(suffix_queue_.end()), suffix_manifest_(core::NextSegmentCalculationStrategy::INCREMENTAL, 0), @@ -39,7 +38,6 @@ bool ManifestIndexManager::onManifest( core::ContentObject::Ptr &&content_object) { auto manifest = std::make_unique<ContentObjectManifest>(std::move(*content_object)); - bool manifest_verified = verification_manager_->onPacketToVerify(*manifest); if (manifest_verified) { @@ -54,14 +52,12 @@ bool ManifestIndexManager::onManifest( case core::ManifestType::INLINE_MANIFEST: { auto _it = manifest->getSuffixList().begin(); auto _end = --manifest->getSuffixList().end(); + final_suffix_ = manifest->getFinalBlockNumber(); // final block number if (TRANSPORT_EXPECT_FALSE(manifest->isFinalManifest())) { _end++; } - // Get final block number - final_suffix_ = manifest->getFinalBlockNumber(); - suffix_hash_map_[_it->first] = std::make_pair(std::vector<uint8_t>(_it->second, _it->second + 32), manifest->getHashAlgorithm()); @@ -93,62 +89,13 @@ bool ManifestIndexManager::onManifest( 1); suffix_manifest_.setSuffixStrategy( manifest->getNextSegmentCalculationStrategy()); - } else if (manifests_in_flight_) { - manifests_in_flight_--; } - if (TRANSPORT_EXPECT_FALSE(manifest->isFinalManifest() || - suffix_manifest_.getSuffix() > - final_suffix_)) { - break; + if (TRANSPORT_EXPECT_FALSE(manifest->isFinalManifest()) == 0) { + fillWindow(manifest->getWritableName(), + manifest->getName().getSuffix()); } - // Get current window size - double current_window_size = 0.; - socket_->getSocketOption(GeneralTransportOptions::CURRENT_WINDOW_SIZE, - current_window_size); - - // Get portal - std::shared_ptr<interface::BasePortal> portal; - socket_->getSocketOption(GeneralTransportOptions::PORTAL, portal); - - // Number of segments in manifest - std::size_t segment_count = 0; - - // Manifest namespace - Name &name = manifest->getWritableName(); - - if (manifests_in_flight_ >= MAX_MANIFESTS_IN_FLIGHT) { - break; - } - - // Send as many manifest as required for filling window. - do { - segment_count += suffix_manifest_.getNbSegments(); - suffix_manifest_++; - - Interest::Ptr interest = getPacket(); - name.setSuffix(suffix_manifest_.getSuffix()); - interest->setName(name); - - uint32_t interest_lifetime; - socket_->getSocketOption(GeneralTransportOptions::INTEREST_LIFETIME, - interest_lifetime); - interest->setLifetime(interest_lifetime); - - // Send requests for manifest out of the congestion window (no - // in_flight_interests++) - portal->sendInterest( - std::move(interest), - std::bind(&ManifestIndexManager::onManifestReceived, this, - std::placeholders::_1, std::placeholders::_2), - std::bind(&ManifestIndexManager::onManifestTimeout, this, - std::placeholders::_1)); - manifests_in_flight_++; - } while (segment_count < current_window_size && - suffix_manifest_.getSuffix() < final_suffix_ && - manifests_in_flight_ < MAX_MANIFESTS_IN_FLIGHT); - break; } case core::ManifestType::FLIC_MANIFEST: { @@ -193,6 +140,56 @@ void ManifestIndexManager::onManifestTimeout(Interest::Ptr &&i) { std::placeholders::_1)); } +void ManifestIndexManager::fillWindow(Name &name, uint32_t current_manifest) { + /* Send as many manifest as required for filling window. */ + uint32_t interest_lifetime; + double window_size; + std::shared_ptr<interface::BasePortal> portal; + Interest::Ptr interest; + uint32_t current_segment = *next_to_retrieve_segment_; + // suffix_manifest_ now points to the next manifest to request + uint32_t last_requested_manifest = (suffix_manifest_++).getSuffix(); + + socket_->getSocketOption(GeneralTransportOptions::PORTAL, portal); + socket_->getSocketOption(GeneralTransportOptions::INTEREST_LIFETIME, + interest_lifetime); + socket_->getSocketOption(GeneralTransportOptions::CURRENT_WINDOW_SIZE, + window_size); + + if (TRANSPORT_EXPECT_FALSE(suffix_manifest_.getSuffix() >= final_suffix_)) { + suffix_manifest_.updateSuffix(last_requested_manifest); + return; + } + + if (current_segment + window_size < suffix_manifest_.getSuffix() && + current_manifest != last_requested_manifest) { + suffix_manifest_.updateSuffix(last_requested_manifest); + return; + } + + do { + interest = getPacket(); + name.setSuffix(suffix_manifest_.getSuffix()); + interest->setName(name); + interest->setLifetime(interest_lifetime); + + // Send interests for manifest out of the congestion window (no + // in_flight_interests++) + portal->sendInterest( + std::move(interest), + std::bind(&ManifestIndexManager::onManifestReceived, this, + std::placeholders::_1, std::placeholders::_2), + std::bind(&ManifestIndexManager::onManifestTimeout, this, + std::placeholders::_1)); + + last_requested_manifest = (suffix_manifest_++).getSuffix(); + } while (current_segment + window_size >= suffix_manifest_.getSuffix() && + suffix_manifest_.getSuffix() < final_suffix_); + + // suffix_manifest_ now points to the last requested manifest + suffix_manifest_.updateSuffix(last_requested_manifest); +} + bool ManifestIndexManager::onContentObject( const core::ContentObject &content_object) { bool verify_signature; diff --git a/libtransport/src/hicn/transport/protocols/manifest_indexing_manager.h b/libtransport/src/hicn/transport/protocols/manifest_indexing_manager.h index 74c86eb60..cb88940d5 100644 --- a/libtransport/src/hicn/transport/protocols/manifest_indexing_manager.h +++ b/libtransport/src/hicn/transport/protocols/manifest_indexing_manager.h @@ -21,9 +21,6 @@ #include <list> -/* #define MAX_MANIFESTS_IN_FLIGHT std::numeric_limits<uint32_t>::max() */ -#define MAX_MANIFESTS_IN_FLIGHT 10 - namespace transport { namespace protocol { @@ -58,9 +55,9 @@ class ManifestIndexManager : public IncrementalIndexManager, private: void onManifestReceived(Interest::Ptr &&i, ContentObject::Ptr &&c); void onManifestTimeout(Interest::Ptr &&i); + void fillWindow(Name &name, uint32_t current_manifest); protected: - uint32_t manifests_in_flight_; SuffixQueue suffix_queue_; SuffixQueue::iterator next_reassembly_segment_; SuffixQueue::iterator next_to_retrieve_segment_; diff --git a/libtransport/src/hicn/transport/protocols/rtc.cc b/libtransport/src/hicn/transport/protocols/rtc.cc index aeee48bac..4d8e4c514 100644 --- a/libtransport/src/hicn/transport/protocols/rtc.cc +++ b/libtransport/src/hicn/transport/protocols/rtc.cc @@ -300,6 +300,16 @@ void RTCTransportProtocol::updateStats(uint32_t round_duration) { updateCCState(); updateWindow(); + if(queuingDelay_ > 100.0){ + //this indicates that the client will go soon out of synch, + //switch to synch mode + if (currentState_ == HICN_RTC_NORMAL_STATE) { + currentState_ = HICN_RTC_SYNC_STATE; + } + computeMaxWindow(BW, 0); + increaseWindow(); + } + // in any case we reset all the counters gotNack_ = false; @@ -351,7 +361,7 @@ void RTCTransportProtocol::computeMaxWindow(uint32_t productionRate, void RTCTransportProtocol::updateWindow() { if (currentState_ == HICN_RTC_SYNC_STATE) return; - if (currentCWin_ < maxCWin_ * 0.7) { + if (currentCWin_ < maxCWin_ * 0.9) { currentCWin_ = min(maxCWin_, (uint32_t)(currentCWin_ * HICN_WIN_INCREASE_FACTOR)); } else if (currentCWin_ > maxCWin_) { @@ -378,7 +388,7 @@ void RTCTransportProtocol::increaseWindow() { if (currentState_ == HICN_RTC_NORMAL_STATE) return; // we need to be carefull to do not increase the window to much - if (currentCWin_ < ((double)maxCWin_ * 0.5)) { + if (currentCWin_ < ((double)maxCWin_ * 0.7)) { currentCWin_ = currentCWin_ + 1; // exponential } else { currentCWin_ = min( @@ -542,14 +552,15 @@ void RTCTransportProtocol::sentinelTimer(){ } } }else{ - uint64_t max_waiting_time = - round((pathTable_[producerPathLabels_[1]]->getMinRtt() - + uint64_t max_waiting_time = //wait at least 50ms + (pathTable_[producerPathLabels_[1]]->getMinRtt() - pathTable_[producerPathLabels_[0]]->getMinRtt()) + - (pathTable_[producerPathLabels_[0]]->getInterArrivalGap() * 10)); + (ceil(pathTable_[producerPathLabels_[0]]->getInterArrivalGap()) * 50); if((currentState_ == HICN_RTC_NORMAL_STATE) && (inflightInterestsCount_ >= currentCWin_) && - ((now - lastEvent_) > max_waiting_time)){ + ((now - lastEvent_) > max_waiting_time) && + (lossRate_ > 10.0)){ uint64_t RTT = pathTable_[producerPathLabels_[1]]->getMinRtt(); @@ -859,8 +870,8 @@ void RTCTransportProtocol::onContentObject( uint32_t pathLabel = content_object->getPathLabel(); if (pathTable_.find(pathLabel) == pathTable_.end()) { - // if this path does not exists we cannot create a new one so drop - return; + std::shared_ptr<RTCDataPath> newPath = std::make_shared<RTCDataPath>(); + pathTable_[pathLabel] = newPath; } // this is the expected probe, update the RTT and drop the packet diff --git a/libtransport/src/hicn/transport/protocols/rtc_data_path.h b/libtransport/src/hicn/transport/protocols/rtc_data_path.h index c8a049368..48a67c525 100644 --- a/libtransport/src/hicn/transport/protocols/rtc_data_path.h +++ b/libtransport/src/hicn/transport/protocols/rtc_data_path.h @@ -20,7 +20,7 @@ #include <climits> #define ALPHA_RTC 0.125 -#define HISTORY_LEN 30 +#define HISTORY_LEN 20 //4 sec namespace transport { diff --git a/libtransport/src/hicn/transport/utils/suffix_strategy.h b/libtransport/src/hicn/transport/utils/suffix_strategy.h index 4358d12f0..3014855f6 100644 --- a/libtransport/src/hicn/transport/utils/suffix_strategy.h +++ b/libtransport/src/hicn/transport/utils/suffix_strategy.h @@ -38,8 +38,6 @@ class SuffixStrategy { std::uint32_t getSuffix() { return suffix_; } - virtual std::uint32_t getNextSuffix() = 0; - void updateSuffix(std::uint32_t new_suffix) { suffix_ = new_suffix; } std::size_t getNbSegments() { return nb_segments_; } @@ -57,6 +55,7 @@ class SuffixStrategy { transport::core::NextSegmentCalculationStrategy suffix_stragegy_; std::uint32_t suffix_; std::size_t nb_segments_; + virtual std::uint32_t getNextSuffix() = 0; }; class SuffixManifest : public SuffixStrategy { @@ -66,27 +65,22 @@ class SuffixManifest : public SuffixStrategy { std::uint32_t start_offset) : SuffixStrategy(suffix_stragegy, start_offset) {} - std::uint32_t getNextSuffix(); - SuffixManifest operator++() { - uint32_t next_suffix = getNextSuffix(); - updateSuffix(next_suffix); - return SuffixManifest(suffix_stragegy_, next_suffix); + updateSuffix(getNextSuffix()); + SuffixManifest temp_suffix(suffix_stragegy_, suffix_); + temp_suffix.setNbSegments(getNbSegments()); + return temp_suffix; } SuffixManifest operator++(int) { SuffixManifest temp_suffix(suffix_stragegy_, suffix_); - uint32_t next_suffix = getNextSuffix(); - updateSuffix(next_suffix); + temp_suffix.setNbSegments(getNbSegments()); + updateSuffix(getNextSuffix()); return temp_suffix; } - SuffixManifest operator+(uint32_t shift) { - for (uint32_t i = 0; i < shift; i++) { - updateSuffix(getNextSuffix()); - } - return SuffixManifest(suffix_stragegy_, getSuffix()); - } + protected: + std::uint32_t getNextSuffix(); }; class SuffixContent : public SuffixStrategy { @@ -101,28 +95,22 @@ class SuffixContent : public SuffixStrategy { std::uint32_t start_offset) : SuffixContent(suffix_stragegy, start_offset, false) {} - std::uint32_t getNextSuffix(); - SuffixContent operator++() { - uint32_t next_suffix = getNextSuffix(); - updateSuffix(next_suffix); - return SuffixContent(suffix_stragegy_, next_suffix, making_manifest_); + updateSuffix(getNextSuffix()); + SuffixContent temp_suffix(suffix_stragegy_, suffix_, making_manifest_); + temp_suffix.setNbSegments(getNbSegments()); + temp_suffix.content_counter_ = content_counter_; + return temp_suffix; } SuffixContent operator++(int) { SuffixContent temp_suffix(suffix_stragegy_, suffix_, making_manifest_); - uint32_t next_suffix = getNextSuffix(); - updateSuffix(next_suffix); + temp_suffix.setNbSegments(getNbSegments()); + temp_suffix.content_counter_ = content_counter_; + updateSuffix(getNextSuffix()); return temp_suffix; } - SuffixContent operator+(uint32_t shift) { - for (uint32_t i = 0; i < shift; i++) { - updateSuffix(getNextSuffix()); - } - return SuffixContent(suffix_stragegy_, getSuffix(), making_manifest_); - } - void setUsingManifest(bool value) { making_manifest_ = value; } void reset(std::uint32_t reset_suffix) { @@ -135,5 +123,6 @@ class SuffixContent : public SuffixStrategy { /* content_counter_ keeps track of the number of segments */ /* between two manifests */ uint32_t content_counter_; + std::uint32_t getNextSuffix(); }; } // namespace utils diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt index 3ed6f9bf3..0e5430356 100644 --- a/utils/CMakeLists.txt +++ b/utils/CMakeLists.txt @@ -47,7 +47,7 @@ endif() set(SUFFIX "") if (${LIBTRANSPORT_LIBRARIES} MATCHES ".*-memif.*") set(SUFFIX "-memif") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,-unresolved-symbols=ignore-in-shared-libs") + set(LINK_FLAGS "-Wl,-unresolved-symbols=ignore-in-shared-libs") endif() set(HICN_UTILS "${HICN_UTILS}${SUFFIX}") @@ -66,6 +66,7 @@ build_executable(hiperf DEPENDS ${DEPENDENCIES} COMPONENT ${HICN_UTILS} DEFINITIONS ${COMPILER_DEFINITIONS} + LINK_FLAGS ${LINK_FLAGS} ) build_executable(hicn-ping-server @@ -74,6 +75,7 @@ build_executable(hicn-ping-server DEPENDS ${DEPENDENCIES} COMPONENT ${HICN_UTILS} DEFINITIONS ${COMPILER_DEFINITIONS} + LINK_FLAGS ${LINK_FLAGS} ) build_executable(hicn-ping-client @@ -82,4 +84,5 @@ build_executable(hicn-ping-client DEPENDS ${DEPENDENCIES} COMPONENT ${HICN_UTILS} DEFINITIONS ${COMPILER_DEFINITIONS} + LINK_FLAGS ${LINK_FLAGS} ) |