Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[NS3] updated in the example to cover more execution scenarios
authorLucas Schnorr <Lucas.Schnorr@imag.fr>
Thu, 8 Sep 2011 14:26:21 +0000 (16:26 +0200)
committerLucas Schnorr <Lucas.Schnorr@imag.fr>
Thu, 8 Sep 2011 15:31:45 +0000 (17:31 +0200)
details:
- debug messages added
- timer function is also executed to have a more detailed view
of what is going on during the simulation of NS3 flows

examples/msg/ns3/3links-d-timer.xml [new file with mode: 0644]
examples/msg/ns3/3links-d.xml
examples/msg/ns3/3links-p.xml
examples/msg/ns3/ns3.c
examples/msg/ns3/ns3.tesh

diff --git a/examples/msg/ns3/3links-d-timer.xml b/examples/msg/ns3/3links-d-timer.xml
new file mode 100644 (file)
index 0000000..9caa5cc
--- /dev/null
@@ -0,0 +1,55 @@
+<?xml version='1.0'?>
+<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
+<platform version="3">
+
+  <process host="S1" function="master">
+      <argument value="100000"/>
+      <argument value="C1"/>
+      <argument value="1"/>
+  </process>
+
+  <process host="C1" function="slave">
+    <argument value="1"/>
+  </process>
+
+  <process host="S2" function="master">
+      <argument value="1000000"/>
+      <argument value="C2"/>
+      <argument value="2"/>
+  </process>
+  
+  <process host="C2" function="slave">
+    <argument value="2"/>
+  </process>
+
+   
+  <process host="S3" function="master">
+      <argument value="2000000"/>
+      <argument value="C3"/>
+      <argument value="3"/>
+  </process>
+  
+  <process host="C3" function="slave">
+    <argument value="3"/>
+  </process>
+
+  <process host="S3" function="master" start_time="2.0">
+      <argument value="2000000"/>
+      <argument value="C3"/>
+      <argument value="4"/>
+  </process>
+  
+  <process host="C3" function="slave">
+    <argument value="4"/>
+  </process>
+
+  <process host="C3" function="timer">
+    <argument value="0"/>
+    <argument value=".1"/>
+  </process>
+
+  <process host="C3" function="timer" start_time="2.0">
+    <argument value="0"/>
+    <argument value=".1"/>
+  </process>
+</platform>
index b9a1cf4..40ddeba 100644 (file)
@@ -3,7 +3,7 @@
 <platform version="3">
 
   <process host="S1" function="master">
-      <argument value="100"/>
+      <argument value="100000"/>
       <argument value="C1"/>
       <argument value="1"/>
   </process>
@@ -13,7 +13,7 @@
   </process>
 
   <process host="S2" function="master">
-      <argument value="1000"/>
+      <argument value="1000000"/>
       <argument value="C2"/>
       <argument value="2"/>
   </process>
   <process host="C2" function="slave">
     <argument value="2"/>
   </process>
+
    
-   
-    <process host="S3" function="master">
-      <argument value="2000"/>
+  <process host="S3" function="master">
+      <argument value="2000000"/>
       <argument value="C3"/>
       <argument value="3"/>
   </process>
   <process host="C3" function="slave">
     <argument value="3"/>
   </process>
-     
+
+<!--  <process host="C3" function="timer">
+    <argument value="0"/>
+    <argument value=".1"/>
+  </process>
+    --> 
 </platform>
index 2e1738d..a7e6848 100644 (file)
@@ -19,9 +19,9 @@
    <host id="S3" power="1000000000"/>
    <host id="C3" power="1000000000"/>
  
-   <link id="1" bandwidth="1000" latency="0.01"/>
-   <link id="2" bandwidth="1000" latency="0.01"/>
-   <link id="3" bandwidth="1000" latency="0.01"/>
+   <link id="1" bandwidth="1000000" latency="0.00001"/>
+   <link id="2" bandwidth="1000000" latency="0.00001"/>
+   <link id="3" bandwidth="1000000" latency="0.00001"/>
  
    <route src="S1" dst="C1">
       <link_ctn id="1"/>
index a40a8d5..d0c7456 100644 (file)
@@ -19,7 +19,7 @@ int timer(int argc, char *argv[]);
 MSG_error_t test_all(const char *platform_file,
                      const char *application_file);
 
-int timer_start = 1;
+int timer_start; //set as 1 in the master process
 
 typedef enum {
   PORT_22 = 0,
@@ -49,9 +49,9 @@ int master(int argc, char *argv[])
   //unique id to control statistics
   int id = -1;
 
-  if (argc != 4) {
-    XBT_INFO("Strange number of arguments expected 3 got %d", argc - 1);
-  }
+  xbt_assert(argc==4,"Strange number of arguments expected 3 got %d", argc - 1);
+
+  XBT_DEBUG ("Master started");
 
   /* data size */
   int read;
@@ -81,6 +81,7 @@ int master(int argc, char *argv[])
   }
 
   count_finished++;
+  timer_start = 1 ;
 
   /* time measurement */
   sprintf(id_alias, "%d", id);
