diff options
-rw-r--r-- | ctrl/facemgr/src/api.c | 1 | ||||
-rw-r--r-- | ctrl/facemgr/src/interfaces/hicn_light/hicn_light.c | 3 | ||||
-rw-r--r-- | ctrl/libhicnctrl/examples/Makefile | 2 | ||||
-rw-r--r-- | ctrl/libhicnctrl/examples/update_priority.c | 60 | ||||
-rw-r--r-- | ctrl/libhicnctrl/includes/hicn/ctrl/api.h | 5 | ||||
-rw-r--r-- | ctrl/libhicnctrl/includes/hicn/ctrl/commands.h | 4 | ||||
-rw-r--r-- | ctrl/libhicnctrl/src/api.c | 45 | ||||
-rw-r--r-- | hicn-light/src/hicn/config/configuration.c | 4 | ||||
-rw-r--r-- | hicn-light/src/hicn/config/controlListConnections.c | 6 | ||||
-rw-r--r-- | hicn-light/src/hicn/core/connection.c | 4 | ||||
-rw-r--r-- | hicn-light/src/hicn/core/name.c | 5 | ||||
-rw-r--r-- | hicn-light/src/hicn/utils/commands.h | 4 | ||||
-rw-r--r-- | libtransport/src/hicn/transport/interfaces/rtc_socket_producer.cc | 6 | ||||
-rw-r--r-- | libtransport/src/hicn/transport/protocols/manifest_indexing_manager.cc | 18 | ||||
-rw-r--r-- | libtransport/src/hicn/transport/protocols/manifest_indexing_manager.h | 4 | ||||
-rw-r--r-- | libtransport/src/hicn/transport/protocols/rtc.cc | 4 | ||||
-rw-r--r-- | libtransport/src/hicn/transport/utils/suffix_strategy.h | 5 |
17 files changed, 141 insertions, 39 deletions
diff --git a/ctrl/facemgr/src/api.c b/ctrl/facemgr/src/api.c index dfb23db3b..13b811288 100644 --- a/ctrl/facemgr/src/api.c +++ b/ctrl/facemgr/src/api.c @@ -2087,7 +2087,6 @@ facemgr_list_facelets_json(const facemgr_t * facemgr, char ** buffer) if (size != 0 && cur >= s + size) goto END; } - free(facelet_array); rc = snprintf(cur, s + size - cur, "]}\n"); if (rc < 0) diff --git a/ctrl/facemgr/src/interfaces/hicn_light/hicn_light.c b/ctrl/facemgr/src/interfaces/hicn_light/hicn_light.c index a6cd44fe0..4ba4c5b1f 100644 --- a/ctrl/facemgr/src/interfaces/hicn_light/hicn_light.c +++ b/ctrl/facemgr/src/interfaces/hicn_light/hicn_light.c @@ -101,7 +101,6 @@ int hl_process_state(interface_t * interface) } data->state = HL_STATE_FACES_SENT; break; - break; case HL_STATE_FACES_RECEIVED: data->state = HL_STATE_IDLE; @@ -601,7 +600,7 @@ int hl_callback(interface_t * interface, int fd, void * unused) facelet_set_event(facelet, FACELET_EVENT_GET); interface_raise_event(interface, facelet); } - + hc_data_free(results); hc_data_free(data->polled_routes); data->polled_routes = NULL; data->state = HL_STATE_FACES_RECEIVED; diff --git a/ctrl/libhicnctrl/examples/Makefile b/ctrl/libhicnctrl/examples/Makefile index 641936f4f..ad0e46a1e 100644 --- a/ctrl/libhicnctrl/examples/Makefile +++ b/ctrl/libhicnctrl/examples/Makefile @@ -9,7 +9,7 @@ EXEC = $(SRC:.c=) all: $(EXEC) -${EXEC}: $(SRC) +%:%.c $(CC) -o $@ $< $(CFLAGS) $(LDFLAGS) .PHONY: clean mrproper diff --git a/ctrl/libhicnctrl/examples/update_priority.c b/ctrl/libhicnctrl/examples/update_priority.c new file mode 100644 index 000000000..d350f71c9 --- /dev/null +++ b/ctrl/libhicnctrl/examples/update_priority.c @@ -0,0 +1,60 @@ +/* + * 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. + */ + +/** + * \file examples/update_priority.c + * \brief libhicnctrl sample code : face priority update + */ + +#include <stdlib.h> +#include <stdio.h> + +#include <hicn/ctrl.h> +#include <hicn/util/log.h> + +int main(int argc, char **argv) +{ + if (argc != 3) { + fprintf(stderr, "Usage: %s FACE_ID PRIORITY\n", argv[0]); + exit(EXIT_FAILURE); + } + unsigned face_id = atoi(argv[1]); + unsigned priority = atoi(argv[2]); + char face_id_s[SYMBOLIC_NAME_LEN]; + + hc_sock_t * socket = hc_sock_create(); + if (!socket){ + DEBUG("Error creating libhicnctrl socket"); + goto ERR_SOCK; + } + + if (hc_sock_connect(socket) < 0){ + DEBUG("Error connecting to forwarder"); + goto ERR; + } + + snprintf(face_id_s, SYMBOLIC_NAME_LEN, "%d", face_id); + if (hc_face_set_priority(socket, face_id_s, priority) < 0) { + DEBUG("Error setting face priority"); + goto ERR; + } + + DEBUG("Face priority updated successfully"); + +ERR: + hc_sock_free(socket); +ERR_SOCK: + return 0; +} diff --git a/ctrl/libhicnctrl/includes/hicn/ctrl/api.h b/ctrl/libhicnctrl/includes/hicn/ctrl/api.h index b6d2686b7..eba80bdb3 100644 --- a/ctrl/libhicnctrl/includes/hicn/ctrl/api.h +++ b/ctrl/libhicnctrl/includes/hicn/ctrl/api.h @@ -568,6 +568,11 @@ int hc_face_delete(hc_sock_t *s, hc_face_t *face); int hc_face_list(hc_sock_t *s, hc_data_t **pdata); int hc_face_list_async(hc_sock_t *s); //, hc_data_t ** pdata); +int hc_face_set_admin_state(hc_sock_t * s, const char * conn_id_or_name, face_state_t state); +#ifdef WITH_POLICY +int hc_face_set_priority(hc_sock_t * s, const char * conn_id_or_name, uint32_t priority); +#endif /* WITH_POLICY */ + #define foreach_face(VAR, data) foreach_type(hc_face_t, VAR, data) #define MAX_FACE_ID 255 diff --git a/ctrl/libhicnctrl/includes/hicn/ctrl/commands.h b/ctrl/libhicnctrl/includes/hicn/ctrl/commands.h index 520559ccf..c250216f0 100644 --- a/ctrl/libhicnctrl/includes/hicn/ctrl/commands.h +++ b/ctrl/libhicnctrl/includes/hicn/ctrl/commands.h @@ -167,10 +167,6 @@ typedef struct { add_connection_command connectionData; uint32_t connid; uint8_t state; - uint8_t admin_state; -#ifdef WITH_POLICY - uint32_t priority; -#endif /* WITH_POLICY */ char interfaceName[SYMBOLIC_NAME_LEN]; char connectionName[SYMBOLIC_NAME_LEN]; } list_connections_command; diff --git a/ctrl/libhicnctrl/src/api.c b/ctrl/libhicnctrl/src/api.c index 5afecf7e6..8540addcf 100644 --- a/ctrl/libhicnctrl/src/api.c +++ b/ctrl/libhicnctrl/src/api.c @@ -520,6 +520,8 @@ hc_sock_free(hc_sock_t * s) } else { for (unsigned i = 0; i < n; i++) { hc_sock_request_t * request = request_array[i]; + if (hc_sock_map_remove(s->map, request->seq, NULL) < 0) + ERROR("[hc_sock_process] Error removing request from map"); hc_sock_request_free(request); } free(request_array); @@ -622,6 +624,9 @@ hc_sock_recv(hc_sock_t * s) return rc; } +/* + * Returns -99 in case of internal error, -1 in case of API command failure + */ int hc_sock_process(hc_sock_t * s, hc_data_t ** data) { @@ -643,11 +648,11 @@ hc_sock_process(hc_sock_t * s, hc_data_t ** data) hc_sock_request_t * request = NULL; if (hc_sock_map_get(s->map, msg->hdr.seqNum, &request) < 0) { ERROR("[hc_sock_process] Error searching for matching request"); - return -1; + return -99; } if (!request) { ERROR("[hc_sock_process] No request matching received sequence number"); - return -1; + return -99; } s->remaining = msg->hdr.length; @@ -662,12 +667,15 @@ hc_sock_process(hc_sock_t * s, hc_data_t ** data) assert(!data); hc_data_set_error(request->data); s->cur_request = request; + err = -1; break; case RESPONSE_LIGHT: assert(data); if (s->remaining == 0) { hc_data_set_complete(request->data); *data = request->data; + if (hc_sock_map_remove(s->map, request->seq, NULL) < 0) + ERROR("[hc_sock_process] Error removing request from map"); hc_sock_request_free(request); } else { /* We only remember it if there is still data to parse */ @@ -676,7 +684,7 @@ hc_sock_process(hc_sock_t * s, hc_data_t ** data) break; default: ERROR("[hc_sock_process] Invalid response received"); - return -1; + return -99; } available -= sizeof(hc_msg_header_t); @@ -697,15 +705,15 @@ hc_sock_process(hc_sock_t * s, hc_data_t ** data) int rc; rc = hc_data_ensure_available(s->cur_request->data, num_chunks); if (rc < 0) - return -1; + return -99; for (int i = 0; i < num_chunks; i++) { u8 * dst = hc_data_get_next(s->cur_request->data); if (!dst) - return -1; + return -99; rc = s->cur_request->parse(s->buf + s->roff + i * s->cur_request->data->in_element_size, dst); if (rc < 0) - err = -1; /* FIXME we let the loop complete (?) */ + err = -99; /* FIXME we let the loop complete (?) */ s->cur_request->data->size++; } } @@ -716,7 +724,7 @@ hc_sock_process(hc_sock_t * s, hc_data_t ** data) if (s->remaining == 0) { if (hc_sock_map_remove(s->map, s->cur_request->seq, NULL) < 0) { ERROR("[hc_sock_process] Error removing request from map"); - return -1; + return -99; } hc_data_set_complete(s->cur_request->data); if (data) @@ -881,9 +889,20 @@ hc_execute_command(hc_sock_t * s, hc_msg_t * msg, size_t msg_len, */ if (hc_sock_recv(s) < 0) continue; //break; - if (hc_sock_process(s, pdata) < 0) { - ERROR("[hc_execute_command] Error processing socket results"); - goto ERR_PROCESS; + int rc = hc_sock_process(s, pdata); + switch(rc) { + case 0: + break; + case -1: + ret = rc; + break; + case -99: + ERROR("[hc_execute_command] Error processing socket results"); + goto ERR_PROCESS; + break; + default: + ERROR("[hc_execute_command] Unexpected return value"); + goto ERR_PROCESS; } } @@ -899,7 +918,7 @@ ERR_MAP: ERR_REQUEST: hc_data_free(data); ERR_DATA: - return -1; + return -99; } /*----------------------------------------------------------------------------* @@ -1655,7 +1674,7 @@ _hc_connection_set_priority(hc_sock_t * s, const char * conn_id_or_name, } msg = { .hdr = { .messageType = REQUEST_LIGHT, - .commandID = CONNECTION_SET_ADMIN_STATE, + .commandID = CONNECTION_SET_PRIORITY, .length = 1, .seqNum = 0, }, @@ -2302,7 +2321,7 @@ hc_face_delete(hc_sock_t * s, hc_face_t * face) int rc = hc_face_snprintf(face_s, MAXSZ_HC_FACE, face); if (rc >= MAXSZ_HC_FACE) WARN("[hc_face_delete] Unexpected truncation of face string"); - DEBUG("[hc_face_delete] face=%s"); + DEBUG("[hc_face_delete] face=%s", face_s); hc_connection_t connection; if (hc_face_to_connection(face, &connection, false) < 0) { diff --git a/hicn-light/src/hicn/config/configuration.c b/hicn-light/src/hicn/config/configuration.c index f135dcc5a..0466189cb 100644 --- a/hicn-light/src/hicn/config/configuration.c +++ b/hicn-light/src/hicn/config/configuration.c @@ -698,7 +698,7 @@ struct iovec *configuration_ProcessConnectionList(Configuration *config, listConnectionsCommand->state = connection_IsUp(original) ? IFACE_UP : IFACE_DOWN; - listConnectionsCommand->admin_state = + listConnectionsCommand->connectionData.admin_state = (connection_GetAdminState(original) == CONNECTION_STATE_UP) ? IFACE_UP : IFACE_DOWN; listConnectionsCommand->connectionData.connectionType = ioOperations_GetConnectionType(connection_GetIoOperations(original)); @@ -706,7 +706,7 @@ struct iovec *configuration_ProcessConnectionList(Configuration *config, listConnectionsCommand->connectionData.admin_state = connection_GetAdminState(original); #ifdef WITH_POLICY - listConnectionsCommand->priority = connection_GetPriority(original); + listConnectionsCommand->connectionData.priority = connection_GetPriority(original); listConnectionsCommand->connectionData.tags = connection_GetTags(original); #endif /* WITH_POLICY */ diff --git a/hicn-light/src/hicn/config/controlListConnections.c b/hicn-light/src/hicn/config/controlListConnections.c index 0613ac4f9..cbed8a79c 100644 --- a/hicn-light/src/hicn/config/controlListConnections.c +++ b/hicn-light/src/hicn/config/controlListConnections.c @@ -109,7 +109,7 @@ static CommandReturn _controlListConnections_Execute(CommandParser *parser, commandOutputMain = parcMemory_Allocate(sizeof(char *) * receivedHeader->length); for (size_t j = 0; j < receivedHeader->length; j++) { - commandOutputMain[j] = parcMemory_Allocate(sizeof(char) * 128); + commandOutputMain[j] = parcMemory_Allocate(sizeof(char) * 256); } } @@ -147,8 +147,8 @@ foreach_policy_tag *s = '\0'; parcBufferComposer_Format( - composer, "%5d %10s %12s %6s %40s %40s %5s [%d] [%s]", listConnectionsCommand->connid, listConnectionsCommand->connectionName, - stateString[listConnectionsCommand->admin_state], + composer, "%5d %10s %12s %6s %40s %40s %5s [%6d] [%s]", listConnectionsCommand->connid, listConnectionsCommand->connectionName, + stateString[listConnectionsCommand->connectionData.admin_state], stateString[listConnectionsCommand->state], sourceString, destinationString, connTypeString[listConnectionsCommand->connectionData.connectionType], diff --git a/hicn-light/src/hicn/core/connection.c b/hicn-light/src/hicn/core/connection.c index 8ec38f75f..c1d143f70 100644 --- a/hicn-light/src/hicn/core/connection.c +++ b/hicn-light/src/hicn/core/connection.c @@ -337,7 +337,7 @@ uint32_t connection_GetPriority(const Connection *conn) { parcAssertNotNull(conn, "Parameter conn must be non-null"); if (!conn->ops) - return CONNECTION_STATE_UNDEFINED; + return 0; return ioOperations_GetPriority(conn->ops); } @@ -346,8 +346,6 @@ void connection_SetPriority(Connection *conn, uint32_t priority) parcAssertNotNull(conn, "Parameter conn must be non-null"); if (!conn->ops) return; - if ((priority != CONNECTION_STATE_UP) && (priority != CONNECTION_STATE_DOWN)) - return; ioOperations_SetPriority(conn->ops, priority); } #endif /* WITH_POLICY */ diff --git a/hicn-light/src/hicn/core/name.c b/hicn-light/src/hicn/core/name.c index 7ef3fcc01..76efa6a8e 100644 --- a/hicn-light/src/hicn/core/name.c +++ b/hicn-light/src/hicn/core/name.c @@ -194,6 +194,11 @@ bool name_Equals(const Name *a, const Name *b) { parcAssertNotNull(a, "Parameter a must be non-null"); parcAssertNotNull(b, "Parameter b must be non-null"); + /* BEGIN: Workaround for HICN-400 */ + if ((!a->content_name) || (!b->content_name)) + return false; + /* END: Workaround for HICN-400 */ + if ((nameBitvector_Equals(a->content_name, b->content_name) && a->segment == b->segment)) return true; diff --git a/hicn-light/src/hicn/utils/commands.h b/hicn-light/src/hicn/utils/commands.h index 520559ccf..c250216f0 100644 --- a/hicn-light/src/hicn/utils/commands.h +++ b/hicn-light/src/hicn/utils/commands.h @@ -167,10 +167,6 @@ typedef struct { add_connection_command connectionData; uint32_t connid; uint8_t state; - uint8_t admin_state; -#ifdef WITH_POLICY - uint32_t priority; -#endif /* WITH_POLICY */ char interfaceName[SYMBOLIC_NAME_LEN]; char connectionName[SYMBOLIC_NAME_LEN]; } list_connections_command; diff --git a/libtransport/src/hicn/transport/interfaces/rtc_socket_producer.cc b/libtransport/src/hicn/transport/interfaces/rtc_socket_producer.cc index c1a45ebb7..f1057aa57 100644 --- a/libtransport/src/hicn/transport/interfaces/rtc_socket_producer.cc +++ b/libtransport/src/hicn/transport/interfaces/rtc_socket_producer.cc @@ -150,8 +150,9 @@ void RTCProducerSocket::produce(std::unique_ptr<utils::MemBuf> &&buffer) { producedBytes_ += (uint32_t)(buffer_size + headerSize_ + TIMESTAMP_LEN); producedPackets_++; + Name n(flowName_); auto content_object = - std::make_shared<ContentObject>(flowName_.setSuffix(currentSeg_.load())); + std::make_shared<ContentObject>(n.setSuffix(currentSeg_.load())); auto payload = utils::MemBuf::create(TIMESTAMP_LEN); memcpy(payload->writableData(), &now, TIMESTAMP_LEN); @@ -340,8 +341,9 @@ void RTCProducerSocket::sendNack(uint32_t sequence) { nack_payload->append(NACK_HEADER_SIZE); ContentObject nack; + Name n(flowName_); nack.appendPayload(std::move(nack_payload)); - nack.setName(flowName_.setSuffix(sequence)); + nack.setName(n.setSuffix(sequence)); uint32_t *payload_ptr = (uint32_t *)nack.getPayload()->data(); *payload_ptr = currentSeg_.load(); diff --git a/libtransport/src/hicn/transport/protocols/manifest_indexing_manager.cc b/libtransport/src/hicn/transport/protocols/manifest_indexing_manager.cc index 9af6a5c3a..05cabc60d 100644 --- a/libtransport/src/hicn/transport/protocols/manifest_indexing_manager.cc +++ b/libtransport/src/hicn/transport/protocols/manifest_indexing_manager.cc @@ -29,6 +29,7 @@ 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), @@ -86,7 +87,14 @@ bool ManifestIndexManager::onManifest( // Set the iterators to the beginning of the suffix queue next_reassembly_segment_ = suffix_queue_.begin(); // Set number of segments in manifests assuming the first one is full - suffix_manifest_.setNbSegments(std::distance(_it, _end) - 1); + suffix_manifest_.setNbSegments( + std::distance(manifest->getSuffixList().begin(), + manifest->getSuffixList().end()) - + 1); + suffix_manifest_.setSuffixStrategy( + manifest->getNextSegmentCalculationStrategy()); + } else if (manifests_in_flight_) { + manifests_in_flight_--; } if (TRANSPORT_EXPECT_FALSE(manifest->isFinalManifest() || @@ -110,6 +118,10 @@ bool ManifestIndexManager::onManifest( // 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(); @@ -132,8 +144,10 @@ bool ManifestIndexManager::onManifest( 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_); + suffix_manifest_.getSuffix() < final_suffix_ && + manifests_in_flight_ < MAX_MANIFESTS_IN_FLIGHT); break; } diff --git a/libtransport/src/hicn/transport/protocols/manifest_indexing_manager.h b/libtransport/src/hicn/transport/protocols/manifest_indexing_manager.h index 5f74ef0bf..74c86eb60 100644 --- a/libtransport/src/hicn/transport/protocols/manifest_indexing_manager.h +++ b/libtransport/src/hicn/transport/protocols/manifest_indexing_manager.h @@ -21,6 +21,9 @@ #include <list> +/* #define MAX_MANIFESTS_IN_FLIGHT std::numeric_limits<uint32_t>::max() */ +#define MAX_MANIFESTS_IN_FLIGHT 10 + namespace transport { namespace protocol { @@ -57,6 +60,7 @@ class ManifestIndexManager : public IncrementalIndexManager, void onManifestTimeout(Interest::Ptr &&i); 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 1a3511003..aeee48bac 100644 --- a/libtransport/src/hicn/transport/protocols/rtc.cc +++ b/libtransport/src/hicn/transport/protocols/rtc.cc @@ -505,7 +505,7 @@ void RTCTransportProtocol::scheduleNextInterests() { } void RTCTransportProtocol::sentinelTimer(){ - uint32_t wait = 10; + uint32_t wait = 50; if(pathTable_.find(producerPathLabels_[0]) != pathTable_.end() && pathTable_.find(producerPathLabels_[1]) != pathTable_.end()){ @@ -545,7 +545,7 @@ void RTCTransportProtocol::sentinelTimer(){ uint64_t max_waiting_time = round((pathTable_[producerPathLabels_[1]]->getMinRtt() - pathTable_[producerPathLabels_[0]]->getMinRtt()) + - pathTable_[producerPathLabels_[0]]->getInterArrivalGap()) * 2; + (pathTable_[producerPathLabels_[0]]->getInterArrivalGap() * 10)); if((currentState_ == HICN_RTC_NORMAL_STATE) && (inflightInterestsCount_ >= currentCWin_) && diff --git a/libtransport/src/hicn/transport/utils/suffix_strategy.h b/libtransport/src/hicn/transport/utils/suffix_strategy.h index 99e557380..4358d12f0 100644 --- a/libtransport/src/hicn/transport/utils/suffix_strategy.h +++ b/libtransport/src/hicn/transport/utils/suffix_strategy.h @@ -31,6 +31,11 @@ class SuffixStrategy { return suffix_stragegy_; } + void setSuffixStrategy( + transport::core::NextSegmentCalculationStrategy strategy) { + suffix_stragegy_ = strategy; + } + std::uint32_t getSuffix() { return suffix_; } virtual std::uint32_t getNextSuffix() = 0; |