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/fibEntry.c | 75 +++++++++++++++----------------- 1 file changed, 35 insertions(+), 40 deletions(-) (limited to 'hicn-light/src/hicn/processor/fibEntry.c') 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 #include -#include +#include #include -#include #include #ifdef WITH_MAPME #include @@ -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 -- cgit 1.2.3-korg