@@ -89,7 +90,7 @@ int master(int argc, char *argv[])
   MSG_task_send(todo, id_alias);
   end_time = MSG_get_clock();
 
-
+  XBT_DEBUG ("Finished");
   return 0;
 }                               /* end_of_master */
 
@@ -97,24 +98,26 @@ int master(int argc, char *argv[])
 /** Timer function  */
 int timer(int argc, char *argv[])
 {
-  int sleep_time;
-  int first_sleep;
+  double sleep_time;
+  double first_sleep;
 
-  if (argc != 3) {
-    XBT_INFO("Strange number of arguments expected 2 got %d", argc - 1);
-  }
+  xbt_assert(argc==3,"Strange number of arguments expected 2 got %d", argc - 1);
+
+  sscanf(argv[1], "%lf", &first_sleep);
+  sscanf(argv[2], "%lf", &sleep_time);
 
-  sscanf(argv[1], "%d", &first_sleep);
-  sscanf(argv[2], "%d", &sleep_time);
+  XBT_DEBUG ("Timer started");
 
   if(first_sleep){
       MSG_process_sleep(first_sleep);
   }
 
-  while(timer_start){
+  do {
+    XBT_DEBUG ("Get sleep");
       MSG_process_sleep(sleep_time);
-  }
+  } while(timer_start);
 
+  XBT_DEBUG ("Finished");
   return 0;
 }
 
@@ -127,9 +130,9 @@ int slave(int argc, char *argv[])
   int id = 0;
   char id_alias[10];
 
-  if (argc != 2) {
-    XBT_INFO("Strange number of arguments expected 1 got %d", argc - 1);
-  }
+  xbt_assert(argc==2,"Strange number of arguments expected 1 got %d", argc - 1);
+
+  XBT_DEBUG ("Slave started");
 
   id = atoi(argv[1]);
   sprintf(id_alias, "%d", id);
@@ -155,9 +158,10 @@ int slave(int argc, char *argv[])
                  MSG_task_get_data_size(task),
        masternames[id],
        slavenames[id]);
-
+//  MSG_task_execute(task);
   MSG_task_destroy(task);
 
+  XBT_DEBUG ("Finished");
   return 0;
 }                               /* end_of_slave */
 
index 02c6cb6..4de9f8c 100644 (file)
@@ -12,9 +12,17 @@ p 6hosts 3links
 $ ns3/ns3 ${srcdir:=.}/ns3/3links-p.xml ${srcdir:=.}/ns3/3links-d.xml --cfg=network/model:NS3
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'network/model' to 'NS3'
 > [0.000000] [surf_config/INFO] Switching workstation model to compound since you changed the network and/or cpu model(s)
-> [C1:slave:(2) 0.392000] [msg_test/INFO] FLOW[1] : Receive 100 bytes from S1 to C1
-> [C2:slave:(4) 1.354000] [msg_test/INFO] FLOW[2] : Receive 1000 bytes from S2 to C2
-> [C3:slave:(6) 2.438000] [msg_test/INFO] FLOW[3] : Receive 2000 bytes from S3 to C3
+> [C1:slave:(2) 0.108460] [msg_test/INFO] FLOW[1] : Receive 100000 bytes from S1 to C1
+> [C2:slave:(4) 1.074465] [msg_test/INFO] FLOW[2] : Receive 1000000 bytes from S2 to C2
+> [C3:slave:(6) 2.116464] [msg_test/INFO] FLOW[3] : Receive 2000000 bytes from S3 to C3
+
+$ ns3/ns3 ${srcdir:=.}/ns3/3links-p.xml ${srcdir:=.}/ns3/3links-d-timer.xml --cfg=network/model:NS3
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'network/model' to 'NS3'
+> [0.000000] [surf_config/INFO] Switching workstation model to compound since you changed the network and/or cpu model(s)
+> [C1:slave:(2) 0.108460] [msg_test/INFO] FLOW[1] : Receive 100000 bytes from S1 to C1
+> [C2:slave:(4) 1.074465] [msg_test/INFO] FLOW[2] : Receive 1000000 bytes from S2 to C2
+> [C3:slave:(6) 2.116506] [msg_test/INFO] FLOW[3] : Receive 2000000 bytes from S3 to C3
+> [C3:slave:(7) 4.232762] [msg_test/INFO] FLOW[4] : Receive 2000000 bytes from S3 to C3
 
 p One cluster
 
@@ -28,4 +36,4 @@ p Two clusters
 $ ns3/ns3 ${srcdir:=.}/ns3/Two_clusters.xml ${srcdir:=.}/ns3/Two_clusters-d.xml --cfg=network/model:NS3
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'network/model' to 'NS3'
 > [0.000000] [surf_config/INFO] Switching workstation model to compound since you changed the network and/or cpu model(s)
-> [c-16.me:slave:(2) 0.012453] [msg_test/INFO] FLOW[1] : Receive 100 bytes from c-3.me to c-16.me
\ No newline at end of file
+> [c-16.me:slave:(2) 0.012453] [msg_test/INFO] FLOW[1] : Receive 100 bytes from c-3.me to c-16.me