X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/7c878c7f73356568b2cf6c801d90e44a08a1e233..f4ae32c676421a6cd5c076b273dd7a07f2695957:/src/surf/gtnets/gtnets_interface.cc diff --git a/src/surf/gtnets/gtnets_interface.cc b/src/surf/gtnets/gtnets_interface.cc index c3626a4417..4207edbf0f 100644 --- a/src/surf/gtnets/gtnets_interface.cc +++ b/src/surf/gtnets/gtnets_interface.cc @@ -1,3 +1,8 @@ +/* $Id$ */ +/* Copyright (c) 2007 Kayo Fujiwara. All rights reserved. */ + +/* This program is free software; you can redistribute it and/or modify it + * under the terms of the license (GNU LGPL) which comes with this package. */ #include "gtnets_simulator.h" #include "gtnets_interface.h" @@ -11,22 +16,34 @@ int gtnets_initialize(){ return -1; } gtnets_sim = new GTSim(); - return 1; + return 0; } -// adds a link (argument link is just an index starting at 0... +// add a link (argument link is just an index starting at 0... // add link 0, add link 1, etc.) int gtnets_add_link(int id, double bandwidth, double latency){ return gtnets_sim->add_link(id, bandwidth, latency); } -// adds a route between a source and a destination as an array of link indices +// add a route between a source and a destination as an array of link indices // (note that there is no gtnets_add_network_card(), as we discover them // on the fly via calls to gtnets_add_route() int gtnets_add_route(int src, int dst, int* links, int nlink){ return gtnets_sim->add_route(src, dst, links, nlink); } +// add a router +int gtnets_add_router(int id){ + return gtnets_sim->add_router(id); +} + +// add a route between a source and a destination as an array of link indices +// (note that there is no gtnets_add_network_card(), as we discover them +// on the fly via calls to gtnets_add_route() +int gtnets_add_onehop_route(int src, int dst, int link){ + return gtnets_sim->add_onehop_route(src, dst, link); +} + // create a new flow on a route // one can attach arbitrary metadata to a flow int gtnets_create_flow(int src, int dst, long datasize, void* metadata){ @@ -36,24 +53,56 @@ int gtnets_create_flow(int src, int dst, long datasize, void* metadata){ // get the time (double) until a flow completes (the first such flow) // if no flows exist, return -1.0 double gtnets_get_time_to_next_flow_completion(){ - return gtnets_sim->get_time_to_next_flow_completion(); + ofstream file; + double value; + file.open ("/dev/null"); + streambuf* sbuf = cout.rdbuf(); + cout.rdbuf(file.rdbuf()); + + value = gtnets_sim->get_time_to_next_flow_completion(); + + cout.rdbuf(sbuf); + + return value; } // run until a flow completes (returns that flow's metadata) int gtnets_run_until_next_flow_completion(void ***metadata, int *number_of_flows){ - return gtnets_sim->run_until_next_flow_completion(metadata, number_of_flows); + ofstream file; + double value; + file.open ("/dev/null"); + streambuf* sbuf = cout.rdbuf(); + cout.rdbuf(file.rdbuf()); + + value = gtnets_sim->run_until_next_flow_completion(metadata, number_of_flows); + + cout.rdbuf(sbuf); + + return value; } +// get the total received in bytes using the TCPServer object totRx field +double gtnets_get_flow_rx(void *metadata){ + return gtnets_sim->gtnets_get_flow_rx(metadata); +} + + // run for a given time (double) int gtnets_run(Time_t deltat){ gtnets_sim->run(deltat); + return 0; } // clean up -void gtnets_finalize(){ - if (!gtnets_sim) return; - gtnets_sim->finalize(); +int gtnets_finalize(){ + if (!gtnets_sim) return -1; delete gtnets_sim; gtnets_sim = 0; + return 0; +} + +// print topology +void gtnets_print_topology(void){ + gtnets_sim->print_topology(); }