diff --git a/src/pathcomp/.gitignore b/src/pathcomp/.gitignore index 48a680bf0f45eb556108c349bc45be896f4219aa..82fc0ca316f8863947b66c3f294444161902e79c 100644 --- a/src/pathcomp/.gitignore +++ b/src/pathcomp/.gitignore @@ -1 +1,4 @@ backend/wireshark +backend/*.o +backend/pathComp +backend/pathComp-dbg diff --git a/src/pathcomp/backend/pathComp_RESTapi.c b/src/pathcomp/backend/pathComp_RESTapi.c index 1780cfde2039b5907ab0f5696885e17deb56644c..5e22136e7dd753cdf2a7f4a66289be740accb2a7 100644 --- a/src/pathcomp/backend/pathComp_RESTapi.c +++ b/src/pathcomp/backend/pathComp_RESTapi.c @@ -281,7 +281,6 @@ void add_comp_path_deviceId_endpointId_json(cJSON* pathObj, struct path_t* p, st return; } - //////////////////////////////////////////////////////////////////////////////////////// /** * @file pathComp_RESTapi.c @@ -812,12 +811,18 @@ void parsing_json_serviceList_array(cJSON* serviceArray) { parse_service_constraints(constraintArray, service); } - // Get the maximum number of paths to be computed (kPaths) - cJSON* kPathsObj = cJSON_GetObjectItemCaseSensitive(item, "kPaths"); - if (cJSON_IsNumber(kPathsObj)){ - service->kPaths = (guint)(kPathsObj->valuedouble); + // Get the maximum number of paths to be computed (kPaths) inspected/explored + cJSON* kPathsInspObj = cJSON_GetObjectItemCaseSensitive(item, "kPaths_inspection"); + if (cJSON_IsNumber(kPathsInspObj)){ + service->kPaths_inspected = (guint)(kPathsInspObj->valuedouble); } + // Get the maximum number of paths to be computed (kPaths) returned + cJSON* kPathsRetpObj = cJSON_GetObjectItemCaseSensitive(item, "kPaths_return"); + if (cJSON_IsNumber(kPathsRetpObj)){ + service->kPaths_returned = (guint)(kPathsRetpObj->valuedouble); + } + // Append the requested service to the serviceList serviceList = g_list_append(serviceList, service); } diff --git a/src/pathcomp/backend/pathComp_ksp.c b/src/pathcomp/backend/pathComp_ksp.c index 00ebaf5b8b7e0a888720a4092a0d23d75a3eb04b..f5e3c8fb8ea854c9acc9fb9f8bc00e3f34a3141a 100644 --- a/src/pathcomp/backend/pathComp_ksp.c +++ b/src/pathcomp/backend/pathComp_ksp.c @@ -63,15 +63,14 @@ void ksp_alg_execution_services(struct compRouteOutputList_t* outputList) { gint i = 0; for (GList* listnode = g_list_first(serviceList); listnode; - listnode = g_list_next(listnode), i++){ - //struct service_t* service = &(serviceList->services[i]); + listnode = g_list_next(listnode), i++){ struct service_t* service = (struct service_t*)(listnode->data); DEBUG_PC("Starting the Computation for ServiceId: %s [ContextId: %s]", service->serviceId.service_uuid, service->serviceId.contextId); struct compRouteOutput_t* pathService = &(outputList->compRouteConnection[i]); // check endpoints of the service are different (PE devices/nodes are different) if (same_src_dst_pe_nodeid(service) == 0) { - DEBUG_PC("PEs are the same... no path computation"); + DEBUG_PC("PEs are the same... NO PATH COMPUTATION"); comp_route_connection_issue_handler(pathService, service); outputList->numCompRouteConnList++; continue; @@ -84,6 +83,7 @@ void ksp_alg_execution_services(struct compRouteOutputList_t* outputList) { outputList->numCompRouteConnList++; continue; } + alg_comp(service, pathService, g, NO_OPTIMIZATION_ARGUMENT); // last parameter 0 is related to an optimization computation argument outputList->numCompRouteConnList++; @@ -92,7 +92,8 @@ void ksp_alg_execution_services(struct compRouteOutputList_t* outputList) { if (pathService->noPathIssue == NO_PATH_CONS_ISSUE) { continue; } - struct path_t* path = &(pathService->paths[pathService->numPaths - 1]); + // Out of the comnputed paths for the pathservice, the first one is chosen to be locally allocated + struct path_t* path = &(pathService->paths[0]); allocate_graph_resources(path, service, g); allocate_graph_reverse_resources(path, service, g); print_graph(g); @@ -111,8 +112,7 @@ void ksp_alg_execution_services(struct compRouteOutputList_t* outputList) { * @date 2022 */ ///////////////////////////////////////////////////////////////////////////////////////// -gint pathComp_ksp_alg(struct compRouteOutputList_t * routeConnList) -{ +gint pathComp_ksp_alg(struct compRouteOutputList_t * routeConnList) { g_assert(routeConnList); gint numSuccesPathComp = 0, numPathCompIntents = 0; diff --git a/src/pathcomp/backend/pathComp_sp.c b/src/pathcomp/backend/pathComp_sp.c index 48231b591e66ae0f8161ff14f79e7c9a6d832328..b6fd885e3fec7032993ef4d058df8256cc363965 100644 --- a/src/pathcomp/backend/pathComp_sp.c +++ b/src/pathcomp/backend/pathComp_sp.c @@ -143,7 +143,7 @@ void computation_shortest_path(struct service_t* s, struct compRouteOutput_t* pa DEBUG_PC("Computed Path Avail Bw: %f, Path Cost: %f, latency: %f", p->availCap, p->cost, p->delay); print_path(p); - gboolean feasibleRoute = check_computed_path_feasability(s, p); + gboolean feasibleRoute = check_computed_path_feasibility(s, p); if (feasibleRoute == TRUE) { DEBUG_PC("SP Feasible"); print_path(p); @@ -202,37 +202,37 @@ void sp_execution_services(struct compRouteOutputList_t* oPathList) { //struct service_t* service = &(serviceList->services[i]); struct service_t* service = (struct service_t*)(listnode->data); - DEBUG_PC("Starting the Computation for ServiceId: %s [ContextId: %s]", service->serviceId.service_uuid, service->serviceId.contextId); - struct compRouteOutput_t* pathService = &(oPathList->compRouteConnection[i]); - // check endpoints of the service are different (PE devices/nodes are different) - if (same_src_dst_pe_nodeid(service) == 0) { - DEBUG_PC("PEs are the same... no path computation"); - comp_route_connection_issue_handler(pathService, service); - oPathList->numCompRouteConnList++; - continue; - } - - // get the graph associated to the contextId in the contextSet, if no then error - struct graph_t* g = get_graph_by_contextId(contextSet, service->serviceId.contextId); - if (g == NULL) { - DEBUG_PC("The targeted contextId is NOT in the ContextSet ... then NO graph"); - comp_route_connection_issue_handler(pathService, service); - oPathList->numCompRouteConnList++; - continue; - } - - computation_shortest_path(service, pathService, g); - oPathList->numCompRouteConnList++; - - // for each network connectivity service, a single computed path (out of the KCSP) is retuned - // If path is found, then the selected resources must be pre-assigned into the context information - if (pathService->noPathIssue == NO_PATH_CONS_ISSUE) { - continue; - } - struct path_t* path = &(pathService->paths[pathService->numPaths - 1]); - //allocate_graph_resources(path, service, g); // LGR: crashes in some cases with assymetric topos - //allocate_graph_reverse_resources(path, service, g); // LGR: crashes in some cases with assymetric topos - print_graph(g); + DEBUG_PC("Starting the Computation for ServiceId: %s [ContextId: %s]", service->serviceId.service_uuid, service->serviceId.contextId); + struct compRouteOutput_t* pathService = &(oPathList->compRouteConnection[i]); + // check endpoints of the service are different (PE devices/nodes are different) + if (same_src_dst_pe_nodeid(service) == 0) { + DEBUG_PC("PEs are the same... no path computation"); + comp_route_connection_issue_handler(pathService, service); + oPathList->numCompRouteConnList++; + continue; + } + + // get the graph associated to the contextId in the contextSet, if no then error + struct graph_t* g = get_graph_by_contextId(contextSet, service->serviceId.contextId); + if (g == NULL) { + DEBUG_PC("The targeted contextId is NOT in the ContextSet ... then NO graph"); + comp_route_connection_issue_handler(pathService, service); + oPathList->numCompRouteConnList++; + continue; + } + + computation_shortest_path(service, pathService, g); + oPathList->numCompRouteConnList++; + + // for each network connectivity service, a single computed path (out of the KCSP) is retuned + // If path is found, then the selected resources must be pre-assigned into the context information + if (pathService->noPathIssue == NO_PATH_CONS_ISSUE) { + continue; + } + struct path_t* path = &(pathService->paths[pathService->numPaths - 1]); + //allocate_graph_resources(path, service, g); // LGR: crashes in some cases with assymetric topos + //allocate_graph_reverse_resources(path, service, g); // LGR: crashes in some cases with assymetric topos + print_graph(g); } return; } diff --git a/src/pathcomp/backend/pathComp_tools.c b/src/pathcomp/backend/pathComp_tools.c index e7b91ee9e5a8a0a1c28344d17247e307238ed4c7..bd4f7df8ca460e3bab3bb3d9f75e7592f19268c7 100644 --- a/src/pathcomp/backend/pathComp_tools.c +++ b/src/pathcomp/backend/pathComp_tools.c @@ -1459,8 +1459,7 @@ void modify_targeted_graph (struct graph_t *g, struct path_set_t *A, struct comp * @date 2022 */ ///////////////////////////////////////////////////////////////////////////////////////// -gint find_nodeId (gconstpointer data, gconstpointer userdata) -{ +gint find_nodeId (gconstpointer data, gconstpointer userdata) { /** check values */ g_assert(data != NULL); g_assert(userdata != NULL); @@ -1470,8 +1469,7 @@ gint find_nodeId (gconstpointer data, gconstpointer userdata) //DEBUG_PC ("SNodeId (%s) nodeId (%s)", SNodeId->node.nodeId, nodeId); - if (!memcmp(SNodeId->node.nodeId, nodeId, strlen (SNodeId->node.nodeId))) - { + if (!memcmp(SNodeId->node.nodeId, nodeId, strlen (SNodeId->node.nodeId))) { return (0); } return -1; @@ -1500,13 +1498,13 @@ gint check_link (struct nodeItem_t *u, gint indexGraphU, gint indexGraphV, struc g_assert(g); g_assert(s); g_assert(mapNodes); struct targetNodes_t *v = &(g->vertices[indexGraphU].targetedVertices[indexGraphV]); - DEBUG_PC("Explored Link %s => %s)", u->node.nodeId, v->tVertice.nodeId); + DEBUG_PC("=======================CHECK Edge %s => %s =================================", u->node.nodeId, v->tVertice.nodeId); //DEBUG_PC("\t %s => %s", u->node.nodeId, v->tVertice.nodeId); // v already explored in S? then, discard it GList *found = g_list_find_custom (*S, v->tVertice.nodeId, find_nodeId); if (found != NULL) { - DEBUG_PC ("v (%s) in S, Discard", v->tVertice.nodeId); + DEBUG_PC ("%s in S, DISCARD", v->tVertice.nodeId); return 0; } @@ -1523,10 +1521,11 @@ gint check_link (struct nodeItem_t *u, gint indexGraphU, gint indexGraphV, struc DEBUG_PC("EDGE %s[%s] => %s[%s]", u->node.nodeId, e->aEndPointId, v->tVertice.nodeId, e->zEndPointId); //DEBUG_PC ("\t %s[%s] =>", u->node.nodeId, e->aEndPointId); //DEBUG_PC("\t => %s[%s]", v->tVertice.nodeId, e->zEndPointId); - DEBUG_PC("\t AvailBw: %f, TotalBw: %f", edgeAvailBw, edgeTotalBw); + DEBUG_PC("\t Edge Att: AvailBw: %f, TotalBw: %f", edgeAvailBw, edgeTotalBw); // Check Service Bw constraint - if ((path_constraints->bw == TRUE) && (edgeAvailBw < path_constraints->bwConstraint)) + if ((path_constraints->bw == TRUE) && (edgeAvailBw < path_constraints->bwConstraint)) { continue; + } else { foundAvailBw = 1; break; @@ -1534,7 +1533,7 @@ gint check_link (struct nodeItem_t *u, gint indexGraphU, gint indexGraphV, struc } // BW constraint NOT MET, then DISCARD edge if ((path_constraints->bw == TRUE) && (foundAvailBw == 0)) { - DEBUG_PC ("AvailBw: %f < path_constraint: %f -- Discard Edge", edgeAvailBw, path_constraints->bwConstraint); + DEBUG_PC ("Edge AvailBw: %f < path_constraint: %f -- DISCARD Edge", edgeAvailBw, path_constraints->bwConstraint); g_free(path_constraints); return 0; } @@ -1580,13 +1579,14 @@ gint check_link (struct nodeItem_t *u, gint indexGraphU, gint indexGraphV, struc if (arg & ENERGY_EFFICIENT_ARGUMENT) { if (distance_through_u == v_map->distance) { if (power_through_u > v_map->power) { - DEBUG_PC("Energy (src -> u + u -> v: %f (Watts) >Energy (src, v): %f (Watts)--> DISCARD LINK", power_through_u, v_map->power); + DEBUG_PC("Energy (src -> u + u -> v: %f (Watts) > Energy (src, v): %f (Watts) --> DISCARD EDGE", power_through_u, v_map->power); return 0; } // same energy consumption, consider latency if ((power_through_u == v_map->power) && (latency_through_u > v_map->latency)) { return 0; } + // same energy, same latency, criteria: choose the one having the largest available bw if ((power_through_u == v_map->power) && (latency_through_u == v_map->latency) && (availBw_through_u < v_map->avaiBandwidth)) { return 0; } @@ -1603,8 +1603,9 @@ gint check_link (struct nodeItem_t *u, gint indexGraphU, gint indexGraphV, struc return 0; } } - DEBUG_PC ("%s --> %s Relaxed", u->node.nodeId, v->tVertice.nodeId); - DEBUG_PC ("\t AvailBw: %f Mb/s, Cost: %f, Latency: %f ms, Energy: %f Watts", availBw_through_u, distance_through_u, latency_through_u, power_through_u); + DEBUG_PC ("Edge %s --> %s [RELAXED]", u->node.nodeId, v->tVertice.nodeId); + DEBUG_PC ("\t path till %s: AvailBw: %f Mb/s | Cost: %f | Latency: %f ms | Energy: %f Watts", v->tVertice.nodeId, availBw_through_u, distance_through_u, + latency_through_u, power_through_u); // Update Q list -- struct nodeItem_t *nodeItem = g_malloc0 (sizeof (struct nodeItem_t)); @@ -1621,8 +1622,9 @@ gint check_link (struct nodeItem_t *u, gint indexGraphU, gint indexGraphV, struc if (arg & ENERGY_EFFICIENT_ARGUMENT) { *Q = g_list_insert_sorted(*Q, nodeItem, sort_by_energy); } - else + else { *Q = g_list_insert_sorted (*Q, nodeItem, sort_by_distance); + } // Update the mapNodes for the specific reached tv v_map->distance = distance_through_u; @@ -1634,9 +1636,9 @@ gint check_link (struct nodeItem_t *u, gint indexGraphU, gint indexGraphV, struc struct edges_t *e1 = &(v_map->predecessor); struct edges_t *e2 = &(v->edges[indexEdge]); duplicate_edge(e1, e2); - DEBUG_PC ("u->v Edge: %s(%s) --> %s(%s)", e2->aNodeId.nodeId, e2->aEndPointId, e2->zNodeId.nodeId, e2->zEndPointId); + //DEBUG_PC ("u->v Edge: %s(%s) --> %s(%s)", e2->aNodeId.nodeId, e2->aEndPointId, e2->zNodeId.nodeId, e2->zEndPointId); //DEBUG_PC("v-pred aTopology: %s", e2->aTopologyId); - DEBUG_PC("v-pred zTopology: %s", e2->zTopologyId); + //DEBUG_PC("v-pred zTopology: %s", e2->zTopologyId); // Check whether v is dstPEId //DEBUG_PC ("Targeted dstId: %s", s->service_endpoints_id[1].device_uuid); @@ -1658,7 +1660,7 @@ gint check_link (struct nodeItem_t *u, gint indexGraphU, gint indexGraphV, struc * @date 2022 */ ///////////////////////////////////////////////////////////////////////////////////////// -gboolean check_computed_path_feasability (struct service_t *s, struct compRouteOutputItem_t* p) { +gboolean check_computed_path_feasibility (struct service_t *s, struct compRouteOutputItem_t* p) { float epsilon = 0.0000001; struct path_constraints_t* pathCons = get_path_constraints(s); gboolean ret = TRUE; @@ -2345,7 +2347,7 @@ void build_contextSet_linklList(GList** set, gint activeFlag) { // for each link in linkList: // 1st- Retrieve endpoints A --> B feauture (context Id, device Id, endpoint Id) // 2st - In the graph associated to the contextId, check wheter A (deviceId) is in the vertices list - // o No, this is weird ... exist + // o No, this is weird ... exit // o Yes, get the other link endpoint (i.e., B) and check whether it exists. If NOT add it, considering // all the attributes; Otherwise, check whether the link is different from existing edges between A and B gdouble epsilon = 0.1; @@ -3064,7 +3066,7 @@ void dijkstra(gint srcMapIndex, gint dstMapIndex, struct graph_t* g, struct serv // if ingress of the root link (aNodeId) is the spurNode, then stops if (compare_node_id(&re->aNodeId, SN) == 0) { - DEBUG_PC("root Link: aNodeId: %s and spurNode: %s -- stop exploring the rootPath (RP)", re->aNodeId.nodeId, SN->nodeId); + DEBUG_PC("Ingress Node rootLink %s = spurNode %s; STOP exploring rootPath (RP)", re->aNodeId.nodeId, SN->nodeId); break; } // Extract from Q @@ -3072,7 +3074,6 @@ void dijkstra(gint srcMapIndex, gint dstMapIndex, struct graph_t* g, struct serv struct nodeItem_t* node = (struct nodeItem_t*)(listnode->data); Q = g_list_remove(Q, node); - //DEBUG_RL_RA ("Exploring node %s", node->node.nodeId); indexVertice = graph_vertice_lookup(node->node.nodeId, g); g_assert(indexVertice >= 0); @@ -3086,22 +3087,21 @@ void dijkstra(gint srcMapIndex, gint dstMapIndex, struct graph_t* g, struct serv } // Check that the first node in Q set is SpurNode, otherwise something went wrong ... if (compare_node_id(&re->aNodeId, SN) != 0) { - //DEBUG_PC ("root Link: aNodeId: %s is NOT the spurNode: %s -- something wrong", re->aNodeId.nodeId, SN->nodeId); + DEBUG_PC ("root Link: aNodeId: %s is NOT the spurNode: %s -- something wrong", re->aNodeId.nodeId, SN->nodeId); g_list_free_full(g_steal_pointer(&S), g_free); g_list_free_full(g_steal_pointer(&Q), g_free); return; } } - while (g_list_length(Q) > 0) { //Extract from Q set GList* listnode = g_list_first(Q); struct nodeItem_t* node = (struct nodeItem_t*)(listnode->data); Q = g_list_remove(Q, node); DEBUG_PC("Q length: %d", g_list_length(Q)); - DEBUG_PC("DeviceId: %s", node->node.nodeId); + DEBUG_PC("Explored DeviceId: %s", node->node.nodeId); - // visit all the links from u within the graph + // scan all the links from u within the graph indexVertice = graph_vertice_lookup(node->node.nodeId, g); g_assert(indexVertice >= 0); @@ -3139,18 +3139,19 @@ gint ksp_comp(struct pred_t* pred, struct graph_t* g, struct service_t* s, struct map_nodes_t* mapNodes, guint arg) { g_assert(pred); g_assert(g); g_assert(s); - DEBUG_PC("Source: %s -- Destination: %s", s->service_endpoints_id[0].device_uuid, s->service_endpoints_id[1].device_uuid); + DEBUG_PC("SOURCE: %s --> DESTINATION: %s", s->service_endpoints_id[0].device_uuid, + s->service_endpoints_id[1].device_uuid); // Check the both ingress src and dst endpoints are in the graph gint srcMapIndex = get_map_index_by_nodeId(s->service_endpoints_id[0].device_uuid, mapNodes); if (srcMapIndex == -1) { - DEBUG_PC("ingress DeviceId: %s NOT in the graph", s->service_endpoints_id[0].device_uuid); + DEBUG_PC("ingress DeviceId: %s NOT in G", s->service_endpoints_id[0].device_uuid); return -1; } gint dstMapIndex = get_map_index_by_nodeId(s->service_endpoints_id[1].device_uuid, mapNodes); if (dstMapIndex == -1) { - DEBUG_PC("egress DeviceId: %s NOT in the graph", s->service_endpoints_id[1].device_uuid); + DEBUG_PC("egress DeviceId: %s NOT in G", s->service_endpoints_id[1].device_uuid); return -1; } @@ -3164,17 +3165,17 @@ gint ksp_comp(struct pred_t* pred, struct graph_t* g, struct service_t* s, gint map_dstIndex = get_map_index_by_nodeId(s->service_endpoints_id[1].device_uuid, mapNodes); struct map_t* dest_map = &mapNodes->map[map_dstIndex]; if (!(dest_map->distance < INFINITY_COST)) { - DEBUG_PC("destination: %s NOT reachable", s->service_endpoints_id[1].device_uuid); + DEBUG_PC("DESTINATION: %s NOT reachable", s->service_endpoints_id[1].device_uuid); return -1; } DEBUG_PC("AvailBw @ %s is %f", dest_map->verticeId.nodeId, dest_map->avaiBandwidth); // Check that the computed available bandwidth is larger than 0.0 if (dest_map->avaiBandwidth <= (gfloat)0.0) { - DEBUG_PC("dst: %s NOT REACHABLE", s->service_endpoints_id[1].device_uuid); + DEBUG_PC("DESTINATION %s NOT REACHABLE", s->service_endpoints_id[1].device_uuid); return -1; } - DEBUG_PC("dst: %s REACHABLE", s->service_endpoints_id[1].device_uuid); + DEBUG_PC("DESTINATION %s REACHABLE", s->service_endpoints_id[1].device_uuid); // Handle predecessors build_predecessors(pred, s, mapNodes); return 1; @@ -3219,6 +3220,18 @@ void set_path_attributes(struct compRouteOutputItem_t* p, struct map_t* mapV) { void alg_comp(struct service_t* s, struct compRouteOutput_t* path, struct graph_t* g, guint arg) { g_assert(s); g_assert(path); g_assert(g); + // Check if the service specifies a nuumber of K paths to be explored/computed for the + // service. If not, compute that number; otherwise set the max number of explored + // computed paths to MAX_KSP_VALUE + guint maxK = 0; + if(s->kPaths_inspected == 0) { + maxK = MAX_KSP_VALUE; + } + else { + maxK = s->kPaths_inspected; + } + DEBUG_PC("The KSP considers K: %d", maxK); + // create map of devices/nodes to handle the path computation using the context struct map_nodes_t* mapNodes = create_map_node(); build_map_node(mapNodes, g); @@ -3228,6 +3241,9 @@ void alg_comp(struct service_t* s, struct compRouteOutput_t* path, struct graph_ struct service_endpoints_id_t* iEp = &(s->service_endpoints_id[0]); struct service_endpoints_id_t* eEp = &(s->service_endpoints_id[1]); + DEBUG_PC("======================================================================================="); + DEBUG_PC("STARTING PATH COMP FOR %s[%s] --> %s[%s]", iEp->device_uuid, iEp->endpoint_uuid, eEp->device_uuid, eEp->endpoint_uuid); + // Compute the 1st KSP path gint done = ksp_comp(predecessors, g, s, NULL, NULL, mapNodes, arg); if (done == -1) { @@ -3260,14 +3276,14 @@ void alg_comp(struct service_t* s, struct compRouteOutput_t* path, struct graph_ } path->num_service_endpoints_id = s->num_service_endpoints_id; - DEBUG_PC("COMPUTE UP TO K Feasible Paths A[%d]", MAX_KSP_VALUE); + DEBUG_PC("COMPUTE UP TO K Feasible Paths A[%d]", maxK); // Create A and B sets of paths to handle the YEN algorithm struct path_set_t *A = create_path_set(), *B = create_path_set(); // Add 1st Computed path into A->paths[0] duplicate_path(p, &A->paths[0]); A->numPaths++; g_free(predecessors); g_free(p); - for (gint k = 1; k < MAX_KSP_VALUE; k++) { + for (gint k = 1; k < maxK; k++) { DEBUG_PC("*************************** kth (%d) ***********************************", k); struct compRouteOutputItem_t* p = create_path_item(); duplicate_path(&A->paths[k - 1], p); @@ -3359,9 +3375,10 @@ void alg_comp(struct service_t* s, struct compRouteOutput_t* path, struct graph_ // copy the service endpoints, in general, there will be 2 (point-to-point network connectivity services) for (gint m = 0; m < s->num_service_endpoints_id; m++) { struct service_endpoints_id_t* iEp = &(s->service_endpoints_id[m]); - struct service_endpoints_id_t* oEp = &(s->service_endpoints_id[m]); + struct service_endpoints_id_t* oEp = &(path->service_endpoints_id[m]); copy_service_endpoint_id(oEp, iEp); } + path->num_service_endpoints_id = s->num_service_endpoints_id; // Print all the paths i A for (gint h = 0; h < A->numPaths; h++) { @@ -3371,27 +3388,33 @@ void alg_comp(struct service_t* s, struct compRouteOutput_t* path, struct graph_ DEBUG_PC("Number of paths: %d", path->numPaths); // For all the computed paths in A, pick the one being feasible wrt the service constraints for (gint ksp = 0; ksp < A->numPaths; ksp++) { - if (ksp >= MAX_KSP_VALUE) { - DEBUG_PC("Number Requested paths (%d) REACHED - STOP", ksp); + if (ksp >= s->kPaths_returned) { + DEBUG_PC("Number Requested/returned paths (%d) REACHED - STOP", ksp); break; } - gdouble feasibleRoute = check_computed_path_feasability(s, &A->paths[ksp]); + gdouble feasibleRoute = check_computed_path_feasibility(s, &A->paths[ksp]); if (feasibleRoute == TRUE) { - DEBUG_PC("A[%d] available: %f, pathCost: %f; latency: %f, Power: %f", ksp, A->paths[ksp].availCap, A->paths[ksp].cost, A->paths[ksp].delay, A->paths[ksp].power); + DEBUG_PC("A[%d] available: %f, pathCost: %f; latency: %f, Power: %f", ksp, A->paths[ksp].availCap, + A->paths[ksp].cost, A->paths[ksp].delay, A->paths[ksp].power); struct compRouteOutputItem_t* pathaux = &A->paths[ksp]; path->numPaths++; struct path_t* targetedPath = &path->paths[path->numPaths - 1]; duplicate_path_t(pathaux, targetedPath); print_path_t(targetedPath); - remove_path_set(A); - remove_path_set(B); - return; + //remove_path_set(A); + //remove_path_set(B); + //return; } } remove_path_set(A); remove_path_set(B); + // At least 1 out (K) paths was found, then K-SP succeded + if (path->numPaths > 0) { + DEBUG_PC("K-SP succeeded"); + return; + } // No paths found --> Issue DEBUG_PC("K-SP failed!!!"); comp_route_connection_issue_handler(path, s); return; -} \ No newline at end of file +} diff --git a/src/pathcomp/backend/pathComp_tools.h b/src/pathcomp/backend/pathComp_tools.h index 84334eb5e1d47199e8a71bb09c3b541625d66af2..49280d543a52ede118a1baee988484671bc76f8d 100644 --- a/src/pathcomp/backend/pathComp_tools.h +++ b/src/pathcomp/backend/pathComp_tools.h @@ -38,7 +38,7 @@ extern GList* activeServList; #define INFINITY_COST 0xFFFFFFFF #define MAX_NUM_PRED 100 -#define MAX_KSP_VALUE 3 +#define MAX_KSP_VALUE 5 // HTTP RETURN CODES #define HTTP_CODE_OK 200 @@ -126,6 +126,7 @@ struct map_nodes_t { #define MAX_NUM_VERTICES 100 // 100 # LGR: reduced from 100 to 20 to divide by 5 the memory used #define MAX_NUM_EDGES 5 // 100 # LGR: reduced from 100 to 5 to divide by 20 the memory used + // Structures for the graph composition struct targetNodes_t { // remote / targeted node @@ -352,11 +353,10 @@ struct constraint_t { #define MAX_NUM_SERVICE_ENPOINTS_ID 2 #define MAX_NUM_SERVICE_CONSTRAINTS 10 -struct service_t { - // Indentifier used to determine the used Algorithm Id, e.g., KSP - gchar algId[MAX_ALG_ID_LENGTH]; - // PATHS expected for the output - guint kPaths; +struct service_t { + gchar algId[MAX_ALG_ID_LENGTH]; // Indentifier used to determine the used Algorithm Id, e.g., KSP + guint kPaths_inspected; // PATHS expected to be inspected + guint kPaths_returned; // Maximum number of PATHS to be returned struct serviceId_t serviceId; guint service_type; // unknown, l2nm, l3nm, tapi @@ -430,7 +430,7 @@ struct pathLink_t { gchar zEndPointId[UUID_CHAR_LENGTH]; struct topology_id_t topologyId; - struct linkTopology_t linkTopologies[2]; // a p2p link (at most) can connect to devices (endpoints) attached to 2 different topologies + struct linkTopology_t linkTopologies[2]; // A p2p link (at most) can connect to devices (endpoints) attached to 2 different topologies gint numLinkTopologies; }; @@ -575,7 +575,7 @@ gboolean matching_path_rootPath (struct compRouteOutputItem_t *, struct compRout void modify_targeted_graph (struct graph_t *, struct path_set_t *, struct compRouteOutputItem_t *, struct nodes_t *); gint find_nodeId (gconstpointer, gconstpointer); gint check_link (struct nodeItem_t *, gint, gint, struct graph_t *, struct service_t *, GList **, GList **, struct map_nodes_t *, guint arg); -gboolean check_computed_path_feasability (struct service_t *, struct compRouteOutputItem_t * ); +gboolean check_computed_path_feasibility (struct service_t *, struct compRouteOutputItem_t * ); gint sort_by_distance (gconstpointer, gconstpointer); gint sort_by_energy(gconstpointer, gconstpointer); @@ -617,4 +617,4 @@ void destroy_context(struct context_t*); void dijkstra(gint, gint, struct graph_t*, struct service_t*, struct map_nodes_t*, struct nodes_t*, struct compRouteOutputItem_t*, guint); void set_path_attributes(struct compRouteOutputItem_t*, struct map_t*); void alg_comp(struct service_t*, struct compRouteOutput_t*, struct graph_t*, guint); -#endif \ No newline at end of file +#endif