I bind an UDP client in n0 and an UDP-echo-server in n3, and several packets are sent by n0 to n3.
During the simulation, all the packets from n0 can reach n3 correctly. However, the echo packets generated by n3 can't reach n0. All the echo packets just bounced on the link between n2 and n3 till the TTL=0.
It seems that n2 didn't set up the right routing table, so it sent these echo packets(dest to 10.0.0.1) back to n3.
I don't quite understand whether those LSAs work correctly. If not, what kind of LSAs should be generated and what's wrong with my script? Hope you can help me with that. Really appreciate that!
#include "ns3/network-module.h"
#include "ns3/core-module.h"
#include "ns3/internet-module.h"
#include "ns3/dce-module.h"
#include "ns3/quagga-helper.h"
#include "ns3/point-to-point-helper.h"
#include "ns3/applications-module.h"
using namespace ns3;
NS_LOG_COMPONENT_DEFINE ("DceQuaggaOspfd");
// Parameters
uint32_t nNodes = 3;
uint32_t stopTime = 600;
std::string netStack = "ns3";
int main (int argc, char *argv[])
{
CommandLine cmd;
cmd.AddValue ("nNodes", "Number of Router nodes", nNodes);
cmd.AddValue ("stopTime", "Time to stop(seconds)", stopTime);
cmd.AddValue ("netStack", "What network stack", netStack);
cmd.Parse (argc,argv);
//
// Step 1
// Node Basic Configuration
//
NodeContainer nodes;
nodes.Create (nNodes);
PointToPointHelper pointToPoint;
pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms"));
NetDeviceContainer *devices;
devices=new NetDeviceContainer[nNodes-1];
for(int i=0;i<nNodes-1;i++)
{
devices[i]=pointToPoint.Install (nodes.Get(i),nodes.Get(i+1));
}
DceManagerHelper processManager;
Ipv4AddressHelper ipv4AddrHelper;
// Internet stack install
InternetStackHelper stack;
Ipv4DceRoutingHelper ipv4RoutingHelper;
stack.SetRoutingHelper (ipv4RoutingHelper);
stack.Install (nodes);
ipv4AddrHelper.SetBase ("10.0.0.0", "255.255.255.0");
Ipv4InterfaceContainer *interfaces;
interfaces=new Ipv4InterfaceContainer[nNodes-1];
for(int i=0;i<nNodes-1;i++)
{
interfaces[i]=ipv4AddrHelper.Assign (devices[i]);
}
processManager.Install (nodes);
QuaggaHelper quagga;
quagga.EnableOspfDebug (nodes);
quagga.EnableZebraDebug (nodes);
quagga.Install (nodes);
uint16_t port = 9; // well-known echo port number
UdpEchoServerHelper server (port);
ApplicationContainer apps = server.Install (nodes.Get (nNodes-1));
apps.Start (Seconds (101));
apps.Stop (Seconds (110));
//
// Create a UdpEchoClient application to send UDP datagrams from node zero to
// node one.
//
Address serverAddress;
serverAddress = Address(interfaces[nNodes-2].GetAddress (1));
//std::cout<<"hello"<<std::endl;
uint32_t packetSize = 1024;
uint32_t maxPacketCount = 10;
Time interPacketInterval = Seconds (1.);
UdpEchoClientHelper client (serverAddress, port);
client.SetAttribute ("MaxPackets", UintegerValue (maxPacketCount));
client.SetAttribute ("Interval", TimeValue (interPacketInterval));
client.SetAttribute ("PacketSize", UintegerValue (packetSize));
apps = client.Install (nodes.Get (0));
apps.Start (Seconds (102));
apps.Stop (Seconds (110));
pointToPoint.EnablePcapAll ("dce-quagga-ospfd",false);
//
// Step 9
// Now It's ready to GO!
//
if (stopTime != 0)
{
Simulator::Stop (Seconds (stopTime));
}
Simulator::Run ();
Simulator::Destroy ();
return 0;
}