Hi, I'm a new user of ns3, and i'm having some troubles with nsclick. I
started to create small networks to get familiar with nsclick, and after
this, i will try to create a data center network. Basically, i tried to
expand the example nsclick-routing.cc. I'm using 4 hosts and 2 routers, in
this way:

                (10.0.k.x)
               Host2   Host3
  (2.2)   (3.2)
            (2.X)\      /(3.X)
   (2.1)  (3.1)
                  Router2
                   (4.2)
                (4.X)|
                   (4.1)
                  Router1
                (0.2)  (1.2)
            (0.x)/      \(1.X)
                (0.1)  (1.1)
              Host0    Host1

The host 0 sends udps to host 3, and the host 3 should make an echo of the
udps. However, the router 1 isn't passing the udps.
If, anyone could help me, i would be very grateful.


-- 
*Márcia Manuela M. Nunes*
Undergraduate Student | Communication Networks Engineering
University of Brasilia - UnB
email:  [email protected]   |  [email protected]

Attachment: node0.click
Description: Binary data

Attachment: node1.click
Description: Binary data

Attachment: node2.click
Description: Binary data

Attachment: node3.click
Description: Binary data

Attachment: node4.click
Description: Binary data

Attachment: node5.click
Description: Binary data

//
//                (10.0.k.x)
//               Host2   Host3
// 		 (2.2)   (3.2) 
//            (2.X)\      /(3.X)    
// 		  (2.1)  (3.1) 
//                  Router2
//                   (4.2)   
//                (4.X)|
//                   (4.1)
//                  Router1     
//                (0.2)  (1.2)
//            (0.x)/      \(1.X)         
//                (0.1)  (1.1)
//              Host0    Host1               
//
//
//
//


#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/internet-module.h"
#include "ns3/applications-module.h"
#include "ns3/csma-module.h"
#include "ns3/ipv4-click-routing.h"
#include "ns3/ipv4-l3-click-protocol.h"
#include "ns3/click-internet-stack-helper.h"
#include "ns3/flow-monitor-helper.h"
#include "ns3/flow-monitor.h"


using namespace ns3;

NS_LOG_COMPONENT_DEFINE ("NsclickRouting");

int
main (int argc, char *argv[])
{
#ifdef NS3_CLICK

//
// Explicitly create the nodes required by the topology (shown above).
//
  NS_LOG_INFO ("Create nodes.");
  
  NodeContainer n;
  n.Create (6);
/*
  NodeContainer n0;
  n0.Create (1);
  NodeContainer n1;
  n1.Create (1);
  NodeContainer n2;
  n2.Create (1);
  NodeContainer n3;
  n3.Create (1);
  NodeContainer n4;
  n4.Create (1);
  NodeContainer n5;
  n5.Create (1);
*/
//
// Install Click on the nodes
//
  ClickInternetStackHelper clickinternet;
  clickinternet.SetClickFile (n.Get (0), "scratch/node0.click");
  clickinternet.SetClickFile (n.Get (1), "scratch/node1.click");
  clickinternet.SetClickFile (n.Get (2), "scratch/node2.click");
  clickinternet.SetClickFile (n.Get (3), "scratch/node3.click");
  clickinternet.SetClickFile (n.Get (4), "scratch/node4.click");
  clickinternet.SetClickFile (n.Get (5), "scratch/node5.click");
  clickinternet.SetRoutingTableElement (n.Get (0), "kernel/rt");
  clickinternet.SetRoutingTableElement (n.Get (1), "kernel/rt");
  clickinternet.SetRoutingTableElement (n.Get (2), "kernel/rt");
  clickinternet.SetRoutingTableElement (n.Get (3), "kernel/rt");
  clickinternet.SetRoutingTableElement (n.Get (4), "u/rt");
  clickinternet.SetRoutingTableElement (n.Get (5), "u/rt");
  clickinternet.Install (n);

  NS_LOG_INFO ("Create channels.");
//
// Explicitly create the channels required by the topology (shown above).
//
  NodeContainer l0R1 = NodeContainer(n.Get (0),n.Get (4));
  NodeContainer l1R1 = NodeContainer(n.Get (1),n.Get (4));
  NodeContainer lR1R2 = NodeContainer(n.Get (4),n.Get (5));
  NodeContainer l2R2 = NodeContainer(n.Get (5),n.Get (2));
  NodeContainer l3R2 = NodeContainer(n.Get (5),n.Get (3));

  CsmaHelper csma;
  csma.SetChannelAttribute ("DataRate", DataRateValue (DataRate (5000000)));
  csma.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (2)));
  csma.SetDeviceAttribute ("Mtu", UintegerValue (1400));
  
  NetDeviceContainer d0R1 = csma.Install (l0R1);
  NetDeviceContainer d1R1 = csma.Install (l1R1);
  NetDeviceContainer dR1R2 = csma.Install (lR1R2);
  NetDeviceContainer d2R2 = csma.Install (l2R2);
  NetDeviceContainer d3R2 = csma.Install (l3R2);
  
   Ipv4AddressHelper ipv4;		
