diff options
author | michele papalini <micpapal@cisco.com> | 2019-12-10 13:40:16 +0100 |
---|---|---|
committer | michele papalini <micpapal@cisco.com> | 2020-01-21 10:26:25 +0100 |
commit | 43980f3096655df2b2ecec50e700dd6989b0e0d6 (patch) | |
tree | 1a8e23e6fe645d8d1951b84f14e4123f17d4efe9 /hicn-light/src/hicn/processor | |
parent | de13ed1c3155f699cb1e322dcd4d64a06ae00bb9 (diff) |
[HICN-442] new forwarding strategy
Signed-off-by: michele papalini <micpapal@cisco.com>
Change-Id: I62c03bddedc83e523fc60f4b50d2c69e38b50318
Signed-off-by: Angelo Mantellini <angelo.mantellini@cisco.com>
Signed-off-by: michele papalini <micpapal@cisco.com>
Diffstat (limited to 'hicn-light/src/hicn/processor')
-rw-r--r-- | hicn-light/src/hicn/processor/fib.c | 6 | ||||
-rw-r--r-- | hicn-light/src/hicn/processor/fib.h | 2 | ||||
-rw-r--r-- | hicn-light/src/hicn/processor/fibEntry.c | 75 | ||||
-rw-r--r-- | hicn-light/src/hicn/processor/fibEntry.h | 10 | ||||
-rw-r--r-- | hicn-light/src/hicn/processor/messageProcessor.c | 69 | ||||
-rw-r--r-- | hicn-light/src/hicn/processor/pitStandard.c | 7 |
6 files changed, 90 insertions, 79 deletions
diff --git a/hicn-light/src/hicn/processor/fib.c b/hicn-light/src/hicn/processor/fib.c index c67bc6773..8822134fe 100644 --- a/hicn-light/src/hicn/processor/fib.c +++ b/hicn-light/src/hicn/processor/fib.c @@ -200,8 +200,10 @@ void fib_Add(FIB *fib, FibEntry *entry) { nameBitvector_clear(name_GetContentName(inner_prefix), match_len); name_setLen(inner_prefix, match_len); - FibEntry * inner_entry = fibEntry_Create(inner_prefix, SET_STRATEGY_LOADBALANCER, - fib->forwarder); + //this is an inner node, we don't want an acctive strategy + //like low_latency that sends probes in this node + FibEntry * inner_entry = fibEntry_Create(inner_prefix, + SET_STRATEGY_LOADBALANCER, fib->forwarder); FibNode * inner_node = _createNode(NULL, NULL, inner_entry, false); FibNode * new_node = _createNode(NULL, NULL, entry, true); diff --git a/hicn-light/src/hicn/processor/fib.h b/hicn-light/src/hicn/processor/fib.h index 7507bb85c..ef9e121b8 100644 --- a/hicn-light/src/hicn/processor/fib.h +++ b/hicn-light/src/hicn/processor/fib.h @@ -23,7 +23,7 @@ struct fib; typedef struct fib FIB; -FIB *fib_Create(); +FIB *fib_Create(Forwarder *forwarder); void fib_Destroy(FIB **fibPtr); diff --git a/hicn-light/src/hicn/processor/fibEntry.c b/hicn-light/src/hicn/processor/fibEntry.c index fe32ada8d..be7278987 100644 --- a/hicn-light/src/hicn/processor/fibEntry.c +++ b/hicn-light/src/hicn/processor/fibEntry.c @@ -22,9 +22,8 @@ #include <hicn/core/nameBitvector.h> #include <hicn/strategies/loadBalancer.h> -#include <hicn/strategies/loadBalancerWithPD.h> +#include <hicn/strategies/lowLatency.h> #include <hicn/strategies/rnd.h> -#include <hicn/strategies/rndSegment.h> #include <hicn/strategies/strategyImpl.h> #ifdef WITH_MAPME #include <parc/algol/parc_HashMap.h> @@ -80,34 +79,23 @@ FibEntry *fibEntry_Create(Name *name, strategy_type fwdStrategy) { sizeof(FibEntry)); fibEntry->name = name_Acquire(name); - if (fwdStrategy) { - switch (fwdStrategy) { - case SET_STRATEGY_LOADBALANCER: - fibEntry->fwdStrategy = strategyLoadBalancer_Create(); - break; - - case SET_STRATEGY_RANDOM: - fibEntry->fwdStrategy = strategyRnd_Create(); - break; - - case SET_STRATEGY_RANDOM_PER_DASH_SEGMENT: - fibEntry->fwdStrategy = strategyRndSegment_Create(); - break; - - case SET_STRATEGY_LOADBALANCER_WITH_DELAY: - fibEntry->fwdStrategy = strategyLoadBalancerWithPD_Create(); - break; - - default: - // LB is the default strategy - fibEntry->fwdStrategy = strategyLoadBalancer_Create(); - // the LB strategy is the default one - // other strategies can be set using the appropiate function - break; - } + switch (fwdStrategy) { + case SET_STRATEGY_LOADBALANCER: + fibEntry->fwdStrategy = strategyLoadBalancer_Create(); + break; - } else { - fibEntry->fwdStrategy = strategyLoadBalancer_Create(); + case SET_STRATEGY_RANDOM: + fibEntry->fwdStrategy = strategyRnd_Create(); + + case SET_STRATEGY_LOW_LATENCY: + fibEntry->fwdStrategy = strategyLowLatency_Create(); + break; + + default: + // LB is the default strategy + fwdStrategy = SET_STRATEGY_LOADBALANCER; + fibEntry->fwdStrategy = strategyLoadBalancer_Create(); + break; } fibEntry->refcount = 1; @@ -124,6 +112,10 @@ FibEntry *fibEntry_Create(Name *name, strategy_type fwdStrategy) { fibEntry->policy_counters = POLICY_COUNTERS_NONE; #endif /* WITH_POLICY */ + if(fwdStrategy == SET_STRATEGY_LOW_LATENCY){ + strategyLowLatency_SetStrategy(fibEntry->fwdStrategy, + fibEntry->forwarder, fibEntry); + } return fibEntry; } @@ -166,20 +158,20 @@ void fibEntry_SetStrategy(FibEntry *fibEntry, strategy_type strategy) { fwdStrategyImpl = strategyRnd_Create(); break; - case SET_STRATEGY_RANDOM_PER_DASH_SEGMENT: - fwdStrategyImpl = strategyRndSegment_Create(); - break; - - case SET_STRATEGY_LOADBALANCER_WITH_DELAY: - fwdStrategyImpl = strategyLoadBalancerWithPD_Create(); + case SET_STRATEGY_LOW_LATENCY: + fwdStrategyImpl = strategyLowLatency_Create(); break; default: - // LB is the defualt strategy + // LB is the default strategy + strategy = SET_STRATEGY_LOADBALANCER; fwdStrategyImpl = strategyLoadBalancer_Create(); - // the LB strategy is the default one - // other strategies can be set using the appropiate function break; + } + + if(strategy == SET_STRATEGY_LOW_LATENCY){ + strategyLowLatency_SetStrategy(fwdStrategyImpl, + fibEntry->forwarder, fibEntry); } const NumberSet *nexthops = fibEntry_GetNexthops(fibEntry); @@ -613,7 +605,9 @@ void fibEntry_ReceiveObjectMessage(FibEntry *fibEntry, void fibEntry_ReceiveObjectMessage(const FibEntry *fibEntry, #endif /* WITH_POLICY */ const NumberSet *egressId, - const Message *objectMessage, Ticks rtt) { + const Message *objectMessage, + Ticks pitEntryCreation, + Ticks objReception) { parcAssertNotNull(fibEntry, "Parameter fibEntry must be non-null"); #ifdef WITH_POLICY @@ -622,6 +616,7 @@ void fibEntry_ReceiveObjectMessage(const FibEntry *fibEntry, /* Update statistic counters : */ size_t msg_size = message_Length(objectMessage); + Ticks rtt = objReception - pitEntryCreation; for (unsigned i = 0; i < numberSet_Length(egressId); i++) { unsigned conn_id = numberSet_GetItem(egressId, i); @@ -666,7 +661,7 @@ void fibEntry_ReceiveObjectMessage(const FibEntry *fibEntry, #endif /* WITH_POLICY */ fibEntry->fwdStrategy->receiveObject(fibEntry->fwdStrategy, egressId, - objectMessage, rtt); + objectMessage, pitEntryCreation, objReception); } #ifdef WITH_POLICY diff --git a/hicn-light/src/hicn/processor/fibEntry.h b/hicn-light/src/hicn/processor/fibEntry.h index 7ec771b4c..1bd917bc2 100644 --- a/hicn-light/src/hicn/processor/fibEntry.h +++ b/hicn-light/src/hicn/processor/fibEntry.h @@ -110,7 +110,9 @@ void fibEntry_ReceiveObjectMessage(FibEntry *fibEntry, void fibEntry_ReceiveObjectMessage(const FibEntry *fibEntry, #endif /* WITH_POLICY */ const NumberSet *egressId, - const Message *objectMessage, Ticks rtt); + const Message *objectMessage, + Ticks pitEntryCreation, + Ticks objReception); #ifdef WITH_POLICY policy_t fibEntry_GetPolicy(const FibEntry *fibEntry); @@ -125,16 +127,10 @@ void fibEntry_OnTimeout(FibEntry *fibEntry, const NumberSet *egressId); const NumberSet *fibEntry_GetNexthopsFromForwardingStrategy( FibEntry *fibEntry, const Message *interestMessage, bool is_retransmission); -void fibEntry_ReceiveObjectMessage(FibEntry *fibEntry, - const NumberSet *egressId, - const Message *objectMessage, Ticks rtt); #else void fibEntry_OnTimeout(const FibEntry *fibEntry, const NumberSet *egressId); const NumberSet *fibEntry_GetNexthopsFromForwardingStrategy( const FibEntry *fibEntry, const Message *interestMessage); -void fibEntry_ReceiveObjectMessage(const FibEntry *fibEntry, - const NumberSet *egressId, - const Message *objectMessage, Ticks rtt); #endif /* WITH_POLICY */ 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 <hicn/content_store/contentStoreLRU.h> #include <hicn/strategies/loadBalancer.h> -#include <hicn/strategies/loadBalancerWithPD.h> +#include <hicn/strategies/lowLatency.h> #include <hicn/strategies/rnd.h> -#include <hicn/strategies/rndSegment.h> #include <hicn/strategies/strategyImpl.h> #include <hicn/io/streamConnection.h> @@ -48,6 +47,7 @@ #include <hicn/utils/utils.h> #include <hicn/utils/address.h> +#include <hicn/core/messageHandler.h> #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 diff --git a/hicn-light/src/hicn/processor/pitStandard.c b/hicn-light/src/hicn/processor/pitStandard.c index edf0b5e98..d4961cdba 100644 --- a/hicn-light/src/hicn/processor/pitStandard.c +++ b/hicn-light/src/hicn/processor/pitStandard.c @@ -159,7 +159,6 @@ static PITVerdict _pitStandard_ReceiveInterest(PIT *generic, ") and reverse path, forwarding", (void *)interestMessage, pitEntry_GetExpiryTime(pitEntry)); } - #ifdef WITH_POLICY return PITVerdict_Retransmit; #else @@ -215,12 +214,10 @@ static NumberSet *_pitStandard_SatisfyInterest(PIT *generic, // PIT entry is not expired, use it FibEntry *fibEntry = pitEntry_GetFibEntry(pitEntry); if (fibEntry != NULL) { - // this is a rough estimation of the residual RTT - Ticks rtt = forwarder_GetTicks(pit->forwarder) - - pitEntry_GetCreationTime(pitEntry); fibEntry_ReceiveObjectMessage(fibEntry, pitEntry_GetEgressSet(pitEntry), objectMessage, - rtt); // need to implement RTT + forwarder_GetTicks(pit->forwarder), + pitEntry_GetCreationTime(pitEntry)); } const NumberSet *is = pitEntry_GetIngressSet(pitEntry); numberSet_AddSet(ingressSet, is); // with this we do a copy so we can |