void ns3_simulator(double min){
- ns3_sim->simulator_start(min);
+ ns3_sim->simulator_start(min);
}
simgrid::surf::NetworkNS3Action* ns3_get_socket_action(void *socket){
return ((MySocket *)socket)->sentBytes;
}
-char ns3_get_socket_is_finished(void *socket){
+bool ns3_get_socket_is_finished(void *socket){
return ((MySocket *)socket)->finished;
}
char* addr = (char*)xbt_dynar_get_as(IPV4addr,node2->node_num,char*);
XBT_DEBUG("ns3_create_flow %d Bytes from %d to %d with Interface %s",TotalBytes, node1->node_num, node2->node_num,addr);
- ns3_sim->create_flow_NS3(src_node,
- dst_node,
- port_number,
+ ns3_sim->create_flow_NS3(src_node, dst_node, port_number,
start,
addr,
TotalBytes,
}
// clean up
-int ns3_finalize(void){
- if (!ns3_sim) return -1;
+void ns3_finalize(){
+ if (!ns3_sim)
+ return;
delete ns3_sim;
ns3_sim = 0;
- return 0;
}
// initialize the NS3 interface and environment
SG_BEGIN_DECL()
-XBT_PUBLIC(int) ns3_finalize(void);
+XBT_PUBLIC(void) ns3_finalize();
XBT_PUBLIC(int) ns3_initialize(const char* TcpProtocol);
XBT_PUBLIC(int) ns3_create_flow(const char* a,const char *b,double start,u_int32_t TotalBytes,simgrid::surf::NetworkNS3Action * action);
XBT_PUBLIC(void) ns3_simulator(double min);
XBT_PUBLIC(simgrid::surf::NetworkNS3Action*) ns3_get_socket_action(void *socket);
XBT_PUBLIC(double) ns3_get_socket_remains(void *socket);
XBT_PUBLIC(double) ns3_get_socket_sent(void *socket);
-XBT_PUBLIC(char) ns3_get_socket_is_finished(void *socket);
+XBT_PUBLIC(bool) ns3_get_socket_is_finished(void *socket);
XBT_PUBLIC(void *) ns3_add_host_cluster(const char * id);
XBT_PUBLIC(void *) ns3_add_router(const char * id);
XBT_PUBLIC(void *) ns3_add_AS(const char * id);
MySocket *mysocket = new MySocket();
mysocket->totalBytes = totalBytes;
mysocket->remaining = totalBytes;
- mysocket->bufferedBytes = 0;
- mysocket->sentBytes = 0;
- mysocket->finished = 0;
mysocket->action = action;
transformSocketPtr(sock);
static void receive_callback(Ptr<Socket> localSocket){
MySocket* mysocket = get_my_socket(localSocket);
- if (mysocket->finished == 0){
- mysocket->finished = 1;
+ if (mysocket->finished == false){
+ mysocket->finished = true;
XBT_DEBUG("recv_cb of F[%p, %p, %d]", mysocket, mysocket->action, mysocket->totalBytes);
XBT_DEBUG("Stop simulator at %f seconds", Simulator::Now().GetSeconds());
Simulator::Stop(Seconds(0.0));
#include "ns3/tcp-socket-factory.h"
struct MySocket{
- std::uint32_t bufferedBytes;
- std::uint32_t sentBytes;
+ std::uint32_t bufferedBytes = 0;
+ std::uint32_t sentBytes = 0;
std::uint32_t remaining;
std::uint32_t totalBytes;
- char finished;
+ bool finished = false;
simgrid::surf::NetworkNS3Action* action;
};