1 /* Copyright (c) 2013-2015. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
7 #ifndef NETWORK_ROUTING_HPP_
8 #define NETWORK_ROUTING_HPP_
11 #include <xbt/signal.hpp>
13 #include "surf_interface.hpp"
16 XBT_PUBLIC(void) routing_model_create( void *loopback);
26 class XBT_PRIVATE RoutingModelDescription;
27 class XBT_PRIVATE Onelink;
30 /** @ingroup SURF_routing_interface
31 * @brief A network card
32 * @details This represents a position in the network. One can route information between two netcards
37 virtual int getId()=0;
38 virtual int *getIdPtr()=0;
39 virtual void setId(int id)=0;
40 virtual char *getName()=0;
41 virtual As *getRcComponent()=0;
42 virtual e_surf_network_element_type_t getRcType()=0;
45 /** @ingroup SURF_routing_interface
46 * @brief The Autonomous System (AS) routing interface
51 xbt_dynar_t p_indexNetworkElm;
52 xbt_dict_t p_bypassRoutes; /* store bypass routes */
53 routing_model_description_t p_modelDesc;
54 e_surf_routing_hierarchy_t p_hierarchy;
57 xbt_dict_t p_routingSons;
59 xbt_dynar_t p_linkUpDownList;
62 * @brief The As constructor
67 * @brief The As destructor
76 * @brief Get the route and latency between two RoutingEdges
77 * @details [long description]
79 * @param src [description]
80 * @param dst [description]
81 * @param into [description]
82 * @param latency [description]
84 virtual void getRouteAndLatency(
85 NetCard *src, NetCard *dst,
86 sg_platf_route_cbarg_t into, double *latency)=0;
87 virtual xbt_dynar_t getOneLinkRoutes()=0;
88 virtual void getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges)=0;
89 virtual sg_platf_route_cbarg_t getBypassRoute(
90 NetCard *src, NetCard *dst,
93 /* The parser calls the following functions to inform the routing models
94 * that a new element is added to the AS currently built.
96 * Of course, only the routing model of this AS is informed, not every ones */
97 virtual int parsePU(NetCard *elm)=0; /* A host or a router, whatever */
98 virtual int parseAS(NetCard *elm)=0;
99 virtual void parseRoute(sg_platf_route_cbarg_t route)=0;
100 virtual void parseASroute(sg_platf_route_cbarg_t route)=0;
101 virtual void parseBypassroute(sg_platf_route_cbarg_t e_route)=0;
104 struct XBT_PRIVATE NetCardImpl : public NetCard {
106 NetCardImpl(char *name, int id, e_surf_network_element_type_t rcType, As *rcComponent)
107 : p_rcComponent(rcComponent), p_rcType(rcType), m_id(id), p_name(name) {}
108 ~NetCardImpl() { xbt_free(p_name);};
110 int getId() {return m_id;}
111 int *getIdPtr() {return &m_id;}
112 void setId(int id) {m_id = id;}
113 char *getName() {return p_name;}
114 As *getRcComponent() {return p_rcComponent;}
115 e_surf_network_element_type_t getRcType() {return p_rcType;}
118 e_surf_network_element_type_t p_rcType;
123 /** @ingroup SURF_routing_interface
124 * @brief Link of lenght 1, alongside with its source and destination. This is mainly usefull in the ns3 bindings
128 Onelink(void *link, NetCard *src, NetCard *dst)
129 : p_src(src), p_dst(dst), p_link(link) {};
135 /** @ingroup SURF_routing_interface
136 * @brief The class representing a whole routing platform
138 XBT_PUBLIC_CLASS RoutingPlatf {
143 xbt_dynar_t p_lastRoute;
144 xbt_dynar_t getOneLinkRoutes(void);
145 xbt_dynar_t recursiveGetOneLinkRoutes(As *rc);
146 void getRouteAndLatency(NetCard *src, NetCard *dst, xbt_dynar_t * links, double *latency);
153 XBT_PUBLIC_DATA(simgrid::xbt::signal<void(NetCard*)>) routingEdgeCreatedCallbacks;
154 XBT_PUBLIC_DATA(simgrid::xbt::signal<void(As*)>) asCreatedCallbacks;
159 #endif /* NETWORK_ROUTING_HPP_ */