aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--hicn-light/src/hicn/processor/fibEntry.c10
-rw-r--r--hicn-light/src/hicn/processor/fibEntry.h4
-rw-r--r--hicn-light/src/hicn/processor/messageProcessor.c3
-rw-r--r--hicn-light/src/hicn/strategies/lowLatency.c104
-rw-r--r--hicn-light/src/hicn/strategies/lowLatency.h6
-rw-r--r--hicn-light/src/hicn/strategies/nexthopStateLowLatency.c2
6 files changed, 107 insertions, 22 deletions
diff --git a/hicn-light/src/hicn/processor/fibEntry.c b/hicn-light/src/hicn/processor/fibEntry.c
index 2c41f1c7b..077e33ff3 100644
--- a/hicn-light/src/hicn/processor/fibEntry.c
+++ b/hicn-light/src/hicn/processor/fibEntry.c
@@ -114,7 +114,8 @@ FibEntry *fibEntry_Create(Name *name, strategy_type fwdStrategy) {
if(fwdStrategy == SET_STRATEGY_LOW_LATENCY){
strategyLowLatency_SetStrategy(fibEntry->fwdStrategy,
- fibEntry->forwarder, fibEntry);
+ fibEntry->forwarder, fibEntry,
+ 0, NULL);
}
return fibEntry;
}
@@ -146,7 +147,9 @@ void fibEntry_Release(FibEntry **fibEntryPtr) {
*fibEntryPtr = NULL;
}
-void fibEntry_SetStrategy(FibEntry *fibEntry, strategy_type strategy) {
+void fibEntry_SetStrategy(FibEntry *fibEntry, strategy_type strategy,
+ unsigned related_prefixes_len,
+ Name **related_prefixes) {
StrategyImpl *fwdStrategyImpl;
switch (strategy) {
@@ -171,7 +174,8 @@ void fibEntry_SetStrategy(FibEntry *fibEntry, strategy_type strategy) {
if(strategy == SET_STRATEGY_LOW_LATENCY){
strategyLowLatency_SetStrategy(fwdStrategyImpl,
- fibEntry->forwarder, fibEntry);
+ fibEntry->forwarder, fibEntry,
+ related_prefixes_len, related_prefixes);
}
const NumberSet *nexthops = fibEntry_GetNexthops(fibEntry);
diff --git a/hicn-light/src/hicn/processor/fibEntry.h b/hicn-light/src/hicn/processor/fibEntry.h
index 13f002eb9..9e438b0e6 100644
--- a/hicn-light/src/hicn/processor/fibEntry.h
+++ b/hicn-light/src/hicn/processor/fibEntry.h
@@ -79,7 +79,9 @@ void fibEntry_Release(FibEntry **fibEntryPtr);
*/
FibEntry *fibEntry_Acquire(const FibEntry *fibEntry);
-void fibEntry_SetStrategy(FibEntry *fibEntry, strategy_type strategy);
+void fibEntry_SetStrategy(FibEntry *fibEntry, strategy_type strategy,
+ unsigned related_prefixes_len,
+ Name **related_prefixes);
void fibEntry_AddNexthop(FibEntry *fibEntry, unsigned connectionId);
diff --git a/hicn-light/src/hicn/processor/messageProcessor.c b/hicn-light/src/hicn/processor/messageProcessor.c
index e38a3d558..bdd9c23e8 100644
--- a/hicn-light/src/hicn/processor/messageProcessor.c
+++ b/hicn-light/src/hicn/processor/messageProcessor.c
@@ -390,7 +390,8 @@ void processor_SetStrategy(MessageProcessor *processor, Name *prefix,
Name **related_prefixes){
FibEntry *entry = fib_Contains(processor->fib, prefix);
if (entry != NULL) {
- fibEntry_SetStrategy(entry, strategy);
+ fibEntry_SetStrategy(entry, strategy, related_prefixes_len,
+ related_prefixes);
}
}
diff --git a/hicn-light/src/hicn/strategies/lowLatency.c b/hicn-light/src/hicn/strategies/lowLatency.c
index a96b7b0af..e1d16b39d 100644
--- a/hicn-light/src/hicn/strategies/lowLatency.c
+++ b/hicn-light/src/hicn/strategies/lowLatency.c
@@ -31,7 +31,6 @@
#include <hicn/strategies/lowLatency.h>
#include <hicn/strategies/nexthopStateLowLatency.h>
-#include <hicn/processor/fibEntry.h>
const unsigned STABILITY_FACTOR = 15;
const unsigned MAX_SWITCH_TRY = 10;
@@ -92,7 +91,6 @@ struct strategy_low_latency {
//hash map from sequence number to face id
PARCHashMap *pending_probes_faces;
const Forwarder * forwarder;
- const FibEntry * fibEntry;
PARCEventTimer *sendProbes;
PARCEventTimer *computeBestFace;
uint8_t * probe;
@@ -104,6 +102,8 @@ struct strategy_low_latency {
unsigned rounds_avoiding_multipath;
bool use2paths;
bool avoid_multipath;
+ unsigned related_prefixes_len;
+ Name **related_prefixes;
#ifndef WITH_POLICY
NumberSet *nexthops;
#endif /* ! WITH_POLICY */
@@ -184,9 +184,27 @@ static void strategyLowLatency_SendProbesCB(int fd, PARCEventType which_event,
parcEventTimer_Start(ll->sendProbes, &timeout);
}
+static void strategyLowLatency_SendMapmeUpdate(StrategyLowLatency *ll,
+ const NumberSet * nexthops){
+ MapMe * mapme = forwarder_getMapmeInstance(ll->forwarder);
+ FIB * fib = forwarder_getFib((Forwarder*) ll->forwarder);
+ if(fib != NULL){
+ for(unsigned i = 0; i < ll->related_prefixes_len; i++){
+ FibEntry *fibEntry = fib_MatchName(fib, ll->related_prefixes[i]);
+ if(fibEntry != NULL){
+ mapme_send_updates(mapme, fibEntry, nexthops);
+ }
+ }
+ }
+}
+
static void strategyLowLatency_SelectBestFaces(StrategyLowLatency *ll,
bool new_round){
+ StrategyNexthopStateLL * old_faces[2];
+ old_faces[0] = ll->bestFaces[0];
+ old_faces[1] = ll->bestFaces[1];
+
if(new_round){
ll->round++;
}
@@ -416,7 +434,7 @@ static void strategyLowLatency_SelectBestFaces(StrategyLowLatency *ll,
}
NEW_ROUND:
-#if 1
+#if 0
if(ll->use2paths){
printf("use 2 paths. rtt face %d = %f queue = %f is_lossy = %d,"
"rtt face %d = %f queue = %f is_lossy = %d\n",
@@ -440,16 +458,61 @@ static void strategyLowLatency_SelectBestFaces(StrategyLowLatency *ll,
}
}
#endif
- //update the round only at the end for all the faces
- if(new_round){
- PARCIterator * iterator = parcHashMap_CreateKeyIterator(ll->strategy_state);
- while (parcIterator_HasNext(iterator)) {
- PARCUnsigned *cid = (PARCUnsigned *) parcIterator_Next(iterator);
- strategyNexthopStateLL_StartNewRound((StrategyNexthopStateLL *)
- parcHashMap_Get(ll->strategy_state, cid));
+ //update the round only at the end for all the faces
+ if(new_round){
+ PARCIterator * iterator = parcHashMap_CreateKeyIterator(ll->strategy_state);
+ while (parcIterator_HasNext(iterator)) {
+ PARCUnsigned *cid = (PARCUnsigned *) parcIterator_Next(iterator);
+ strategyNexthopStateLL_StartNewRound((StrategyNexthopStateLL *)
+ parcHashMap_Get(ll->strategy_state, cid));
+ }
+ parcIterator_Release(&iterator);
+ }
+
+ //mapme updates
+ //if ll->bestFaces[0] == NULL we don't have any output faces
+ //so don't need to send any updates since we are disconnected
+ if(ll->related_prefixes_len != 0){
+ if(ll->bestFaces[0] != NULL){
+ NumberSet *out = numberSet_Create();
+ if(old_faces[0] == NULL ||
+ (strategyNexthopStateLL_GetFaceId(ll->bestFaces[0]) !=
+ strategyNexthopStateLL_GetFaceId(old_faces[0]))){
+ //there is a new face 0 so we need a map me update
+ //if ll->bestFaces[1] != NULL we need to send the update
+ //even if it is the same as before
+ numberSet_Add(out,
+ strategyNexthopStateLL_GetFaceId(ll->bestFaces[0]));
+ if(ll->bestFaces[1] != NULL){
+ numberSet_Add(out,
+ strategyNexthopStateLL_GetFaceId(ll->bestFaces[1]));
+ }
+ strategyLowLatency_SendMapmeUpdate(ll,out);
+ }else{
+ if(ll->bestFaces[1] != NULL){
+ if(old_faces[1] == NULL ||
+ (strategyNexthopStateLL_GetFaceId(ll->bestFaces[1]) !=
+ strategyNexthopStateLL_GetFaceId(old_faces[1]))){
+ //send a mapme both with face 0 and face 1
+ numberSet_Add(out,
+ strategyNexthopStateLL_GetFaceId(ll->bestFaces[0]));
+ numberSet_Add(out,
+ strategyNexthopStateLL_GetFaceId(ll->bestFaces[1]));
+ strategyLowLatency_SendMapmeUpdate(ll,out);
+ }
+ }else{
+ if(old_faces[1] != NULL){
+ //in the previuos round we were using two faces, now only one
+ //send update with only face 0
+ numberSet_Add(out,
+ strategyNexthopStateLL_GetFaceId(ll->bestFaces[0]));
+ strategyLowLatency_SendMapmeUpdate(ll,out);
+ }
+ }
}
- parcIterator_Release(&iterator);
+ numberSet_Release(&out);
}
+ }
}
static void strategyLowLatency_BestFaceCB(int fd, PARCEventType which_event,
@@ -489,12 +552,13 @@ StrategyImpl *strategyLowLatency_Create() {
}
void strategyLowLatency_SetStrategy(StrategyImpl *strategy,
- const Forwarder * forwarder,
- const FibEntry * fibEntry){
+ const Forwarder * forwarder,
+ const FibEntry * fibEntry,
+ unsigned related_prefixes_len,
+ Name **related_prefixes) {
StrategyLowLatency *ll =
(StrategyLowLatency *)strategy->context;
ll->forwarder = forwarder;
- ll->fibEntry = fibEntry;
//create probe packet
ll->probe = messageHandler_CreateProbePacket(HF_INET6_TCP, PROBE_LIFETIME);
@@ -515,6 +579,12 @@ void strategyLowLatency_SetStrategy(StrategyImpl *strategy,
ll->use2paths = false;
ll->avoid_multipath = false;
+ ll->related_prefixes_len = related_prefixes_len;
+ ll->related_prefixes = malloc(sizeof(Name *) * ll->related_prefixes_len);
+ for(unsigned i = 0; i < ll->related_prefixes_len; i++){
+ ll->related_prefixes[i] = name_Copy(related_prefixes[i]);
+ }
+
ll->computeBestFace = dispatcher_CreateTimer(dispatcher, false,
strategyLowLatency_BestFaceCB, ll);
}
@@ -755,6 +825,12 @@ static void _strategyLowLatency_ImplDestroy(StrategyImpl **strategyPtr) {
parcMemory_Deallocate(&(strategy->probe));
parcMemory_Deallocate(&(strategy->name));
+
+ for(unsigned i = 0; i < strategy->related_prefixes_len; i++){
+ name_Release(&(strategy->related_prefixes[i]));
+ }
+ free(strategy->related_prefixes);
+
#ifndef WITH_POLICY
numberSet_Release(&(strategy->nexthops));
#endif /* ! WITH_POLICY */
diff --git a/hicn-light/src/hicn/strategies/lowLatency.h b/hicn-light/src/hicn/strategies/lowLatency.h
index f82a576f1..736c8783d 100644
--- a/hicn-light/src/hicn/strategies/lowLatency.h
+++ b/hicn-light/src/hicn/strategies/lowLatency.h
@@ -26,6 +26,8 @@
StrategyImpl *strategyLowLatency_Create();
void strategyLowLatency_SetStrategy(StrategyImpl *strategy,
- const Forwarder * forwarder,
- const FibEntry * fibEntry);
+ const Forwarder * forwarder,
+ const FibEntry * fibEntry,
+ unsigned related_prefixes_len,
+ Name **related_prefixes);
#endif // lowLatency_h
diff --git a/hicn-light/src/hicn/strategies/nexthopStateLowLatency.c b/hicn-light/src/hicn/strategies/nexthopStateLowLatency.c
index fd83bb072..a3953987f 100644
--- a/hicn-light/src/hicn/strategies/nexthopStateLowLatency.c
+++ b/hicn-light/src/hicn/strategies/nexthopStateLowLatency.c
@@ -31,7 +31,7 @@ const unsigned MAX_ROUNS_WITHOUT_PROBES = 4;
const unsigned MIN_NON_LOSSY_ROUNDS = 10;
//number of rounds in non lossy mode before switch to
//no lossy state
-const double MAX_LOSS_RATE = 0.15; //15%
+const double MAX_LOSS_RATE = 0.10; //10%
struct strategy_nexthop_state_ll {
bool in_use;