As::~As()
{
xbt_dict_free(&sons_);
- xbt_dynar_free(&p_indexNetworkElm);
+ xbt_dynar_free(&vertices_);
xbt_dynar_free(&upDownLinks);
xbt_free(name_);
if (netcard_)
int As::addComponent(NetCard *elm) {
XBT_DEBUG("Load component \"%s\"", elm->getName());
- xbt_dynar_push_as(p_indexNetworkElm, NetCard*, elm);
- return xbt_dynar_length(p_indexNetworkElm)-1;
+ xbt_dynar_push_as(vertices_, NetCard*, elm);
+ return xbt_dynar_length(vertices_)-1;
}
}} // namespace simgrid::surf
xbt_dynar_t surf_AS_get_hosts(simgrid::surf::As *as)
{
- xbt_dynar_t elms = as->p_indexNetworkElm;
+ xbt_dynar_t elms = as->vertices_;
int count = xbt_dynar_length(elms);
xbt_dynar_t res = xbt_dynar_new(sizeof(sg_host_t), NULL);
for (int index = 0; index < count; index++) {
class RoutingPlatf;
/** @ingroup SURF_routing_interface
- * @brief A network card
+ * @brief Network cards are the vertices in the graph representing the network, used to compute paths between nodes.
+ *
* @details This represents a position in the network. One can route information between two netcards
*/
class NetCard {
public:
virtual ~NetCard(){};
- virtual int getId()=0;
+ virtual int getId()=0; // Our rank in the vertices_ array of our englobing AS.
virtual int *getIdPtr()=0;
virtual void setId(int id)=0;
virtual char *getName()=0;
As *father_ = nullptr;
xbt_dict_t sons_ = xbt_dict_new_homogeneous(NULL);
- xbt_dynar_t p_indexNetworkElm = xbt_dynar_new(sizeof(char*),NULL); // TODO: What is it?
+ xbt_dynar_t vertices_ = xbt_dynar_new(sizeof(char*),NULL); // our content, as known to our graph routing algorithm (maps vertexId -> vertex)
xbt_dict_t bypassRoutes_ = nullptr;
e_surf_routing_hierarchy_t hierarchy_ = SURF_ROUTING_NULL;
xbt_dynar_t upDownLinks = xbt_dynar_new(sizeof(s_surf_parsing_link_up_down_t),NULL);
/**
- * @brief Get the characteristics of the routing path between two points
+ * @brief Probe the routing path between two points
*
- * This function is used by the networking model to find the information it needs when starting a communication.
+ * The networking model uses this function when creating a communication
+ * to retrieve both the list of links that the create communication will use,
+ * and the summed latency that these links represent.
*
- * The things are not straightforward because the platform can be routed using several routing models.
+ * The network could recompute the latency by itself from the list, but it would
+ * require an additional link set traversal. This operation being on the critical
+ * path of SimGrid, the routing computes the latency in behalf of the network.
+ *
+ * Things are rather complex here because we have to find the path from ASes to ASes, and within each.
+ * In addition, the different ASes may use differing routing models.
* Some ASes may be routed in full, others may have only some connection information and use a shortest path on top of that, and so on.
* Some ASes may even not have any predefined links and use only coordinate informations to compute the latency.
*
*
* @param src Initial point of the routing path
* @param dst Final point of the routing path
- * @param into Container into which the links should be pushed
- * @param latency Accumulator in which the latencies should be added
+ * @param into Container into which the traversed links should be pushed
+ * @param latency Accumulator in which the latencies should be added (caller must set it to 0)
*/
- virtual void getRouteAndLatency(
- NetCard *src, NetCard *dst,
- sg_platf_route_cbarg_t into, double *latency)=0;
+ virtual void getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t into, double *latency)=0;
+ /** @brief retrieves the list of all routes of size 1 (of type src x dst x Link) */
virtual xbt_dynar_t getOneLinkRoutes()=0;
virtual void getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges)=0;
void AsCluster::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges)
{
int isrc;
- int table_size = xbt_dynar_length(p_indexNetworkElm);
+ int table_size = xbt_dynar_length(vertices_);
NetCard *src;
xbt_node_t current, previous, backboneNode = NULL, routerNode;
}
for (isrc = 0; isrc < table_size; isrc++) {
- src = xbt_dynar_get_as(p_indexNetworkElm, isrc, NetCard*);
+ src = xbt_dynar_get_as(vertices_, isrc, NetCard*);
if (src->getRcType() != SURF_NETWORK_ELEMENT_ROUTER) {
previous = new_xbt_graph_node(graph, src->getName(), nodes);
int src,dst;
NetCard *src_elm, *dst_elm;
- int table_size = (int)xbt_dynar_length(p_indexNetworkElm);
+ int table_size = (int)xbt_dynar_length(vertices_);
for(src=0; src < table_size; src++) {
for(dst=0; dst< table_size; dst++) {
xbt_dynar_reset(route->link_list);
- src_elm = xbt_dynar_get_as(p_indexNetworkElm, src, NetCard*);
- dst_elm = xbt_dynar_get_as(p_indexNetworkElm, dst, NetCard*);
+ src_elm = xbt_dynar_get_as(vertices_, src, NetCard*);
+ dst_elm = xbt_dynar_get_as(vertices_, dst, NetCard*);
this->getRouteAndLatency(src_elm, dst_elm,route, NULL);
if (xbt_dynar_length(route->link_list) == 1) {
AsFloyd::~AsFloyd(){
int i, j;
int table_size;
- table_size = (int)xbt_dynar_length(p_indexNetworkElm);
+ table_size = (int)xbt_dynar_length(vertices_);
if (p_linkTable == NULL) // Dealing with a parse error in the file?
return;
/* Delete link_table */
int src,dst;
sg_netcard_t src_elm, dst_elm;
- int table_size = xbt_dynar_length(p_indexNetworkElm);
+ int table_size = xbt_dynar_length(vertices_);
for(src=0; src < table_size; src++) {
for(dst=0; dst< table_size; dst++) {
xbt_dynar_reset(route->link_list);
- src_elm = xbt_dynar_get_as(p_indexNetworkElm, src, NetCard*);
- dst_elm = xbt_dynar_get_as(p_indexNetworkElm, dst, NetCard*);
+ src_elm = xbt_dynar_get_as(vertices_, src, NetCard*);
+ dst_elm = xbt_dynar_get_as(vertices_, dst, NetCard*);
this->getRouteAndLatency(src_elm, dst_elm, route, NULL);
if (xbt_dynar_length(route->link_list) == 1) {
{
/* set utils vars */
- size_t table_size = xbt_dynar_length(p_indexNetworkElm);
+ size_t table_size = xbt_dynar_length(vertices_);
this->srcDstCheck(src, dst);
int as_route = 0;
/* set the size of table routing */
- int table_size = (int)xbt_dynar_length(p_indexNetworkElm);
+ int table_size = (int)xbt_dynar_length(vertices_);
NetCard *src_net_elm, *dst_net_elm;
src_net_elm = sg_netcard_by_name_or_null(src);
unsigned int i, j, a, b, c;
/* set the size of table routing */
- size_t table_size = xbt_dynar_length(p_indexNetworkElm);
+ size_t table_size = xbt_dynar_length(vertices_);
if(!p_linkTable) {
/* Create Cost, Predecessor and Link tables */
sg_platf_route_cbarg_t e_route;
/* set utils vars */
- int table_size = (int)xbt_dynar_length(p_indexNetworkElm);
+ int table_size = (int)xbt_dynar_length(vertices_);
/* Create table if necessary */
if (!p_routingTable)
AsFull::~AsFull(){
if (p_routingTable) {
- int table_size = (int)xbt_dynar_length(p_indexNetworkElm);
+ int table_size = (int)xbt_dynar_length(vertices_);
int i, j;
/* Delete routing table */
for (i = 0; i < table_size; i++)
xbt_dynar_t ret = xbt_dynar_new(sizeof(Onelink*), xbt_free_f);
int src, dst;
- int table_size = xbt_dynar_length(p_indexNetworkElm);
+ int table_size = xbt_dynar_length(vertices_);
for(src=0; src < table_size; src++) {
for(dst=0; dst< table_size; dst++) {
void *link = *(void **) xbt_dynar_get_ptr(route->link_list, 0);
Onelink *onelink;
if (hierarchy_ == SURF_ROUTING_BASE) {
- NetCard *tmp_src = xbt_dynar_get_as(p_indexNetworkElm, src, sg_netcard_t);
+ NetCard *tmp_src = xbt_dynar_get_as(vertices_, src, sg_netcard_t);
tmp_src->setId(src);
- NetCard *tmp_dst = xbt_dynar_get_as(p_indexNetworkElm, dst, sg_netcard_t);
+ NetCard *tmp_dst = xbt_dynar_get_as(vertices_, dst, sg_netcard_t);
tmp_dst->setId(dst);
onelink = new Onelink(link, tmp_src, tmp_dst);
} else if (hierarchy_ == SURF_ROUTING_RECURSIVE)
dst->getId());
/* set utils vars */
- size_t table_size = xbt_dynar_length(p_indexNetworkElm);
+ size_t table_size = xbt_dynar_length(vertices_);
sg_platf_route_cbarg_t e_route = NULL;
void *link;
xbt_assert(src_net_elm, "Network elements %s not found", src);
xbt_assert(dst_net_elm, "Network elements %s not found", dst);
- size_t table_size = xbt_dynar_length(p_indexNetworkElm);
+ size_t table_size = xbt_dynar_length(vertices_);
xbt_assert(!xbt_dynar_is_empty(route->link_list),
"Invalid count of links, must be greater than zero (%s,%s)",
void AsGeneric::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges)
{
int src, dst;
- int table_size = xbt_dynar_length(p_indexNetworkElm);
+ int table_size = xbt_dynar_length(vertices_);
for (src = 0; src < table_size; src++) {
NetCard *my_src =
- xbt_dynar_get_as(p_indexNetworkElm, src, NetCard*);
+ xbt_dynar_get_as(vertices_, src, NetCard*);
for (dst = 0; dst < table_size; dst++) {
if (src == dst)
continue;
NetCard *my_dst =
- xbt_dynar_get_as(p_indexNetworkElm, dst, NetCard*);
+ xbt_dynar_get_as(vertices_, dst, NetCard*);
sg_platf_route_cbarg_t route = xbt_new0(s_sg_platf_route_cbarg_t, 1);
route->link_list = xbt_dynar_new(sizeof(sg_routing_link_t), NULL);