examples/mixed-wireless.cc
changeset 4036 a17503f15f8c
parent 4035 749cf964666a
child 4037 a8f42518c058
equal deleted inserted replaced
4035:749cf964666a 4036:a17503f15f8c
    67 // Define logging keyword for this file
    67 // Define logging keyword for this file
    68 //
    68 //
    69 NS_LOG_COMPONENT_DEFINE ("MixedWireless");
    69 NS_LOG_COMPONENT_DEFINE ("MixedWireless");
    70 
    70 
    71 //
    71 //
    72 // This function will be used below as a trace sink
    72 // This function will be used below as a trace sink, if the command-line
       
    73 // argument or default value "useCourseChangeCallback" is set to true
    73 // 
    74 // 
    74 #ifdef ENABLE_FOR_TRACING_EXAMPLE
       
    75 static void
    75 static void
    76 CourseChangeCallback (std::string path, Ptr<const MobilityModel> model)
    76 CourseChangeCallback (std::string path, Ptr<const MobilityModel> model)
    77 {
    77 {
    78   Vector position = model->GetPosition ();
    78   Vector position = model->GetPosition ();
    79   std::cout << "CourseChange " << path << " x=" << position.x << ", y=" << position.y << ", z=" << position.z << std::endl;
    79   std::cout << "CourseChange " << path << " x=" << position.x << ", y=" << position.y << ", z=" << position.z << std::endl;
    80 }
    80 }
    81 #endif
       
    82 
    81 
    83 int 
    82 int 
    84 main (int argc, char *argv[])
    83 main (int argc, char *argv[])
    85 {
    84 {
    86   //
    85   //
    89   //
    88   //
    90   uint32_t backboneNodes = 10;
    89   uint32_t backboneNodes = 10;
    91   uint32_t infraNodes = 5;
    90   uint32_t infraNodes = 5;
    92   uint32_t lanNodes = 5;
    91   uint32_t lanNodes = 5;
    93   uint32_t stopTime = 10;
    92   uint32_t stopTime = 10;
       
    93   bool useCourseChangeCallback = false;
    94 
    94 
    95   //
    95   //
    96   // Simulation defaults are typically set next, before command line
    96   // Simulation defaults are typically set next, before command line
    97   // arguments are parsed.
    97   // arguments are parsed.
    98   //
    98   //
   107   CommandLine cmd;
   107   CommandLine cmd;
   108   cmd.AddValue("backboneNodes", "number of backbone nodes", backboneNodes);
   108   cmd.AddValue("backboneNodes", "number of backbone nodes", backboneNodes);
   109   cmd.AddValue ("infraNodes", "number of leaf nodes", infraNodes);
   109   cmd.AddValue ("infraNodes", "number of leaf nodes", infraNodes);
   110   cmd.AddValue("lanNodes", "number of LAN nodes", lanNodes);
   110   cmd.AddValue("lanNodes", "number of LAN nodes", lanNodes);
   111   cmd.AddValue("stopTime", "simulation stop time (seconds)", stopTime);
   111   cmd.AddValue("stopTime", "simulation stop time (seconds)", stopTime);
       
   112   cmd.AddValue("useCourseChangeCallback", "whether to enable course change tracing", useCourseChangeCallback);
   112 
   113 
   113   //
   114   //
   114   // The system global variables and the local values added to the argument
   115   // The system global variables and the local values added to the argument
   115   // system can be overridden by command line arguments by using this call.
   116   // system can be overridden by command line arguments by using this call.
   116   //
   117   //
   344   // Let's do a pcap trace on the backbone devices
   345   // Let's do a pcap trace on the backbone devices
   345   YansWifiPhyHelper::EnablePcap ("mixed-wireless", backboneDevices); 
   346   YansWifiPhyHelper::EnablePcap ("mixed-wireless", backboneDevices); 
   346   // Let's additionally trace the application Sink, ifIndex 0
   347   // Let's additionally trace the application Sink, ifIndex 0
   347   CsmaHelper::EnablePcap ("mixed-wireless", appSink->GetId (), 0);
   348   CsmaHelper::EnablePcap ("mixed-wireless", appSink->GetId (), 0);
   348 
   349 
   349 #ifdef ENABLE_FOR_TRACING_EXAMPLE
   350   if (useCourseChangeCallback == true)
   350   Config::Connect ("/NodeList/*/$MobilityModel/CourseChange",
   351     {
   351     MakeCallback (&CourseChangeCallback));
   352       Config::Connect ("/NodeList/*/$ns3::MobilityModel/CourseChange", MakeCallback (&CourseChangeCallback));
   352 #endif
   353     }
   353 
       
   354 
   354 
   355   /////////////////////////////////////////////////////////////////////////// 
   355   /////////////////////////////////////////////////////////////////////////// 
   356   //                                                                       //
   356   //                                                                       //
   357   // Run simulation                                                        //
   357   // Run simulation                                                        //
   358   //                                                                       //
   358   //                                                                       //