From 43980f3096655df2b2ecec50e700dd6989b0e0d6 Mon Sep 17 00:00:00 2001 From: michele papalini Date: Tue, 10 Dec 2019 13:40:16 +0100 Subject: [HICN-442] new forwarding strategy Signed-off-by: michele papalini Change-Id: I62c03bddedc83e523fc60f4b50d2c69e38b50318 Signed-off-by: Angelo Mantellini Signed-off-by: michele papalini --- hicn-light/src/hicn/processor/messageProcessor.c | 69 +++++++++++++++--------- 1 file changed, 45 insertions(+), 24 deletions(-) (limited to 'hicn-light/src/hicn/processor/messageProcessor.c') diff --git a/hicn-light/src/hicn/processor/messageProcessor.c b/hicn-light/src/hicn/processor/messageProcessor.c index c989f8cb6..e38a3d558 100644 --- a/hicn-light/src/hicn/processor/messageProcessor.c +++ b/hicn-light/src/hicn/processor/messageProcessor.c @@ -34,9 +34,8 @@ #include #include -#include +#include #include -#include #include #include @@ -48,6 +47,7 @@ #include #include +#include #ifdef WITH_POLICY #define STATS_INTERVAL 1000 /* ms */ @@ -160,7 +160,7 @@ MessageProcessor *messageProcessor_Create(Forwarder *forwarder) { processor->logger = logger_Acquire(forwarder_GetLogger(forwarder)); processor->pit = pitStandard_Create(forwarder); - processor->fib = fib_Create(); + processor->fib = fib_Create(forwarder); if (logger_IsLoggable(processor->logger, LoggerFacility_Processor, PARCLogLevel_Debug)) { @@ -304,18 +304,13 @@ bool messageProcessor_AddOrUpdateRoute(MessageProcessor *processor, control->addressType, &control->address, &control->len); strategy_type fwdStrategy = configuration_GetForwardingStrategy(config, prefixStr); - if (fwdStrategy == LAST_STRATEGY_VALUE) { - fwdStrategy = SET_STRATEGY_LOADBALANCER; - } Name *prefix = name_CreateFromAddress(control->addressType, control->address, control->len); FibEntry *entry = fib_Contains(processor->fib, prefix); - bool newEntry = false; if (entry != NULL) { fibEntry_AddNexthop(entry, ifidx); } else { - newEntry = true; #ifdef WITH_POLICY entry = fibEntry_Create(prefix, fwdStrategy, processor->forwarder); #else @@ -328,14 +323,6 @@ bool messageProcessor_AddOrUpdateRoute(MessageProcessor *processor, free(prefixStr); name_Release(&prefix); - /* For policy implementation, we need access to the ConnectionTable in all - * Forwarding Strategies, so it is setup during FIB Entry creation */ - if (newEntry && (fwdStrategy == SET_STRATEGY_LOADBALANCER_WITH_DELAY)) { - strategyLoadBalancerWithPD_SetConnectionTable( - fibEntry_GetFwdStrategy(entry), - forwarder_GetConnectionTable(processor->forwarder)); - } - return true; } @@ -365,9 +352,6 @@ bool messageProcessor_AddOrUpdatePolicy(MessageProcessor *processor, if (!entry) { strategy_type fwdStrategy = configuration_GetForwardingStrategy(config, prefixStr); - if (fwdStrategy == LAST_STRATEGY_VALUE) { - fwdStrategy = SET_STRATEGY_LOADBALANCER; - } entry = fibEntry_Create(prefix, fwdStrategy, processor->forwarder); fib_Add(processor->fib, entry); } @@ -407,11 +391,6 @@ void processor_SetStrategy(MessageProcessor *processor, Name *prefix, FibEntry *entry = fib_Contains(processor->fib, prefix); if (entry != NULL) { fibEntry_SetStrategy(entry, strategy); - if (strategy == SET_STRATEGY_LOADBALANCER_WITH_DELAY) { - strategyLoadBalancerWithPD_SetConnectionTable( - fibEntry_GetFwdStrategy(entry), - forwarder_GetConnectionTable(processor->forwarder)); - } } } @@ -572,6 +551,34 @@ static bool messageProcessor_ForwardViaFib(MessageProcessor *processor, return false; } + if(messageHandler_IsAProbe(message_FixedHeader(interestMessage))){ + bool reply_to_probe = false; + ConnectionTable * ct = forwarder_GetConnectionTable(processor->forwarder); + const NumberSet * nexthops = fibEntry_GetNexthops(fibEntry); + unsigned size = (unsigned) numberSet_Length(nexthops); + + for (unsigned i = 0; i < size; i++) { + unsigned nhop = numberSet_GetItem(nexthops, i); + Connection *conn = + (Connection *)connectionTable_FindById(ct, nhop); + if (!conn) + continue; + bool isLocal = connection_IsLocal(conn); + if(isLocal){ + Connection * replyConn = + (Connection *)connectionTable_FindById(ct, + message_GetIngressConnectionId(interestMessage)); + connection_HandleProbe(replyConn, + (uint8_t *) message_FixedHeader(interestMessage)); + reply_to_probe = true; + break; + } + } + if(reply_to_probe) + return false; + } + + PitEntry *pitEntry = pit_GetPitEntry(processor->pit, interestMessage); if (pitEntry == NULL) { return false; @@ -709,6 +716,20 @@ static void messageProcessor_ReceiveContentObject(MessageProcessor *processor, (void *)message, processor->stats.countDroppedNoReversePath); } + //if the packet is a probe we need to analyze it + if(messageHandler_IsAProbe(message_FixedHeader(message))){ + FibEntry *fibEntry = fib_MatchMessage(processor->fib, message); + if(fibEntry && + fibEntry_GetFwdStrategyType(fibEntry) == SET_STRATEGY_LOW_LATENCY){ + unsigned connid = message_GetIngressConnectionId(message); + NumberSet *outFace = numberSet_Create(); + numberSet_Add(outFace, connid); + fibEntry_ReceiveObjectMessage(fibEntry, outFace, message, 0, + forwarder_GetTicks(processor->forwarder)); + numberSet_Release(&(outFace)); + } + } + // we store the packets in the content store enven in the case where there // is no match in the PIT table in this way the applications can push the // content in the CS of the forwarder. We allow this only for local faces -- cgit 1.2.3-korg