1 /* Copyright (c) 2013-2016. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
6 #ifndef NETWORK_ROUTING_HPP_
7 #define NETWORK_ROUTING_HPP_
10 #include <xbt/signal.hpp>
12 #include "surf_interface.hpp"
13 #include "src/kernel/routing/AsImpl.hpp"
19 XBT_PRIVATE xbt_node_t new_xbt_graph_node (xbt_graph_t graph, const char *name, xbt_dict_t nodes);
20 XBT_PRIVATE xbt_edge_t new_xbt_graph_edge (xbt_graph_t graph, xbt_node_t s, xbt_node_t d, xbt_dict_t edges);
27 XBT_PUBLIC_DATA(simgrid::xbt::signal<void(s4u::As*)>) asCreatedCallbacks;
28 XBT_PUBLIC_DATA(simgrid::xbt::signal<void(NetCard*)>) netcardCreatedCallbacks;
34 class XBT_PRIVATE Onelink;
37 /** @ingroup SURF_routing_interface
38 * @brief Network cards are the vertices in the graph representing the network, used to compute paths between nodes.
40 * @details This represents a position in the network. One can route information between two netcards
48 NetCard(std::string name, NetCard::Type componentType, AsImpl* containingAS)
49 : name_(name), componentType_(componentType), containingAS_(containingAS)
51 if (containingAS != nullptr)
52 id_ = containingAS->addComponent(this);
53 simgrid::kernel::routing::netcardCreatedCallbacks(this);
57 // Our rank in the vertices_ array of our containing AS.
58 unsigned int id() {return id_;}
59 std::string name() { return name_; }
60 const char* cname() { return name_.c_str(); }
61 // This is the AS in which I am
62 AsImpl *containingAS() {return containingAS_;}
64 bool isAS() {return componentType_ == Type::As;}
65 bool isHost() {return componentType_ == Type::Host;}
66 bool isRouter() {return componentType_ == Type::Router;}
72 NetCard::Type componentType_;
73 AsImpl *containingAS_;
78 explicit AsRoute(NetCard* gwSrc, NetCard* gwDst) : gw_src(gwSrc), gw_dst(gwDst) {}
79 const NetCard* gw_src;
80 const NetCard* gw_dst;
81 std::vector<Link*> links;
84 /** @ingroup SURF_routing_interface
85 * @brief Link of length 1, alongside with its source and destination. This is mainly useful in the ns3 bindings
89 Onelink(Link* link, NetCard* src, NetCard* dst) : src_(src), dst_(dst), link_(link){};
97 #endif /* NETWORK_ROUTING_HPP_ */