//
// We've got the "hardware" in place.  Now we need to add IP addresses.
//
  NS_LOG_INFO ("Assign IP Addresses.");
  ipv4.SetBase ("10.0.0.0", "255.255.255.0");
  Ipv4InterfaceContainer i0R1 = ipv4.Assign (d0R1);

  ipv4.SetBase ("10.0.1.0", "255.255.255.0");
  Ipv4InterfaceContainer i1R1 = ipv4.Assign (d1R1);

  ipv4.SetBase ("10.0.2.0", "255.255.255.0");
  Ipv4InterfaceContainer i2R2 = ipv4.Assign (d2R2);

  ipv4.SetBase ("10.0.3.0", "255.255.255.0");
  Ipv4InterfaceContainer i3R2 = ipv4.Assign (d3R2);

  ipv4.SetBase ("10.0.4.0", "255.255.255.0");
  Ipv4InterfaceContainer iR1R2 = ipv4.Assign (dR1R2);

  NS_LOG_INFO ("Create Applications.");
//
// Create one udpServer applications on node one.
//
  uint16_t port = 4000;
  UdpEchoServerHelper server (port);
  ApplicationContainer apps = server.Install (n.Get (3));
  apps.Start (Seconds (1.0));
  apps.Stop (Seconds (10.0));

//
// Create one UdpClient application to send UDP datagrams from node zero to
// node two.
//
  uint32_t MaxPacketSize = 1024;
  Time interPacketInterval = Seconds (0.05);
  uint32_t maxPacketCount = 320;
  UdpEchoClientHelper client (i3R2.GetAddress (1), port);
  client.SetAttribute ("MaxPackets", UintegerValue (maxPacketCount));
  client.SetAttribute ("Interval", TimeValue (interPacketInterval));
  client.SetAttribute ("PacketSize", UintegerValue (MaxPacketSize));
  apps = client.Install (NodeContainer (n.Get (0)));
  apps.Start (Seconds (2.0));
  apps.Stop (Seconds (10.0));
  
  csma.EnablePcap ("router", d0R1, false);
  csma.EnablePcap ("router", d1R1, false);
  csma.EnablePcap ("router", d2R2, false);
  csma.EnablePcap ("router", d3R2, false);
  csma.EnablePcap ("router", dR1R2, false);

//
// Now, do the actual simulation.
//
  NS_LOG_INFO ("Run Simulation.");
  Simulator::Stop (Seconds (20.0));
  Simulator::Run ();
  Simulator::Destroy ();
  NS_LOG_INFO ("Done.");
#else
  NS_FATAL_ERROR ("Can't use ns-3-click without NSCLICK compiled in");
#endif
}
_______________________________________________
click mailing list
[email protected]
https://amsterdam.lcs.mit.edu/mailman/listinfo/click

Reply via email to