--- a/scratch/nsclick-test-full.cc Fri Jun 25 17:53:42 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,137 +0,0 @@
-#include "ns3/core-module.h"
-#include "ns3/common-module.h"
-#include "ns3/node-module.h"
-#include "ns3/helper-module.h"
-#include "ns3/log.h"
-#include "ns3/ipv4-click-routing.h"
-#include "ns3/arp-l3-protocol.h"
-#include "ns3/ipv4-l3-protocol.h"
-#include "ns3/ipv4-l3-click-protocol.h"
-#include "ns3/udp-l4-protocol.h"
-#include "ns3/tcp-l4-protocol.h"
-
-#include <click/simclick.h>
-using namespace ns3;
-
-void ReceivePacket (Ptr<Socket> socket)
-{
- NS_LOG_UNCOND ("Received one packet!");
-}
-
-void
-CreateAndAggregateObjectFromTypeId (Ptr<Node> node, const std::string typeId)
-{
- ObjectFactory factory;
- factory.SetTypeId (typeId);
- Ptr<Object> protocol = factory.Create <Object> ();
- node->AggregateObject (protocol);
-}
-/*
-static void GenerateTraffic (Ptr<Socket> socket, uint32_t pktSize,
- uint32_t pktCount, Time pktInterval )
-{
- if (pktCount > 0)
- {
- socket->Send (Create<Packet> (pktSize));
- Simulator::Schedule (pktInterval, &GenerateTraffic,
- socket, pktSize,pktCount-1, pktInterval);
- }
- else
- {
- socket->Close ();
- }
-}*/
-
-static void
-AddClickInternetStack (Ptr<Node> node)
-{
- // Setup ArpL3Protocol
- Ptr<ArpL3Protocol> arp = CreateObject<ArpL3Protocol> ();
- node->AggregateObject (arp);
-
- // Setup Ipv4L3Protocol
- Ptr<Ipv4L3ClickProtocol> ipv4l3 = CreateObject<Ipv4L3ClickProtocol> ();
- node->AggregateObject (ipv4l3);
-
- // Setup Click instance
- Ptr<Ipv4> ipv4 = node->GetObject<Ipv4> ();
- Ptr<Ipv4ClickRouting> click = CreateObject<Ipv4ClickRouting> ();
- click->SetClickFile ("nsclick-simple-lan.click");
- ipv4->SetRoutingProtocol (click);
-
- Ptr<TcpL4Protocol> udp = CreateObject<TcpL4Protocol> ();
- node->AggregateObject(udp);
-}
-
-
-int main (int argc, char *argv[])
-{
-// double packetSize = 1000;
-// double numPackets = 5;
- Time interPacketInterval = Seconds(1.0);
-
- NodeContainer csmaNodes;
- csmaNodes.Create (2);
-
- CsmaHelper csma;
- csma.SetChannelAttribute ("DataRate", DataRateValue (DataRate (5000000)));
- csma.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (2)));
- NetDeviceContainer csmaDevices = csma.Install (csmaNodes);
-
- InternetStackHelper internet;
- internet.Install (csmaNodes.Get (1));
-
- AddClickInternetStack (csmaNodes.Get (0));
-
- Ipv4AddressHelper ipv4;
- ipv4.SetBase ("172.16.1.0", "255.255.255.0");
- ipv4.Assign (csmaDevices);
-
- Ptr<Ipv4> ipv4click = csmaNodes.Get (0)->GetObject<Ipv4> ();
- Ptr<Ipv4ClickRouting> click = DynamicCast <Ipv4ClickRouting> (ipv4click->GetRoutingProtocol ());
- click->SetClickRoutingTableElement ("u/rt");
- click->DoStart ();
-
-
- Address LocalAddress (InetSocketAddress (Ipv4Address::GetAny (), 50000));
- PacketSinkHelper packetSinkHelper ("ns3::TcpSocketFactory", LocalAddress);
- ApplicationContainer recvapp = packetSinkHelper.Install (csmaNodes.Get (1));
- recvapp.Start (Seconds (5.0));
- recvapp.Stop (Seconds (10.0));
-
- OnOffHelper onOffHelper ("ns3::TcpSocketFactory", Address ());
- onOffHelper.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1)));
- onOffHelper.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0)));
-// onOffHelper.SetAttribute ("PacketSize", UintegerValue (512));
-// onOffHelper.SetAttribute ("MaxBytes", UintegerValue (513));
-
- ApplicationContainer appcont;
-
- AddressValue remoteAddress (InetSocketAddress (Ipv4Address ("172.16.1.2"), 50000));
- onOffHelper.SetAttribute ("Remote", remoteAddress);
- appcont.Add (onOffHelper.Install (csmaNodes.Get (0)));
-
- appcont.Start (Seconds (5.0));
- appcont.Stop (Seconds (10.0));
-
-/*
- TypeId tid = TypeId::LookupByName ("ns3::TcpSocketFactory");
- Ptr<Socket> recvSink = Socket::CreateSocket (csmaNodes.Get(1), tid);
- InetSocketAddress local = InetSocketAddress (Ipv4Address::GetAny (), 80);
- recvSink->Bind (local);
- recvSink->SetRecvCallback (MakeCallback (&ReceivePacket));
-
- Ptr<Socket> source = Socket::CreateSocket (csmaNodes.Get (0), tid);
- InetSocketAddress remote = InetSocketAddress (Ipv4Address ("172.16.1.2"), 80);
- source->Connect (remote);
-
- Simulator::ScheduleWithContext (source->GetNode ()->GetId (),
- Seconds (15.0), &GenerateTraffic,
- source, packetSize, numPackets, interPacketInterval);
-*/
- csma.EnablePcap ("click-test", csmaDevices, false);
-
- Simulator::Stop (Seconds(20.0));
- Simulator::Run();
- return 0;
-}
--- a/scratch/nsclick-test.cc Fri Jun 25 17:53:42 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,72 +0,0 @@
-#include "ns3/core-module.h"
-#include "ns3/common-module.h"
-#include "ns3/node-module.h"
-#include "ns3/helper-module.h"
-#include "ns3/log.h"
-#include "ns3/ipv4-click-routing.h"
-
-using namespace ns3;
-
-
-void testme1(Ptr<Ipv4ClickRouting> cr)
-{
-// cr->TestInit ();
-}
-
-/*
-void testme1(Ptr<Ipv4ClickRouting> cr)
-{
- NS_LOG_UNCOND ("TESTME: " << Simulator::Now ());
-
- cr->SendToExtRouter ();
-}*/
-
-int main (int argc, char *argv[])
-{
-
- NodeContainer clickNodes;
-
- clickNodes.Create (2);
-
- CsmaHelper csma1;
- csma1.SetChannelAttribute ("DataRate", DataRateValue (DataRate (5000000)));
- csma1.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (2)));
-
- NetDeviceContainer devices1 = csma1.Install (clickNodes);
-/*
- CsmaHelper csma2;
- csma2.SetChannelAttribute ("DataRate", DataRateValue (DataRate (5000000)));
- csma2.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (2)));
-
- NetDeviceContainer devices2 = csma2.Install (clickNodes);
-*/
- InternetStackHelper internet;
- internet.Install (clickNodes);
-
- Ipv4AddressHelper ipv4;
- ipv4.SetBase ("172.16.1.0", "255.255.255.0");
- ipv4.Assign (devices1);
-// ipv4.Assign (devices2);
-
- Ptr<Ipv4> stack = clickNodes.Get (0)->GetObject<Ipv4> ();
-
- Ptr<Ipv4ClickRouting> click = Create<Ipv4ClickRouting>();
- click->SetClickFile ("nsclick-simple-lan.click");
- click->SetNodeName ("Node0");
-
- stack->SetRoutingProtocol (click);
-
- click->DoStart ();
-// click->TestInit ();
-
- csma1.EnablePcap ("nsclick-test", devices1, false);
-
-
- Simulator::Schedule (Seconds (10.0), &testme1, click);
-// Simulator::Schedule (Seconds (20.0), &testme2, test);
-
- Simulator::Stop (Seconds (20.0));
- Simulator::Run ();
- Simulator::Destroy ();
- return 0;
-}