--- /dev/null
+#include <stdio.h>
+#include <stdlib.h>
+#include "msg/msg.h"
+/* Create a log channel to have nice outputs. */
+#include "xbt/log.h"
+#include "xbt/asserts.h"
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,"Messages specific for this msg example");
+
+int master(int argc, char *argv[]);
+int slave(int argc, char *argv[]);
+MSG_error_t test_all(const char *platform_file, const char *application_file);
+
+
+typedef enum {
+ PORT_22 = 0,
+ MAX_CHANNEL
+} channel_t;
+
+
+double time=0;
+double task_comm_size=0.0;
+
+#define FINALIZE ((void*)221297) /* a magic number to tell people to stop working */
+
+/** Master */
+int master(int argc, char *argv[]){
+ char *slavename = NULL;
+ m_task_t todo = NULL;
+ m_host_t slave;
+ MSG_error_t a;
+
+ if(argc != 3){
+ xbt_assert1(0, "Invalid number of arguments in master process, expected 4 got %d\n", argc);
+ }
+
+ /* data size */
+ xbt_assert1(sscanf(argv[1],"%lg", &task_comm_size),
+ "Invalid argument %s\n", argv[1]);
+ INFO1("task_comm_size : %f\n", task_comm_size);
+
+ /* slave name */
+ slavename = argv[2];
+
+
+ /* Task creation. */
+ char sprintf_buffer[64] = "Task_0";
+ todo = MSG_task_create(sprintf_buffer, 0, task_comm_size, NULL);
+
+ /* Process organisation */
+ slave = MSG_get_host_by_name(slavename);
+
+ /* Time measurement */
+ time = MSG_get_clock();
+
+ a = MSG_task_put(todo, slave, PORT_22);
+ xbt_assert0(!a,"MSG_task_put failure");
+
+ return 0;
+} /* end_of_master */
+
+
+/** Receiver function */
+int slave(int argc, char *argv[])
+{
+ m_task_t task = NULL;
+ int a;
+
+ a = MSG_task_get(&(task), PORT_22);
+ xbt_assert0(!a, "MSG_task_get failure");
+
+ /* Elapsed time */
+ time = MSG_get_clock() - time;
+
+ INFO1("Total transmission time: %f", time);
+ INFO1("Hockney estimated bandwidth: %f", ((task_comm_size*8)/time)/1000);
+
+ MSG_task_destroy(task);
+ return 0;
+} /* end_of_slave */
+
+
+
+
+/** Test function */
+MSG_error_t test_all(const char *platform_file,
+ const char *application_file){
+ MSG_error_t res = MSG_OK;
+
+ /* Simulation setting */
+ MSG_set_channel_number(MAX_CHANNEL);
+ MSG_paje_output("msg_test.trace");
+ MSG_create_environment(platform_file);
+
+ /* Application deployment */
+ MSG_function_register("master", master);
+ MSG_function_register("slave", slave);
+ MSG_launch_application(application_file);
+
+ res = MSG_main();
+ return res;
+} /* end_of_test_all */
+
+
+/** Main function */
+int main(int argc, char *argv[]){
+ MSG_error_t res = MSG_OK;
+
+ MSG_global_init(&argc,argv);
+ if (argc < 3) {
+ printf ("Usage: %s platform_file deployment_file\n",argv[0]);
+ exit(1);
+ }
+ res = test_all(argv[1],argv[2]);
+
+ MSG_clean();
+
+ if(res==MSG_OK) return 0;
+ else return 1;
+} /* end_of_main */
XBT_PUBLIC(double) MSG_task_get_compute_duration(m_task_t task);
XBT_PUBLIC(double) MSG_task_get_remaining_computation(m_task_t task);
+XBT_PUBLIC(double) MSG_task_get_remaining_communication(m_task_t task);
XBT_PUBLIC(double) MSG_task_get_data_size(m_task_t task);
}
}
+
+
+/** \ingroup m_task_management
+ * \brief Returns the total amount received by a task #m_task_t.
+ *
+ */
+double MSG_task_get_remaining_communication(m_task_t task)
+{
+ xbt_assert0((task != NULL)
+ && (task->simdata != NULL), "Invalid parameter");
+
+ return SIMIX_action_get_remains(task->simdata->comm);
+}
+
/** \ingroup m_task_management
* \brief Returns the size of the data attached to a task #m_task_t.
*
return gtnets_sim->run_until_next_flow_completion(metadata, number_of_flows);
}
+// 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);
int gtnets_create_flow(int src, int dst, long datasize, void* metadata);
double gtnets_get_time_to_next_flow_completion();
int gtnets_run_until_next_flow_completion(void*** metadata, int* number_of_flows);
+ double gtnets_get_flow_rx(void *metadata);
+
int gtnets_run(double delta);
int gtnets_finalize();
sim_ = new Simulator();
topo_ = new GTNETS_Topology();
+ sim_->verbose=false;
// Set default values.
TCP::DefaultAdvWin(wsize);
TCP::DefaultSegSize(1000);
gtnets_servers_[nflow_] = (TCPServer*)gtnets_nodes_[dst_node]->
AddApplication(TCPServer(TCPReno()));
+ //added by arnaud in order to avoid TCPServer duplicates.
+ //It is not needed since we create a new TCPServer for
+ //each flow. Also we need to control this variable
+ //to proper set the value of remaining communication amount.
+ //See functions:
+ gtnets_servers_[nflow_]->copyOnConnect=false;
gtnets_servers_[nflow_]->BindAndListen(80);
gtnets_clients_[nflow_] = (TCPSend*)gtnets_nodes_[src_node]->
AddApplication(TCPSend(metadata, gtnets_nodes_[dst_node]->GetIPAddr(),
80, Constant(datasize), TCPReno()));
+ gtnets_clients_[nflow_]->copyOnConnect=false;
gtnets_clients_[nflow_]->SetSendCallBack(tcp_sent_callback);
gtnets_clients_[nflow_]->Start(0);
+
+ //added by pedro in order to get statistics
+ //map an action from a gtnets flow id
+ //metadata is the action and flow is the id to gtnets
+ gtnets_action_to_flow_[metadata] = nflow_;
nflow_++;
return 0;
Time_t t1;
int pfds[2];
meta_flg=0;
+
+ //remain needs to be updated in the future
+ Count_t remain;
pipe(pfds);
return t1;
}
+double GTSim::gtnets_get_flow_rx(void *metadata){
+ int flow = gtnets_action_to_flow_[metadata];
+ return ((TCPServer *)gtnets_servers_[flow])->totRx;//action_remain[flow];
+}
+
int GTSim::run_until_next_flow_completion(void ***metadata, int *number_of_flows){
meta_flows.clear();
meta_nflow = number_of_flows;
double get_time_to_next_flow_completion();
int run_until_next_flow_completion(void*** metadata, int* number_of_flows);
int run(double deltat);
-
+ //added by pedro, returns the total received by the TCPServer peer of the given action
+ double gtnets_get_flow_rx(void *metadata);
void create_gtnets_topology();
private:
void add_nodes();
int is_topology_;
int nflow_;
- map<int, Linkp2p*> gtnets_links_;
- map<int, Node*> gtnets_nodes_;
map<int, TCPServer*> gtnets_servers_;
map<int, TCPSend*> gtnets_clients_;
+ map<int, Linkp2p*> gtnets_links_;
+ map<int, Node*> gtnets_nodes_;
+ //added by pedro in order to get statistics
+ map<void*, int> gtnets_action_to_flow_;
map<int, void*> gtnets_metadata_;
};