surf_network_model->extension.network.communicate = ns3_communicate;
/* Added the initialization for NS3 interface */
- if (ns3_initialize()) {
+
+ if (ns3_initialize(xbt_cfg_get_string(_surf_cfg_set,"ns3/TcpModel"))) {
xbt_die("Impossible to initialize NS3 interface");
}
}
// initialize the NS3 interface and environment
-int ns3_initialize(void){
+int ns3_initialize(const char* TcpProtocol){
xbt_assert(!ns3_sim, "ns3 already initialized");
ns3_sim = new NS3Sim();
- return 0;
+
+// tcpModel are:
+// "ns3::TcpNewReno"
+// "ns3::TcpReno"
+// "ns3::TcpTahoe"
+
+ Config::SetDefault ("ns3::TcpSocket::SegmentSize", UintegerValue (1000)); // 1000-byte packet for easier reading
+ Config::SetDefault ("ns3::TcpSocket::DelAckCount", UintegerValue (1));
+
+ if(!strcmp(TcpProtocol,"default")){
+ return 0;
+ }
+ if(!strcmp(TcpProtocol,"Reno")){
+ XBT_INFO("Switching Tcp protocol to '%s'",TcpProtocol);
+ Config::SetDefault ("ns3::TcpL4Protocol::SocketType", StringValue("ns3::TcpReno"));
+ return 0;
+ }
+ if(!strcmp(TcpProtocol,"NewReno")){
+ XBT_INFO("Switching Tcp protocol to '%s'",TcpProtocol);
+ Config::SetDefault ("ns3::TcpL4Protocol::SocketType", StringValue("ns3::TcpNewReno"));
+ return 0;
+ }
+ if(!strcmp(TcpProtocol,"Tahoe")){
+ XBT_INFO("Switching Tcp protocol to '%s'",TcpProtocol);
+ Config::SetDefault ("ns3::TcpL4Protocol::SocketType", StringValue("ns3::TcpTahoe"));
+ return 0;
+ }
+
+ XBT_ERROR("The ns3/TcpModel must be : NewReno or Reno or Tahoe");
}
void * ns3_add_host(char * id)
#endif
XBT_PUBLIC(int) ns3_finalize(void);
-XBT_PUBLIC(int) ns3_initialize(void);
+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,void * action);
XBT_PUBLIC(void) ns3_simulator(double min);
XBT_PUBLIC(double) ns3_time(void);
void * action)
{
if(!dict_socket) dict_socket = xbt_dict_new();
- PacketSinkHelper sink ("ns3::TcpSocketFactory", InetSocketAddress (Ipv4Address::GetAny(), port_number));
+
+ PacketSinkHelper sink ("ns3::TcpSocketFactory",
+ InetSocketAddress (Ipv4Address::GetAny(),
+ port_number));
sink.Install (dst);
- Ptr<Socket> sock = Socket::CreateSocket (src, TypeId::LookupByName ("ns3::TcpSocketFactory"));
+ Ptr<Socket> sock = Socket::CreateSocket (src,
+ TcpSocketFactory::GetTypeId());
+
MySocket *mysocket = new MySocket();
mysocket->totalBytes = totalBytes;
mysocket->remaining = totalBytes;
#endif
#ifdef HAVE_NS3
{"NS3",
- "TODO",
- NULL, surf_network_model_init_NS3},
+ "Use NS3 tcp model",
+ NULL, surf_network_model_init_NS3},
#endif
{"Reno",
"Model using lagrange_solve instead of lmm_solve (experts only)", NULL,
xbt_cfgelm_int, &default_value_int, 0, 1,
_surf_cfg_cb__gtnets_jitter_seed, NULL);
#endif
-
+#ifdef HAVE_NS3
+ xbt_cfg_register(&_surf_cfg_set, "ns3/TcpModel",
+ "The ns3 tcp model can be : NewReno or Reno or Tahoe",
+ xbt_cfgelm_string, NULL, 1, 1,
+ NULL, NULL);
+ xbt_cfg_setdefault_string(_surf_cfg_set, "ns3/TcpModel", "default");
+#endif
if (!surf_path) {
/* retrieves the current directory of the current process */
const char *initial_path = __surf_get_initial_path();