Fixes Click test suite, updates it to use ClickInternetStackHelper, and fixes sanity check in Ipv4ClickRouting

This commit is contained in:
Lalith Suresh
2011-03-28 19:46:05 +01:00
parent edad87014d
commit 8e654a5f94
3 changed files with 23 additions and 30 deletions

View File

@@ -46,7 +46,7 @@ NS_LOG_COMPONENT_DEFINE ("NsclickUdpClientServerWifi");
#ifdef NS3_CLICK
void
readArp (Ptr<Ipv4ClickRouting> clickRouter)
ReadArp (Ptr<Ipv4ClickRouting> clickRouter)
{
// Access the handlers
NS_LOG_INFO (clickRouter->ReadHandler ("wifi/arpquerier", "table"));
@@ -54,11 +54,21 @@ readArp (Ptr<Ipv4ClickRouting> clickRouter)
}
void
writeArp (Ptr<Ipv4ClickRouting> clickRouter)
WriteArp (Ptr<Ipv4ClickRouting> clickRouter)
{
// Access the handler
NS_LOG_INFO (clickRouter->WriteHandler ("wifi/arpquerier", "insert", "172.16.1.2 00:00:00:00:00:02"));
}
void SetPromisc (Ptr<Ipv4ClickRouting> clickRouter)
{
// 4th node can listen to traffic in promisc mode
// Note: Promiscuous mode support for Click has
// been added ahead of the official Wifi support
// for promiscuous mode. Thus, the below line will
// not work until then.
clickRouter->SetPromiscuous ("eth0");
}
#endif
int
@@ -135,13 +145,6 @@ main (int argc, char *argv[])
clickinternet.SetClickFile (n, "src/click/examples/nsclick-wifi-single-interface.click");
clickinternet.SetRoutingTableElement (n, "rt");
clickinternet.Install (n);
// 4th node can listen to traffic in promisc mode
// Note: Promiscuous mode support for Click has
// been added ahead of the official Wifi support
// for promiscuous mode. Thus, the below line will
// not work until then.
n.Get (3)->GetObject<Ipv4ClickRouting> ()->SetPromiscuous ("eth0");
Ipv4AddressHelper ipv4;
//
// We've got the "hardware" in place. Now we need to add IP addresses.
@@ -177,6 +180,9 @@ main (int argc, char *argv[])
wifiPhy.EnablePcap ("nsclick-udp-client-server-wifi", d);
// Call SetPromiscuous mode on Click Router for node 4
Simulator::Schedule (Seconds (0.1), &SetPromisc, n.Get (3)->GetObject<Ipv4ClickRouting> ());
// Force the MAC address of the second node: The current ARP
// implementation of Click sends only one ARP request per incoming
// packet for an unknown destination and does not retransmit if no
@@ -184,9 +190,9 @@ main (int argc, char *argv[])
// requests of node 3 are lost due to interference from node
// 1. Hence, we fill in the ARP table of node 2 before at the
// beginning of the simulation
Simulator::Schedule (Seconds (0.5), &readArp,n.Get (2)->GetObject<Ipv4ClickRouting> ());
Simulator::Schedule (Seconds (0.6), &writeArp,n.Get (2)->GetObject<Ipv4ClickRouting> ());
Simulator::Schedule (Seconds (0.7), &readArp,n.Get (2)->GetObject<Ipv4ClickRouting> ());
Simulator::Schedule (Seconds (0.5), &ReadArp, n.Get (2)->GetObject<Ipv4ClickRouting> ());
Simulator::Schedule (Seconds (0.6), &WriteArp, n.Get (2)->GetObject<Ipv4ClickRouting> ());
Simulator::Schedule (Seconds (0.7), &ReadArp, n.Get (2)->GetObject<Ipv4ClickRouting> ());
//
// Now, do the actual simulation.

View File

@@ -193,7 +193,7 @@ Ipv4ClickRouting::GetInterfaceId (const char *ifname)
// more interfaces defined in the Click graph
// for a Click node than are defined for it in
// the simulation script
if (retval > (int) m_ipv4->GetNInterfaces ())
if (retval >= (int) m_ipv4->GetNInterfaces ())
{
return -1;
}

View File

@@ -26,8 +26,7 @@
#include "ns3/ipv4-l3-protocol.h"
#include "ns3/simple-net-device.h"
#include "ns3/ipv4-click-routing.h"
#include "ns3/icmpv4-l4-protocol.h"
#include "ns3/arp-l3-protocol.h"
#include "ns3/click-internet-stack-helper.h"
#include <click/simclick.h>
@@ -36,19 +35,9 @@ namespace ns3 {
static void
AddClickInternetStack (Ptr<Node> node)
{
// Setup ArpL3Protocol
Ptr<ArpL3Protocol> arp = CreateObject<ArpL3Protocol> ();
node->AggregateObject (arp);
// Setup Ipv4L3Protocol
Ptr<Ipv4L3Protocol> ipv4l3 = CreateObject<Ipv4L3Protocol> ();
node->AggregateObject (ipv4l3);
// Setup Click instance
Ptr<Ipv4> ipv4 = node->GetObject<Ipv4> ();
Ptr<Ipv4ClickRouting> click = CreateObject<Ipv4ClickRouting> ();
click->SetClickFile ("src/click/examples/nsclick-lan-single-interface.click");
ipv4->SetRoutingProtocol (click);
ClickInternetStackHelper internet;
internet.SetClickFile (node, "src/click/examples/nsclick-lan-single-interface.click");
internet.Install (node);
}
static void
@@ -108,7 +97,6 @@ ClickIfidFromNameTest::DoRun ()
ret = simclick_sim_command (click->m_simNode, SIMCLICK_IFID_FROM_NAME, "eth1");
NS_TEST_EXPECT_MSG_EQ (ret, -1, "No eth1 on node");
}
class ClickIpMacAddressFromNameTest : public TestCase
@@ -203,7 +191,6 @@ ClickTrivialTest::DoRun ()
NS_TEST_EXPECT_MSG_EQ (ret, 0, "eth1 does not exist, so return 0");
delete [] buf;
ret = 1;
}
class ClickIfidFromNameTestSuite : public TestSuite