2 #include "gtnets_simulator.h"
3 #include "gtnets_interface.h"
5 static GTSim* gtnets_sim = 0;
7 // initialize the GTNetS interface and environment
8 int gtnets_initialize(){
10 fprintf(stderr, "gtnets already initialized.\n");
13 gtnets_sim = new GTSim();
17 // adds a link (argument link is just an index starting at 0...
18 // add link 0, add link 1, etc.)
19 int gtnets_add_link(int id, double bandwidth, double latency){
20 return gtnets_sim->add_link(id, bandwidth, latency);
23 // adds a route between a source and a destination as an array of link indices
24 // (note that there is no gtnets_add_network_card(), as we discover them
25 // on the fly via calls to gtnets_add_route()
26 int gtnets_add_route(int src, int dst, int* links, int nlink){
27 return gtnets_sim->add_route(src, dst, links, nlink);
30 // create a new flow on a route
31 // one can attach arbitrary metadata to a flow
32 int gtnets_create_flow(int src, int dst, long datasize, void* metadata){
33 return gtnets_sim->create_flow(src, dst, datasize, metadata);
36 // get the time (double) until a flow completes (the first such flow)
37 // if no flows exist, return -1.0
38 double gtnets_get_time_to_next_flow_completion(){
39 return gtnets_sim->get_time_to_next_flow_completion();
42 // run until a flow completes (returns that flow's metadata)
43 int gtnets_run_until_next_flow_completion(void ***metadata, int *number_of_flows){
44 return gtnets_sim->run_until_next_flow_completion(metadata, number_of_flows);
47 // run for a given time (double)
48 int gtnets_run(Time_t deltat){
49 gtnets_sim->run(deltat);
53 void gtnets_finalize(){
54 if (!gtnets_sim) return;
55 gtnets_sim->finalize();