scratch/nsclick-test.cc
changeset 6317 709aa60c053b
parent 6316 cbe2eca6eff3
child 6318 36ff3fb7ca8b
equal deleted inserted replaced
6316:cbe2eca6eff3 6317:709aa60c053b
     1 #include "ns3/core-module.h"
       
     2 #include "ns3/common-module.h"
       
     3 #include "ns3/node-module.h"
       
     4 #include "ns3/helper-module.h"
       
     5 #include "ns3/log.h"
       
     6 #include "ns3/ipv4-click-routing.h"
       
     7 
       
     8 using namespace ns3;
       
     9 
       
    10 
       
    11 void testme1(Ptr<Ipv4ClickRouting> cr)
       
    12 {
       
    13 //  cr->TestInit ();
       
    14 }
       
    15 
       
    16 /*
       
    17 void testme1(Ptr<Ipv4ClickRouting> cr)
       
    18 {
       
    19   NS_LOG_UNCOND ("TESTME: " << Simulator::Now ());
       
    20 
       
    21   cr->SendToExtRouter ();
       
    22 }*/
       
    23 
       
    24 int main (int argc, char *argv[])
       
    25 {
       
    26 
       
    27   NodeContainer clickNodes;
       
    28 
       
    29   clickNodes.Create (2);
       
    30 
       
    31   CsmaHelper csma1;
       
    32   csma1.SetChannelAttribute ("DataRate", DataRateValue (DataRate (5000000)));
       
    33   csma1.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (2)));
       
    34 
       
    35   NetDeviceContainer devices1 = csma1.Install (clickNodes);
       
    36 /*
       
    37   CsmaHelper csma2;
       
    38   csma2.SetChannelAttribute ("DataRate", DataRateValue (DataRate (5000000)));
       
    39   csma2.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (2)));
       
    40 
       
    41   NetDeviceContainer devices2 = csma2.Install (clickNodes);
       
    42 */
       
    43   InternetStackHelper internet;
       
    44   internet.Install (clickNodes);
       
    45 
       
    46   Ipv4AddressHelper ipv4;
       
    47   ipv4.SetBase ("172.16.1.0", "255.255.255.0");
       
    48   ipv4.Assign (devices1);
       
    49 //  ipv4.Assign (devices2);
       
    50 
       
    51   Ptr<Ipv4> stack = clickNodes.Get (0)->GetObject<Ipv4> ();
       
    52 
       
    53   Ptr<Ipv4ClickRouting> click = Create<Ipv4ClickRouting>();
       
    54   click->SetClickFile ("nsclick-simple-lan.click");
       
    55   click->SetNodeName ("Node0");
       
    56 
       
    57   stack->SetRoutingProtocol (click);
       
    58 
       
    59   click->DoStart ();
       
    60 //  click->TestInit ();
       
    61 
       
    62   csma1.EnablePcap ("nsclick-test", devices1, false);
       
    63 
       
    64 
       
    65   Simulator::Schedule (Seconds (10.0), &testme1, click);
       
    66 //  Simulator::Schedule (Seconds (20.0), &testme2, test);
       
    67 
       
    68   Simulator::Stop (Seconds (20.0));
       
    69   Simulator::Run ();
       
    70   Simulator::Destroy ();
       
    71   return 0;
       
    72 }