More edits for manual chapter about adding new modules
This commit is contained in:
@@ -51,7 +51,7 @@ ReceivePacket (Ptr<Socket> socket)
|
||||
{
|
||||
InetSocketAddress iaddr = InetSocketAddress::ConvertFrom (from);
|
||||
NS_LOG_UNCOND ("--\nReceived one packet! Socket: "<< iaddr.GetIpv4 ()
|
||||
<< " port: " << iaddr.GetPort () << " at time = " <<
|
||||
<< " port: " << iaddr.GetPort () << " at time = " <<
|
||||
Simulator::Now ().GetSeconds () << "\n--");
|
||||
}
|
||||
}
|
||||
@@ -68,13 +68,13 @@ ReceivePacket (Ptr<Socket> socket)
|
||||
*/
|
||||
static void
|
||||
GenerateTraffic (Ptr<Socket> socket, uint32_t pktSize, Ptr<Node> n,
|
||||
uint32_t pktCount, Time pktInterval)
|
||||
uint32_t pktCount, Time pktInterval)
|
||||
{
|
||||
if (pktCount > 0)
|
||||
{
|
||||
socket->Send (Create<Packet> (pktSize));
|
||||
Simulator::Schedule (pktInterval, &GenerateTraffic, socket, pktSize, n,
|
||||
pktCount - 1, pktInterval);
|
||||
pktCount - 1, pktInterval);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -59,7 +59,7 @@ main (int argc, char *argv[])
|
||||
// Set a few attributes
|
||||
Config::SetDefault ("ns3::RateErrorModel::ErrorRate", DoubleValue (0.01));
|
||||
Config::SetDefault ("ns3::RateErrorModel::ErrorUnit", StringValue ("EU_PKT"));
|
||||
|
||||
|
||||
Config::SetDefault ("ns3::OnOffApplication::PacketSize", UintegerValue (210));
|
||||
Config::SetDefault ("ns3::OnOffApplication::DataRate", DataRateValue (DataRate ("448kb/s")));
|
||||
|
||||
@@ -93,13 +93,13 @@ main (int argc, char *argv[])
|
||||
p2p.SetDeviceAttribute ("DataRate", DataRateValue (DataRate (1500000)));
|
||||
p2p.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (10)));
|
||||
NetDeviceContainer d3d2 = p2p.Install (n3n2);
|
||||
|
||||
// Later, we add IP addresses.
|
||||
|
||||
// Later, we add IP addresses.
|
||||
NS_LOG_INFO ("Assign IP Addresses.");
|
||||
Ipv4AddressHelper ipv4;
|
||||
ipv4.SetBase ("10.1.1.0", "255.255.255.0");
|
||||
ipv4.Assign (d0d2);
|
||||
|
||||
|
||||
ipv4.SetBase ("10.1.2.0", "255.255.255.0");
|
||||
Ipv4InterfaceContainer i1i2 = ipv4.Assign (d1d2);
|
||||
|
||||
@@ -115,7 +115,7 @@ main (int argc, char *argv[])
|
||||
uint16_t port = 9; // Discard port (RFC 863)
|
||||
|
||||
OnOffHelper onoff ("ns3::UdpSocketFactory",
|
||||
Address (InetSocketAddress (i3i2.GetAddress (1), port)));
|
||||
Address (InetSocketAddress (i3i2.GetAddress (1), port)));
|
||||
onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable(1)));
|
||||
onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable(0)));
|
||||
|
||||
@@ -125,7 +125,7 @@ main (int argc, char *argv[])
|
||||
|
||||
// Create an optional packet sink to receive these packets
|
||||
PacketSinkHelper sink ("ns3::UdpSocketFactory",
|
||||
Address (InetSocketAddress (Ipv4Address::GetAny (), port)));
|
||||
Address (InetSocketAddress (Ipv4Address::GetAny (), port)));
|
||||
apps = sink.Install (c.Get (2));
|
||||
apps.Start (Seconds (1.0));
|
||||
apps.Stop (Seconds (10.0));
|
||||
@@ -150,7 +150,7 @@ main (int argc, char *argv[])
|
||||
// Create an ErrorModel based on the implementation (constructor)
|
||||
// specified by the default classId
|
||||
Ptr<RateErrorModel> em = CreateObjectWithAttributes<RateErrorModel> ("RanVar", RandomVariableValue (UniformVariable (0.0, 1.0)),
|
||||
"ErrorRate", DoubleValue (0.001));
|
||||
"ErrorRate", DoubleValue (0.001));
|
||||
d3d2.Get (0)->SetAttribute ("ReceiveErrorModel", PointerValue (em));
|
||||
|
||||
// Now, let's use the ListErrorModel and explicitly force a loss
|
||||
@@ -168,7 +168,7 @@ main (int argc, char *argv[])
|
||||
p2p.EnablePcapAll ("simple-error-model");
|
||||
|
||||
NS_LOG_INFO ("Run Simulation.");
|
||||
Simulator::Run ();
|
||||
Simulator::Run ();
|
||||
Simulator::Destroy ();
|
||||
NS_LOG_INFO ("Done.");
|
||||
}
|
||||
|
||||
@@ -82,10 +82,10 @@ public:
|
||||
{
|
||||
route = routing->GetRoute (i);
|
||||
std::cout << route.GetDest () << "\t"
|
||||
<< route.GetGateway () << "\t"
|
||||
<< route.GetInterface () << "\t"
|
||||
<< route.GetPrefixToUse () << "\t"
|
||||
<< std::endl;
|
||||
<< route.GetGateway () << "\t"
|
||||
<< route.GetInterface () << "\t"
|
||||
<< route.GetPrefixToUse () << "\t"
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -82,10 +82,10 @@ public:
|
||||
{
|
||||
route = routing->GetRoute (i);
|
||||
std::cout << route.GetDest () << "\t"
|
||||
<< route.GetGateway () << "\t"
|
||||
<< route.GetInterface () << "\t"
|
||||
<< route.GetPrefixToUse () << "\t"
|
||||
<< std::endl;
|
||||
<< route.GetGateway () << "\t"
|
||||
<< route.GetInterface () << "\t"
|
||||
<< route.GetPrefixToUse () << "\t"
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,8 +33,8 @@
|
||||
// // +------------+ | | |
|
||||
// // | Host 1 |--| | +------------+ |
|
||||
// // [------------] |---| Router 3 |---|
|
||||
// // [------------]
|
||||
// //
|
||||
// // [------------]
|
||||
// //
|
||||
// //
|
||||
// // - Tracing of queues and packet receptions to file "loose-routing-ipv6.tr"
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
// Network topology
|
||||
//
|
||||
// n0 n1
|
||||
// n0 n1
|
||||
// | |
|
||||
// =================
|
||||
// LAN
|
||||
|
||||
@@ -89,10 +89,10 @@ public:
|
||||
{
|
||||
route = routing->GetRoute (i);
|
||||
std::cout << route.GetDest () << "\t"
|
||||
<< route.GetGateway () << "\t"
|
||||
<< route.GetInterface () << "\t"
|
||||
<< route.GetPrefixToUse () << "\t"
|
||||
<< std::endl;
|
||||
<< route.GetGateway () << "\t"
|
||||
<< route.GetInterface () << "\t"
|
||||
<< route.GetPrefixToUse () << "\t"
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -278,7 +278,7 @@ int main (int argc, char *argv[])
|
||||
bool animEnabled = false;
|
||||
AnimationInterface anim;
|
||||
if (anim.SetServerPort (9) && anim.SetOutputFile (anim_name.c_str ()))
|
||||
{
|
||||
{
|
||||
NS_LOG_INFO ("Animation Interface Enabled.");
|
||||
animEnabled = true;
|
||||
anim.StartAnimation ();
|
||||
|
||||
@@ -50,7 +50,7 @@ main (int argc, char *argv[])
|
||||
// that.
|
||||
//
|
||||
GlobalValue::Bind ("SimulatorImplementationType",
|
||||
StringValue ("ns3::RealtimeSimulatorImpl"));
|
||||
StringValue ("ns3::RealtimeSimulatorImpl"));
|
||||
|
||||
//
|
||||
// Explicitly create the nodes required by the topology (shown above).
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
// keeps the point-to-point link "up" from n1's perspective). Traffic will
|
||||
// flow through the path n1-n2-n5-n6
|
||||
// At time 8s, bring the interface back up. Path n1-n6 is restored
|
||||
// At time 10s, stop the first flow.
|
||||
// At time 10s, stop the first flow.
|
||||
// At time 11s, start a new flow, but to n6's other IP address (the one
|
||||
// on the n1/n6 p2p link)
|
||||
// At time 12s, bring the n1 interface down between n1 and n6. Packets
|
||||
@@ -58,7 +58,7 @@
|
||||
// At time 14s, re-enable the n1/n6 interface to up. This will change
|
||||
// routing back to n1-n6 since the interface up notification will cause
|
||||
// a new local interface route, at higher priority than global routing
|
||||
// At time 16s, stop the second flow.
|
||||
// At time 16s, stop the second flow.
|
||||
|
||||
// - Tracing of queues and packet receptions to file "dynamic-global-routing.tr"
|
||||
|
||||
@@ -122,8 +122,8 @@ main (int argc, char *argv[])
|
||||
csma.SetChannelAttribute ("DataRate", StringValue ("5Mbps"));
|
||||
csma.SetChannelAttribute ("Delay", StringValue ("2ms"));
|
||||
NetDeviceContainer d2345 = csma.Install (n2345);
|
||||
|
||||
// Later, we add IP addresses.
|
||||
|
||||
// Later, we add IP addresses.
|
||||
NS_LOG_INFO ("Assign IP Addresses.");
|
||||
Ipv4AddressHelper ipv4;
|
||||
ipv4.SetBase ("10.1.1.0", "255.255.255.0");
|
||||
@@ -163,7 +163,7 @@ main (int argc, char *argv[])
|
||||
// Create a second OnOff application to send UDP datagrams of size
|
||||
// 210 bytes at a rate of 448 Kb/s
|
||||
OnOffHelper onoff2 ("ns3::UdpSocketFactory",
|
||||
InetSocketAddress (i1i6.GetAddress (1), port));
|
||||
InetSocketAddress (i1i6.GetAddress (1), port));
|
||||
onoff2.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1)));
|
||||
onoff2.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0)));
|
||||
onoff2.SetAttribute ("DataRate", StringValue ("2kbps"));
|
||||
@@ -175,13 +175,13 @@ main (int argc, char *argv[])
|
||||
|
||||
// Create an optional packet sink to receive these packets
|
||||
PacketSinkHelper sink ("ns3::UdpSocketFactory",
|
||||
Address (InetSocketAddress (Ipv4Address::GetAny (), port)));
|
||||
Address (InetSocketAddress (Ipv4Address::GetAny (), port)));
|
||||
apps = sink.Install (c.Get (6));
|
||||
apps.Start (Seconds (1.0));
|
||||
apps.Stop (Seconds (10.0));
|
||||
|
||||
PacketSinkHelper sink2 ("ns3::UdpSocketFactory",
|
||||
Address (InetSocketAddress (Ipv4Address::GetAny (), port)));
|
||||
Address (InetSocketAddress (Ipv4Address::GetAny (), port)));
|
||||
apps2 = sink2.Install (c.Get (6));
|
||||
apps2.Start (Seconds (11.0));
|
||||
apps2.Stop (Seconds (16.0));
|
||||
|
||||
@@ -79,7 +79,7 @@ main (int argc, char *argv[])
|
||||
NetDeviceContainer dAdB = p2p.Install (nAnB);
|
||||
|
||||
NetDeviceContainer dBdC = p2p.Install (nBnC);;
|
||||
|
||||
|
||||
Ptr<CsmaNetDevice> deviceA = CreateObject<CsmaNetDevice> ();
|
||||
deviceA->SetAddress (Mac48Address::Allocate ());
|
||||
nA->AddDevice (deviceA);
|
||||
@@ -88,7 +88,7 @@ main (int argc, char *argv[])
|
||||
deviceC->SetAddress (Mac48Address::Allocate ());
|
||||
nC->AddDevice (deviceC);
|
||||
|
||||
// Later, we add IP addresses.
|
||||
// Later, we add IP addresses.
|
||||
Ipv4AddressHelper ipv4;
|
||||
ipv4.SetBase ("10.1.1.0", "255.255.255.252");
|
||||
Ipv4InterfaceContainer iAiB = ipv4.Assign (dAdB);
|
||||
@@ -99,10 +99,10 @@ main (int argc, char *argv[])
|
||||
Ptr<Ipv4> ipv4A = nA->GetObject<Ipv4> ();
|
||||
Ptr<Ipv4> ipv4B = nB->GetObject<Ipv4> ();
|
||||
Ptr<Ipv4> ipv4C = nC->GetObject<Ipv4> ();
|
||||
|
||||
|
||||
int32_t ifIndexA = ipv4A->AddInterface (deviceA);
|
||||
int32_t ifIndexC = ipv4C->AddInterface (deviceC);
|
||||
|
||||
|
||||
Ipv4InterfaceAddress ifInAddrA = Ipv4InterfaceAddress (Ipv4Address ("172.16.1.1"), Ipv4Mask ("255.255.255.255"));
|
||||
ipv4A->AddAddress (ifIndexA, ifInAddrA);
|
||||
ipv4A->SetMetric (ifIndexA, 1);
|
||||
@@ -115,7 +115,7 @@ main (int argc, char *argv[])
|
||||
|
||||
// Create router nodes, initialize routing database and set up the routing
|
||||
// tables in the nodes.
|
||||
|
||||
|
||||
// Populate routing tables for nodes nA and nB
|
||||
Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
|
||||
// Inject global routes from Node B, including transit network...
|
||||
@@ -123,19 +123,19 @@ main (int argc, char *argv[])
|
||||
globalRouterB->InjectRoute ("10.1.1.4", "255.255.255.252");
|
||||
// ...and the host in network "C"
|
||||
globalRouterB->InjectRoute ("192.168.1.1", "255.255.255.255");
|
||||
|
||||
|
||||
Ipv4GlobalRoutingHelper::RecomputeRoutingTables();
|
||||
// In addition, nB needs a static route to nC so it knows what to do with stuff
|
||||
// going to 192.168.1.1
|
||||
Ipv4StaticRoutingHelper ipv4RoutingHelper;
|
||||
Ptr<Ipv4StaticRouting> staticRoutingB = ipv4RoutingHelper.GetStaticRouting(ipv4B);
|
||||
staticRoutingB->AddHostRouteTo (Ipv4Address ("192.168.1.1"), Ipv4Address ("10.1.1.6"),2);
|
||||
|
||||
|
||||
// Create the OnOff application to send UDP datagrams of size
|
||||
// 210 bytes at a rate of 448 Kb/s
|
||||
uint16_t port = 9; // Discard port (RFC 863)
|
||||
OnOffHelper onoff ("ns3::UdpSocketFactory",
|
||||
Address (InetSocketAddress (ifInAddrC.GetLocal(), port)));
|
||||
Address (InetSocketAddress (ifInAddrC.GetLocal(), port)));
|
||||
onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1)));
|
||||
onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0)));
|
||||
onoff.SetAttribute ("DataRate", DataRateValue (DataRate (6000)));
|
||||
@@ -145,7 +145,7 @@ main (int argc, char *argv[])
|
||||
|
||||
// Create a packet sink to receive these packets
|
||||
PacketSinkHelper sink ("ns3::UdpSocketFactory",
|
||||
Address (InetSocketAddress (Ipv4Address::GetAny (), port)));
|
||||
Address (InetSocketAddress (Ipv4Address::GetAny (), port)));
|
||||
apps = sink.Install (nC);
|
||||
apps.Start (Seconds (1.0));
|
||||
apps.Stop (Seconds (10.0));
|
||||
|
||||
@@ -65,7 +65,7 @@ main (int argc, char *argv[])
|
||||
NetDeviceContainer dAdB = p2p.Install (nAnB);
|
||||
|
||||
NetDeviceContainer dBdC = p2p.Install (nBnC);;
|
||||
|
||||
|
||||
Ptr<CsmaNetDevice> deviceA = CreateObject<CsmaNetDevice> ();
|
||||
deviceA->SetAddress (Mac48Address::Allocate ());
|
||||
nA->AddDevice (deviceA);
|
||||
@@ -74,7 +74,7 @@ main (int argc, char *argv[])
|
||||
deviceC->SetAddress (Mac48Address::Allocate ());
|
||||
nC->AddDevice (deviceC);
|
||||
|
||||
// Later, we add IP addresses.
|
||||
// Later, we add IP addresses.
|
||||
Ipv4AddressHelper ipv4;
|
||||
ipv4.SetBase ("10.1.1.0", "255.255.255.252");
|
||||
Ipv4InterfaceContainer iAiB = ipv4.Assign (dAdB);
|
||||
@@ -84,10 +84,10 @@ main (int argc, char *argv[])
|
||||
|
||||
Ptr<Ipv4> ipv4A = nA->GetObject<Ipv4> ();
|
||||
Ptr<Ipv4> ipv4C = nC->GetObject<Ipv4> ();
|
||||
|
||||
|
||||
int32_t ifIndexA = ipv4A->AddInterface (deviceA);
|
||||
int32_t ifIndexC = ipv4C->AddInterface (deviceC);
|
||||
|
||||
|
||||
Ipv4InterfaceAddress ifInAddrA = Ipv4InterfaceAddress (Ipv4Address ("172.16.1.1"), Ipv4Mask ("255.255.255.255"));
|
||||
ipv4A->AddAddress (ifIndexA, ifInAddrA);
|
||||
ipv4A->SetMetric (ifIndexA, 1);
|
||||
@@ -106,7 +106,7 @@ main (int argc, char *argv[])
|
||||
// 210 bytes at a rate of 448 Kb/s
|
||||
uint16_t port = 9; // Discard port (RFC 863)
|
||||
OnOffHelper onoff ("ns3::UdpSocketFactory",
|
||||
Address (InetSocketAddress (ifInAddrC.GetLocal(), port)));
|
||||
Address (InetSocketAddress (ifInAddrC.GetLocal(), port)));
|
||||
onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1)));
|
||||
onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0)));
|
||||
onoff.SetAttribute ("DataRate", DataRateValue (DataRate (6000)));
|
||||
@@ -116,7 +116,7 @@ main (int argc, char *argv[])
|
||||
|
||||
// Create a packet sink to receive these packets
|
||||
PacketSinkHelper sink ("ns3::UdpSocketFactory",
|
||||
Address (InetSocketAddress (Ipv4Address::GetAny (), port)));
|
||||
Address (InetSocketAddress (Ipv4Address::GetAny (), port)));
|
||||
apps = sink.Install (nC);
|
||||
apps.Start (Seconds (1.0));
|
||||
apps.Stop (Seconds (10.0));
|
||||
|
||||
@@ -87,8 +87,8 @@ main (int argc, char *argv[])
|
||||
csma.SetChannelAttribute ("DataRate", StringValue ("5Mbps"));
|
||||
csma.SetChannelAttribute ("Delay", StringValue ("2ms"));
|
||||
NetDeviceContainer d2345 = csma.Install (n2345);
|
||||
|
||||
// Later, we add IP addresses.
|
||||
|
||||
// Later, we add IP addresses.
|
||||
NS_LOG_INFO ("Assign IP Addresses.");
|
||||
Ipv4AddressHelper ipv4;
|
||||
ipv4.SetBase ("10.1.1.0", "255.255.255.0");
|
||||
|
||||
@@ -109,17 +109,17 @@ main (int argc, char *argv[])
|
||||
|
||||
InternetStackHelper internet;
|
||||
internet.Install (c);
|
||||
|
||||
|
||||
// Later, we add IP addresses. The middle two octets correspond to
|
||||
// the channel number.
|
||||
// the channel number.
|
||||
NS_LOG_INFO ("Assign IP Addresses.");
|
||||
Ipv4AddressHelper ipv4;
|
||||
ipv4.SetBase ("10.0.0.0", "255.255.255.0");
|
||||
ipv4.Assign (d0d2);
|
||||
|
||||
|
||||
ipv4.SetBase ("10.1.1.0", "255.255.255.0");
|
||||
Ipv4InterfaceContainer i1i2 = ipv4.Assign (d1d2);
|
||||
|
||||
|
||||
ipv4.SetBase ("10.2.2.0", "255.255.255.0");
|
||||
ipv4.Assign (d3d2);
|
||||
|
||||
@@ -139,7 +139,7 @@ main (int argc, char *argv[])
|
||||
|
||||
// Create a flow from n3 to n1, starting at time 1.1 seconds
|
||||
OnOffHelper onoff ("ns3::UdpSocketFactory",
|
||||
Address (InetSocketAddress (i1i2.GetAddress (0), port)));
|
||||
Address (InetSocketAddress (i1i2.GetAddress (0), port)));
|
||||
onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1)));
|
||||
onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0)));
|
||||
|
||||
@@ -149,7 +149,7 @@ main (int argc, char *argv[])
|
||||
|
||||
// Create a packet sink to receive these packets
|
||||
PacketSinkHelper sink ("ns3::UdpSocketFactory",
|
||||
Address (InetSocketAddress (Ipv4Address::GetAny (), port)));
|
||||
Address (InetSocketAddress (Ipv4Address::GetAny (), port)));
|
||||
apps = sink.Install (c.Get (1));
|
||||
apps.Start (Seconds (1.1));
|
||||
apps.Stop (Seconds (10.0));
|
||||
|
||||
@@ -64,7 +64,7 @@ main (int argc, char *argv[])
|
||||
Config::SetDefault ("ns3::OnOffApplication::PacketSize", UintegerValue (210));
|
||||
Config::SetDefault ("ns3::OnOffApplication::DataRate", StringValue ("448kb/s"));
|
||||
|
||||
//DefaultValue::Bind ("DropTailQueue::m_maxPackets", 30);
|
||||
//DefaultValue::Bind ("DropTailQueue::m_maxPackets", 30);
|
||||
|
||||
// Allow the user to override any of the defaults and the above
|
||||
// DefaultValue::Bind ()s at run-time, via command-line arguments
|
||||
@@ -93,12 +93,12 @@ main (int argc, char *argv[])
|
||||
NetDeviceContainer d0d2 = p2p.Install (n0n2);
|
||||
|
||||
NetDeviceContainer d1d2 = p2p.Install (n1n2);
|
||||
|
||||
|
||||
p2p.SetDeviceAttribute ("DataRate", StringValue ("1500kbps"));
|
||||
p2p.SetChannelAttribute ("Delay", StringValue ("10ms"));
|
||||
NetDeviceContainer d3d2 = p2p.Install (n3n2);
|
||||
|
||||
// Later, we add IP addresses.
|
||||
|
||||
// Later, we add IP addresses.
|
||||
NS_LOG_INFO ("Assign IP Addresses.");
|
||||
Ipv4AddressHelper ipv4;
|
||||
ipv4.SetBase ("10.1.1.0", "255.255.255.0");
|
||||
@@ -106,7 +106,7 @@ main (int argc, char *argv[])
|
||||
|
||||
ipv4.SetBase ("10.1.2.0", "255.255.255.0");
|
||||
Ipv4InterfaceContainer i1i2 = ipv4.Assign (d1d2);
|
||||
|
||||
|
||||
ipv4.SetBase ("10.1.3.0", "255.255.255.0");
|
||||
Ipv4InterfaceContainer i3i2 = ipv4.Assign (d3d2);
|
||||
|
||||
@@ -119,7 +119,7 @@ main (int argc, char *argv[])
|
||||
NS_LOG_INFO ("Create Applications.");
|
||||
uint16_t port = 9; // Discard port (RFC 863)
|
||||
OnOffHelper onoff ("ns3::UdpSocketFactory",
|
||||
Address (InetSocketAddress (i3i2.GetAddress (0), port)));
|
||||
Address (InetSocketAddress (i3i2.GetAddress (0), port)));
|
||||
onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1)));
|
||||
onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0)));
|
||||
ApplicationContainer apps = onoff.Install (c.Get (0));
|
||||
@@ -128,14 +128,14 @@ main (int argc, char *argv[])
|
||||
|
||||
// Create a packet sink to receive these packets
|
||||
PacketSinkHelper sink ("ns3::UdpSocketFactory",
|
||||
Address (InetSocketAddress (Ipv4Address::GetAny (), port)));
|
||||
Address (InetSocketAddress (Ipv4Address::GetAny (), port)));
|
||||
apps = sink.Install (c.Get (3));
|
||||
apps.Start (Seconds (1.0));
|
||||
apps.Stop (Seconds (10.0));
|
||||
|
||||
// Create a similar flow from n3 to n1, starting at time 1.1 seconds
|
||||
onoff.SetAttribute ("Remote",
|
||||
AddressValue (InetSocketAddress (i1i2.GetAddress (0), port)));
|
||||
AddressValue (InetSocketAddress (i1i2.GetAddress (0), port)));
|
||||
apps = onoff.Install (c.Get (3));
|
||||
apps.Start (Seconds (1.1));
|
||||
apps.Stop (Seconds (10.0));
|
||||
@@ -155,7 +155,7 @@ main (int argc, char *argv[])
|
||||
{
|
||||
FlowMonitorHelper flowmonHelper;
|
||||
flowmon = flowmonHelper.InstallAll ();
|
||||
}
|
||||
}
|
||||
|
||||
NS_LOG_INFO ("Run Simulation.");
|
||||
Simulator::Stop (Seconds (11));
|
||||
|
||||
@@ -83,10 +83,10 @@ public:
|
||||
{
|
||||
route = routing->GetRoute (i);
|
||||
std::cout << route.GetDest () << "\t"
|
||||
<< route.GetGateway () << "\t"
|
||||
<< route.GetInterface () << "\t"
|
||||
<< route.GetPrefixToUse () << "\t"
|
||||
<< std::endl;
|
||||
<< route.GetGateway () << "\t"
|
||||
<< route.GetInterface () << "\t"
|
||||
<< route.GetPrefixToUse () << "\t"
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -65,7 +65,7 @@ main (int argc, char *argv[])
|
||||
NetDeviceContainer dAdB = p2p.Install (nAnB);
|
||||
|
||||
NetDeviceContainer dBdC = p2p.Install (nBnC);;
|
||||
|
||||
|
||||
Ptr<CsmaNetDevice> deviceA = CreateObject<CsmaNetDevice> ();
|
||||
deviceA->SetAddress (Mac48Address::Allocate ());
|
||||
nA->AddDevice (deviceA);
|
||||
@@ -74,7 +74,7 @@ main (int argc, char *argv[])
|
||||
deviceC->SetAddress (Mac48Address::Allocate ());
|
||||
nC->AddDevice (deviceC);
|
||||
|
||||
// Later, we add IP addresses.
|
||||
// Later, we add IP addresses.
|
||||
Ipv4AddressHelper ipv4;
|
||||
ipv4.SetBase ("10.1.1.0", "255.255.255.252");
|
||||
Ipv4InterfaceContainer iAiB = ipv4.Assign (dAdB);
|
||||
@@ -85,10 +85,10 @@ main (int argc, char *argv[])
|
||||
Ptr<Ipv4> ipv4A = nA->GetObject<Ipv4> ();
|
||||
Ptr<Ipv4> ipv4B = nB->GetObject<Ipv4> ();
|
||||
Ptr<Ipv4> ipv4C = nC->GetObject<Ipv4> ();
|
||||
|
||||
|
||||
int32_t ifIndexA = ipv4A->AddInterface (deviceA);
|
||||
int32_t ifIndexC = ipv4C->AddInterface (deviceC);
|
||||
|
||||
|
||||
Ipv4InterfaceAddress ifInAddrA = Ipv4InterfaceAddress (Ipv4Address ("172.16.1.1"), Ipv4Mask ("/32"));
|
||||
ipv4A->AddAddress (ifIndexA, ifInAddrA);
|
||||
ipv4A->SetMetric (ifIndexA, 1);
|
||||
@@ -111,7 +111,7 @@ main (int argc, char *argv[])
|
||||
// 210 bytes at a rate of 448 Kb/s
|
||||
uint16_t port = 9; // Discard port (RFC 863)
|
||||
OnOffHelper onoff ("ns3::UdpSocketFactory",
|
||||
Address (InetSocketAddress (ifInAddrC.GetLocal (), port)));
|
||||
Address (InetSocketAddress (ifInAddrC.GetLocal (), port)));
|
||||
onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1)));
|
||||
onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0)));
|
||||
onoff.SetAttribute ("DataRate", DataRateValue (DataRate (6000)));
|
||||
@@ -121,7 +121,7 @@ main (int argc, char *argv[])
|
||||
|
||||
// Create a packet sink to receive these packets
|
||||
PacketSinkHelper sink ("ns3::UdpSocketFactory",
|
||||
Address (InetSocketAddress (Ipv4Address::GetAny (), port)));
|
||||
Address (InetSocketAddress (Ipv4Address::GetAny (), port)));
|
||||
apps = sink.Install (nC);
|
||||
apps.Start (Seconds (1.0));
|
||||
apps.Stop (Seconds (10.0));
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
| 10.20.1.0/24
|
||||
DSTRTR
|
||||
10.10.1.0/24 / \ 10.10.2.0/24
|
||||
/ \
|
||||
/ \
|
||||
Rtr1 Rtr2
|
||||
10.1.1.0/24 | | 10.1.2.0/24
|
||||
| /
|
||||
@@ -65,7 +65,7 @@ main (int argc, char *argv[])
|
||||
Ptr<Node> nRtr1 = CreateObject<Node> ();
|
||||
Ptr<Node> nRtr2 = CreateObject<Node> ();
|
||||
Ptr<Node> nDstRtr = CreateObject<Node> ();
|
||||
|
||||
|
||||
NodeContainer c = NodeContainer (nSrc, nDst, nRtr1, nRtr2, nDstRtr);
|
||||
|
||||
InternetStackHelper internet;
|
||||
@@ -77,7 +77,7 @@ main (int argc, char *argv[])
|
||||
NodeContainer nRtr1nDstRtr = NodeContainer (nRtr1, nDstRtr);
|
||||
NodeContainer nRtr2nDstRtr = NodeContainer (nRtr2, nDstRtr);
|
||||
NodeContainer nDstRtrnDst = NodeContainer (nDstRtr, nDst);
|
||||
|
||||
|
||||
// We create the channels first without any IP addressing information
|
||||
PointToPointHelper p2p;
|
||||
p2p.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
|
||||
@@ -87,11 +87,11 @@ main (int argc, char *argv[])
|
||||
NetDeviceContainer dRtr1dDstRtr = p2p.Install (nRtr1nDstRtr);
|
||||
NetDeviceContainer dRtr2dDstRtr = p2p.Install (nRtr2nDstRtr);
|
||||
NetDeviceContainer dDstRtrdDst = p2p.Install (nDstRtrnDst);
|
||||
|
||||
|
||||
Ptr<NetDevice> SrcToRtr1=dSrcdRtr1.Get (0);
|
||||
Ptr<NetDevice> SrcToRtr2=dSrcdRtr2.Get (0);
|
||||
|
||||
// Later, we add IP addresses.
|
||||
|
||||
// Later, we add IP addresses.
|
||||
Ipv4AddressHelper ipv4;
|
||||
ipv4.SetBase ("10.1.1.0", "255.255.255.0");
|
||||
Ipv4InterfaceContainer iSrciRtr1 = ipv4.Assign (dSrcdRtr1);
|
||||
@@ -109,7 +109,7 @@ main (int argc, char *argv[])
|
||||
Ptr<Ipv4> ipv4Rtr2 = nRtr2->GetObject<Ipv4> ();
|
||||
Ptr<Ipv4> ipv4DstRtr = nDstRtr->GetObject<Ipv4> ();
|
||||
Ptr<Ipv4> ipv4Dst = nDst->GetObject<Ipv4> ();
|
||||
|
||||
|
||||
Ipv4StaticRoutingHelper ipv4RoutingHelper;
|
||||
Ptr<Ipv4StaticRouting> staticRoutingSrc = ipv4RoutingHelper.GetStaticRouting (ipv4Src);
|
||||
Ptr<Ipv4StaticRouting> staticRoutingRtr1 = ipv4RoutingHelper.GetStaticRouting (ipv4Rtr1);
|
||||
@@ -120,33 +120,33 @@ main (int argc, char *argv[])
|
||||
// Create static routes from Src to Dst
|
||||
staticRoutingRtr1->AddHostRouteTo (Ipv4Address ("10.20.1.2"), Ipv4Address ("10.10.1.2"), 2);
|
||||
staticRoutingRtr2->AddHostRouteTo (Ipv4Address ("10.20.1.2"), Ipv4Address ("10.10.2.2"), 2);
|
||||
|
||||
|
||||
// Two routes to same destination - setting separate metrics.
|
||||
// You can switch these to see how traffic gets diverted via different routes
|
||||
staticRoutingSrc->AddHostRouteTo (Ipv4Address ("10.20.1.2"), Ipv4Address ("10.1.1.2"), 1,5);
|
||||
staticRoutingSrc->AddHostRouteTo (Ipv4Address ("10.20.1.2"), Ipv4Address ("10.1.2.2"), 2,10);
|
||||
|
||||
|
||||
// Creating static routes from DST to Source pointing to Rtr1 VIA Rtr2(!)
|
||||
staticRoutingDst->AddHostRouteTo (Ipv4Address ("10.1.1.1"), Ipv4Address ("10.20.1.1"), 1);
|
||||
staticRoutingDstRtr->AddHostRouteTo (Ipv4Address ("10.1.1.1"), Ipv4Address ("10.10.2.1"), 2);
|
||||
staticRoutingRtr2->AddHostRouteTo (Ipv4Address ("10.1.1.1"), Ipv4Address ("10.1.2.1"), 1);
|
||||
|
||||
|
||||
Ipv4InterfaceAddress ifInAddrSrc=ipv4Src->GetAddress (1,0);
|
||||
|
||||
|
||||
// There are no apps that can utilize the Socket Option so doing the work directly..
|
||||
// Taken from tcp-large-transfer example
|
||||
|
||||
Ptr<Socket> srcSocket = Socket::CreateSocket (nSrc, TypeId::LookupByName ("ns3::UdpSocketFactory"));
|
||||
srcSocket->Bind ();
|
||||
srcSocket->SetRecvCallback (MakeCallback (&srcSocketRecv));
|
||||
|
||||
|
||||
Ptr<Socket> dstSocket = Socket::CreateSocket (nDst, TypeId::LookupByName ("ns3::UdpSocketFactory"));
|
||||
uint16_t dstport = 12345;
|
||||
Ipv4Address dstaddr ("10.20.1.2");
|
||||
InetSocketAddress dst = InetSocketAddress (dstaddr, dstport);
|
||||
dstSocket->Bind (dst);
|
||||
dstSocket->SetRecvCallback (MakeCallback (&dstSocketRecv));
|
||||
|
||||
|
||||
AsciiTraceHelper ascii;
|
||||
p2p.EnableAsciiAll (ascii.CreateFileStream ("socket-bound-static-routing.tr"));
|
||||
p2p.EnablePcapAll ("socket-bound-static-routing");
|
||||
@@ -201,7 +201,7 @@ srcSocketRecv (Ptr<Socket> socket)
|
||||
{
|
||||
NS_LOG_INFO ("Socket was bound");
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
NS_LOG_INFO ("Socket was not bound");
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
| 10.20.1.0/24
|
||||
DSTRTR
|
||||
10.10.1.0/24 / \ 10.10.2.0/24
|
||||
/ \
|
||||
/ \
|
||||
Rtr1 Rtr2
|
||||
10.1.1.0/24 | | 10.1.2.0/24
|
||||
| /
|
||||
@@ -75,7 +75,7 @@ main (int argc, char *argv[])
|
||||
Ptr<Node> nRtr1 = CreateObject<Node> ();
|
||||
Ptr<Node> nRtr2 = CreateObject<Node> ();
|
||||
Ptr<Node> nDstRtr = CreateObject<Node> ();
|
||||
|
||||
|
||||
NodeContainer c = NodeContainer (nSrc, nDst, nRtr1, nRtr2, nDstRtr);
|
||||
|
||||
InternetStackHelper internet;
|
||||
@@ -87,7 +87,7 @@ main (int argc, char *argv[])
|
||||
NodeContainer nRtr1nDstRtr = NodeContainer (nRtr1, nDstRtr);
|
||||
NodeContainer nRtr2nDstRtr = NodeContainer (nRtr2, nDstRtr);
|
||||
NodeContainer nDstRtrnDst = NodeContainer (nDstRtr, nDst);
|
||||
|
||||
|
||||
// We create the channels first without any IP addressing information
|
||||
PointToPointHelper p2p;
|
||||
p2p.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
|
||||
@@ -97,11 +97,11 @@ main (int argc, char *argv[])
|
||||
NetDeviceContainer dRtr1dDstRtr = p2p.Install (nRtr1nDstRtr);
|
||||
NetDeviceContainer dRtr2dDstRtr = p2p.Install (nRtr2nDstRtr);
|
||||
NetDeviceContainer dDstRtrdDst = p2p.Install (nDstRtrnDst);
|
||||
|
||||
|
||||
Ptr<NetDevice> SrcToRtr1=dSrcdRtr1.Get (0);
|
||||
Ptr<NetDevice> SrcToRtr2=dSrcdRtr2.Get (0);
|
||||
|
||||
// Later, we add IP addresses.
|
||||
|
||||
// Later, we add IP addresses.
|
||||
Ipv4AddressHelper ipv4;
|
||||
ipv4.SetBase ("10.1.1.0", "255.255.255.0");
|
||||
Ipv4InterfaceContainer iSrciRtr1 = ipv4.Assign (dSrcdRtr1);
|
||||
@@ -119,7 +119,7 @@ main (int argc, char *argv[])
|
||||
Ptr<Ipv4> ipv4Rtr2 = nRtr2->GetObject<Ipv4> ();
|
||||
Ptr<Ipv4> ipv4DstRtr = nDstRtr->GetObject<Ipv4> ();
|
||||
Ptr<Ipv4> ipv4Dst = nDst->GetObject<Ipv4> ();
|
||||
|
||||
|
||||
Ipv4StaticRoutingHelper ipv4RoutingHelper;
|
||||
Ptr<Ipv4StaticRouting> staticRoutingSrc = ipv4RoutingHelper.GetStaticRouting (ipv4Src);
|
||||
Ptr<Ipv4StaticRouting> staticRoutingRtr1 = ipv4RoutingHelper.GetStaticRouting (ipv4Rtr1);
|
||||
@@ -130,23 +130,23 @@ main (int argc, char *argv[])
|
||||
// Create static routes from Src to Dst
|
||||
staticRoutingRtr1->AddHostRouteTo (Ipv4Address ("10.20.1.2"), Ipv4Address ("10.10.1.2"), 2);
|
||||
staticRoutingRtr2->AddHostRouteTo (Ipv4Address ("10.20.1.2"), Ipv4Address ("10.10.2.2"), 2);
|
||||
|
||||
|
||||
// Two routes to same destination - setting separate metrics.
|
||||
// You can switch these to see how traffic gets diverted via different routes
|
||||
staticRoutingSrc->AddHostRouteTo (Ipv4Address ("10.20.1.2"), Ipv4Address ("10.1.1.2"), 1,5);
|
||||
staticRoutingSrc->AddHostRouteTo (Ipv4Address ("10.20.1.2"), Ipv4Address ("10.1.2.2"), 2,10);
|
||||
|
||||
|
||||
// Creating static routes from DST to Source pointing to Rtr1 VIA Rtr2(!)
|
||||
staticRoutingDst->AddHostRouteTo (Ipv4Address ("10.1.1.1"), Ipv4Address ("10.20.1.1"), 1);
|
||||
staticRoutingDstRtr->AddHostRouteTo (Ipv4Address ("10.1.1.1"), Ipv4Address ("10.10.2.1"), 2);
|
||||
staticRoutingRtr2->AddHostRouteTo (Ipv4Address ("10.1.1.1"), Ipv4Address ("10.1.2.1"), 1);
|
||||
|
||||
|
||||
staticRoutingDst->AddHostRouteTo (Ipv4Address ("10.1.2.1"), Ipv4Address ("10.20.1.1"), 1);
|
||||
staticRoutingDstRtr->AddHostRouteTo (Ipv4Address ("10.1.2.1"), Ipv4Address ("10.10.2.1"), 2);
|
||||
staticRoutingRtr2->AddHostRouteTo (Ipv4Address ("10.1.2.1"), Ipv4Address ("10.1.2.1"), 1);
|
||||
|
||||
Ipv4InterfaceAddress ifInAddrSrc=ipv4Src->GetAddress (1,0);
|
||||
|
||||
|
||||
// There are no apps that can utilize the Socket Option so doing the work directly..
|
||||
// Taken from tcp-large-transfer example
|
||||
|
||||
@@ -155,15 +155,15 @@ main (int argc, char *argv[])
|
||||
Ptr<Socket> srcSocket3 = Socket::CreateSocket (nSrc, TypeId::LookupByName ("ns3::TcpSocketFactory"));
|
||||
Ptr<Socket> srcSocket4 = Socket::CreateSocket (nSrc, TypeId::LookupByName ("ns3::TcpSocketFactory"));
|
||||
|
||||
|
||||
|
||||
uint16_t dstport = 12345;
|
||||
Ipv4Address dstaddr ("10.20.1.2");
|
||||
|
||||
|
||||
PacketSinkHelper sink ("ns3::TcpSocketFactory", InetSocketAddress (Ipv4Address::GetAny(), dstport));
|
||||
ApplicationContainer apps = sink.Install (nDst);
|
||||
apps.Start (Seconds (0.0));
|
||||
apps.Stop (Seconds (10.0));
|
||||
|
||||
|
||||
AsciiTraceHelper ascii;
|
||||
p2p.EnableAsciiAll (ascii.CreateFileStream ("socket-bound-tcp-static-routing.tr"));
|
||||
p2p.EnablePcapAll ("socket-bound-tcp-static-routing");
|
||||
@@ -204,7 +204,7 @@ void StartFlow(Ptr<Socket> localSocket,
|
||||
NS_LOG_INFO ("Starting flow at time " << Simulator::Now ().GetSeconds ());
|
||||
currentTxBytes = 0;
|
||||
localSocket->Bind ();
|
||||
localSocket->Connect (InetSocketAddress (servAddress, servPort));//connect
|
||||
localSocket->Connect (InetSocketAddress (servAddress, servPort)); //connect
|
||||
|
||||
// tell the tcp implementation to call WriteUntilBufferFull again
|
||||
// if we blocked and new tx buffer space becomes available
|
||||
|
||||
@@ -67,7 +67,7 @@ Sender::GetTypeId(void)
|
||||
MakeRandomVariableChecker())
|
||||
.AddTraceSource ("Tx", "A new packet is created and is sent",
|
||||
MakeTraceSourceAccessor (&Sender::m_txTrace))
|
||||
;
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
|
||||
@@ -99,10 +99,10 @@ void Sender::StartApplication()
|
||||
|
||||
if (m_socket == 0) {
|
||||
Ptr<SocketFactory> socketFactory = GetNode()->GetObject<SocketFactory>
|
||||
(UdpSocketFactory::GetTypeId());
|
||||
(UdpSocketFactory::GetTypeId());
|
||||
m_socket = socketFactory->CreateSocket ();
|
||||
m_socket->Bind ();
|
||||
}
|
||||
}
|
||||
|
||||
m_count = 0;
|
||||
|
||||
@@ -118,7 +118,7 @@ void Sender::StopApplication()
|
||||
Simulator::Cancel(m_sendEvent);
|
||||
// end Sender::StopApplication
|
||||
}
|
||||
|
||||
|
||||
void Sender::SendPacket()
|
||||
{
|
||||
// NS_LOG_FUNCTION_NOARGS ();
|
||||
@@ -139,9 +139,9 @@ void Sender::SendPacket()
|
||||
m_txTrace(packet);
|
||||
|
||||
if (++m_count < m_numPkts) {
|
||||
m_sendEvent = Simulator::Schedule(Seconds(m_interval.GetValue()),
|
||||
&Sender::SendPacket, this);
|
||||
}
|
||||
m_sendEvent = Simulator::Schedule(Seconds(m_interval.GetValue()),
|
||||
&Sender::SendPacket, this);
|
||||
}
|
||||
|
||||
// end Sender::SendPacket
|
||||
}
|
||||
@@ -162,7 +162,7 @@ Receiver::GetTypeId(void)
|
||||
UintegerValue(1603),
|
||||
MakeUintegerAccessor(&Receiver::m_port),
|
||||
MakeUintegerChecker<uint32_t>())
|
||||
;
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
|
||||
@@ -196,12 +196,12 @@ Receiver::StartApplication()
|
||||
|
||||
if (m_socket == 0) {
|
||||
Ptr<SocketFactory> socketFactory = GetNode()->GetObject<SocketFactory>
|
||||
(UdpSocketFactory::GetTypeId());
|
||||
(UdpSocketFactory::GetTypeId());
|
||||
m_socket = socketFactory->CreateSocket();
|
||||
InetSocketAddress local =
|
||||
InetSocketAddress(Ipv4Address::GetAny(), m_port);
|
||||
m_socket->Bind(local);
|
||||
}
|
||||
}
|
||||
|
||||
m_socket->SetRecvCallback(MakeCallback(&Receiver::Receive, this));
|
||||
|
||||
@@ -215,7 +215,7 @@ Receiver::StopApplication()
|
||||
|
||||
if (m_socket != 0) {
|
||||
m_socket->SetRecvCallback(MakeNullCallback<void, Ptr<Socket> > ());
|
||||
}
|
||||
}
|
||||
|
||||
// end Receiver::StopApplication
|
||||
}
|
||||
@@ -241,30 +241,30 @@ Receiver::Receive(Ptr<Socket> socket)
|
||||
Ptr<Packet> packet;
|
||||
Address from;
|
||||
while (packet = socket->RecvFrom(from)) {
|
||||
if (InetSocketAddress::IsMatchingType (from)) {
|
||||
InetSocketAddress address = InetSocketAddress::ConvertFrom (from);
|
||||
NS_LOG_INFO ("Received " << packet->GetSize() << " bytes from " <<
|
||||
address.GetIpv4());
|
||||
if (InetSocketAddress::IsMatchingType (from)) {
|
||||
InetSocketAddress address = InetSocketAddress::ConvertFrom (from);
|
||||
NS_LOG_INFO ("Received " << packet->GetSize() << " bytes from " <<
|
||||
address.GetIpv4());
|
||||
}
|
||||
|
||||
TimestampTag timestamp;
|
||||
// Should never not be found since the sender is adding it, but
|
||||
// you never know.
|
||||
if (packet->FindFirstMatchingByteTag(timestamp)) {
|
||||
Time tx = timestamp.GetTimestamp();
|
||||
|
||||
if (m_delay != 0) {
|
||||
m_delay->Update(Simulator::Now() - tx);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_calc != 0) {
|
||||
m_calc->Update();
|
||||
}
|
||||
|
||||
// end receiving packets
|
||||
}
|
||||
|
||||
TimestampTag timestamp;
|
||||
// Should never not be found since the sender is adding it, but
|
||||
// you never know.
|
||||
if (packet->FindFirstMatchingByteTag(timestamp)) {
|
||||
Time tx = timestamp.GetTimestamp();
|
||||
|
||||
if (m_delay != 0) {
|
||||
m_delay->Update(Simulator::Now() - tx);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_calc != 0) {
|
||||
m_calc->Update();
|
||||
}
|
||||
|
||||
// end receiving packets
|
||||
}
|
||||
|
||||
// end Receiver::Receive
|
||||
}
|
||||
|
||||
@@ -285,7 +285,7 @@ TimestampTag::GetTypeId(void)
|
||||
EmptyAttributeValue(),
|
||||
MakeTimeAccessor(&TimestampTag::GetTimestamp),
|
||||
MakeTimeChecker())
|
||||
;
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
TypeId
|
||||
|
||||
@@ -37,7 +37,7 @@ using namespace ns3;
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
//------------------------------------------------------
|
||||
class Sender: public Application {
|
||||
class Sender : public Application {
|
||||
public:
|
||||
static TypeId GetTypeId(void);
|
||||
Sender();
|
||||
@@ -72,7 +72,7 @@ private:
|
||||
|
||||
|
||||
//------------------------------------------------------
|
||||
class Receiver: public Application {
|
||||
class Receiver : public Application {
|
||||
public:
|
||||
static TypeId GetTypeId(void);
|
||||
Receiver();
|
||||
@@ -112,7 +112,7 @@ public:
|
||||
virtual uint32_t GetSerializedSize (void) const;
|
||||
virtual void Serialize (TagBuffer i) const;
|
||||
virtual void Deserialize (TagBuffer i);
|
||||
|
||||
|
||||
// these are our accessors to our tag structure
|
||||
void SetTimestamp(Time time);
|
||||
Time GetTimestamp(void) const;
|
||||
|
||||
@@ -99,21 +99,21 @@ int main(int argc, char *argv[]) {
|
||||
cmd.Parse (argc, argv);
|
||||
|
||||
if (format != "omnet" && format != "db") {
|
||||
NS_LOG_ERROR("Unknown output format '" << format << "'");
|
||||
return -1;
|
||||
}
|
||||
NS_LOG_ERROR("Unknown output format '" << format << "'");
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifndef STATS_HAS_SQLITE3
|
||||
if (format == "db") {
|
||||
NS_LOG_ERROR("sqlite support not compiled in.");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
{
|
||||
stringstream sstr("");
|
||||
sstr << distance;
|
||||
input = sstr.str();
|
||||
stringstream sstr("");
|
||||
sstr << distance;
|
||||
input = sstr.str();
|
||||
}
|
||||
|
||||
|
||||
@@ -163,12 +163,12 @@ int main(int argc, char *argv[]) {
|
||||
//-- Create a custom traffic source and sink
|
||||
//--------------------------------------------
|
||||
NS_LOG_INFO ("Create traffic source & sink.");
|
||||
Ptr<Node> appSource = NodeList::GetNode(0);
|
||||
Ptr<Node> appSource = NodeList::GetNode(0);
|
||||
Ptr<Sender> sender = CreateObject<Sender>();
|
||||
appSource->AddApplication(sender);
|
||||
sender->SetStartTime(Seconds(1));
|
||||
|
||||
Ptr<Node> appSink = NodeList::GetNode(1);
|
||||
Ptr<Node> appSink = NodeList::GetNode(1);
|
||||
Ptr<Receiver> receiver = CreateObject<Receiver>();
|
||||
appSink->AddApplication(receiver);
|
||||
receiver->SetStartTime(Seconds(0));
|
||||
@@ -231,7 +231,7 @@ int main(int argc, char *argv[]) {
|
||||
appTx->SetContext("node[0]");
|
||||
Config::Connect("/NodeList/0/ApplicationList/*/$Sender/Tx",
|
||||
MakeCallback(&PacketCounterCalculator::PacketUpdate,
|
||||
appTx));
|
||||
appTx));
|
||||
data.AddDataCalculator(appTx);
|
||||
|
||||
// Here a counter for received packets is directly manipulated by
|
||||
@@ -271,8 +271,8 @@ int main(int argc, char *argv[]) {
|
||||
appTxPkts->SetContext("node[0]");
|
||||
Config::Connect("/NodeList/0/ApplicationList/*/$Sender/Tx",
|
||||
MakeCallback
|
||||
(&PacketSizeMinMaxAvgTotalCalculator::PacketUpdate,
|
||||
appTxPkts));
|
||||
(&PacketSizeMinMaxAvgTotalCalculator::PacketUpdate,
|
||||
appTxPkts));
|
||||
data.AddDataCalculator(appTxPkts);
|
||||
|
||||
|
||||
@@ -294,7 +294,7 @@ int main(int argc, char *argv[]) {
|
||||
//-- Run the simulation
|
||||
//--------------------------------------------
|
||||
NS_LOG_INFO("Run Simulation.");
|
||||
Simulator::Run();
|
||||
Simulator::Run();
|
||||
Simulator::Destroy();
|
||||
|
||||
|
||||
@@ -307,16 +307,16 @@ int main(int argc, char *argv[]) {
|
||||
// Pick an output writer based in the requested format.
|
||||
Ptr<DataOutputInterface> output = 0;
|
||||
if (format == "omnet") {
|
||||
NS_LOG_INFO("Creating omnet formatted data output.");
|
||||
output = CreateObject<OmnetDataOutput>();
|
||||
} else if (format == "db") {
|
||||
NS_LOG_INFO("Creating omnet formatted data output.");
|
||||
output = CreateObject<OmnetDataOutput>();
|
||||
} else if (format == "db") {
|
||||
#ifdef STATS_HAS_SQLITE3
|
||||
NS_LOG_INFO("Creating sqlite formatted data output.");
|
||||
output = CreateObject<SqliteDataOutput>();
|
||||
#endif
|
||||
} else {
|
||||
NS_LOG_ERROR("Unknown output format " << format);
|
||||
}
|
||||
} else {
|
||||
NS_LOG_ERROR("Unknown output format " << format);
|
||||
}
|
||||
|
||||
// Finally, have that writer interrogate the DataCollector and save
|
||||
// the results.
|
||||
|
||||
@@ -75,7 +75,7 @@ main (int argc, char *argv[])
|
||||
|
||||
NS_LOG_INFO ("Create applications.");
|
||||
//
|
||||
// Create a packet sink on the star "hub" to receive packets.
|
||||
// Create a packet sink on the star "hub" to receive packets.
|
||||
//
|
||||
uint16_t port = 50000;
|
||||
Address hubLocalAddress (InetSocketAddress (Ipv4Address::GetAny (), port));
|
||||
@@ -98,7 +98,7 @@ main (int argc, char *argv[])
|
||||
AddressValue remoteAddress (InetSocketAddress (star.GetHubIpv4Address (i), port));
|
||||
onOffHelper.SetAttribute ("Remote", remoteAddress);
|
||||
spokeApps.Add (onOffHelper.Install (star.GetSpokeNode (i)));
|
||||
}
|
||||
}
|
||||
spokeApps.Start (Seconds (1.0));
|
||||
spokeApps.Stop (Seconds (10.0));
|
||||
|
||||
|
||||
@@ -152,7 +152,7 @@ int main (int argc, char *argv[])
|
||||
|
||||
// Create and bind the socket...
|
||||
Ptr<Socket> localSocket =
|
||||
Socket::CreateSocket (n0n1.Get (0), TcpSocketFactory::GetTypeId ());
|
||||
Socket::CreateSocket (n0n1.Get (0), TcpSocketFactory::GetTypeId ());
|
||||
localSocket->Bind ();
|
||||
|
||||
// Trace changes to the congestion window
|
||||
@@ -191,7 +191,7 @@ void StartFlow(Ptr<Socket> localSocket,
|
||||
uint16_t servPort)
|
||||
{
|
||||
NS_LOG_LOGIC("Starting flow at time " << Simulator::Now ().GetSeconds ());
|
||||
localSocket->Connect (InetSocketAddress (servAddress, servPort));//connect
|
||||
localSocket->Connect (InetSocketAddress (servAddress, servPort)); //connect
|
||||
|
||||
// tell the tcp implementation to call WriteUntilBufferFull again
|
||||
// if we blocked and new tx buffer space becomes available
|
||||
|
||||
@@ -103,9 +103,9 @@ int main (int argc, char *argv[])
|
||||
DoubleValue rate(errRate);
|
||||
RandomVariableValue u01(UniformVariable (0.0, 1.0));
|
||||
Ptr<RateErrorModel> em1 =
|
||||
CreateObjectWithAttributes<RateErrorModel> ("RanVar", u01, "ErrorRate", rate);
|
||||
CreateObjectWithAttributes<RateErrorModel> ("RanVar", u01, "ErrorRate", rate);
|
||||
Ptr<RateErrorModel> em2 =
|
||||
CreateObjectWithAttributes<RateErrorModel> ("RanVar", u01, "ErrorRate", rate);
|
||||
CreateObjectWithAttributes<RateErrorModel> ("RanVar", u01, "ErrorRate", rate);
|
||||
|
||||
// This enables the specified errRate on both link endpoints.
|
||||
p2pInterfaces.Get(0)->SetAttribute("ReceiveErrorModel", PointerValue (em1));
|
||||
@@ -122,7 +122,7 @@ int main (int argc, char *argv[])
|
||||
|
||||
// This sets up two TCP flows, one from A -> B, one from B -> A.
|
||||
for (int i = 0, j = 1; i < 2; j--, i++)
|
||||
{
|
||||
{
|
||||
Address remoteAddress(InetSocketAddress(ipv4Interfaces.GetAddress (i), servPort));
|
||||
OnOffHelper clientHelper ("ns3::TcpSocketFactory", remoteAddress);
|
||||
clientHelper.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1)));
|
||||
|
||||
@@ -57,8 +57,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (MaxNodes < 2)
|
||||
{
|
||||
std::cerr << "--nodes: must be >= 2" << std::endl;
|
||||
return 1;
|
||||
std::cerr << "--nodes: must be >= 2" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
csma.SetChannelAttribute ("DataRate", DataRateValue (DataRate(100 * 1000 * 1000)));
|
||||
csma.SetChannelAttribute ("Delay", TimeValue (MicroSeconds (200)));
|
||||
@@ -115,24 +115,24 @@ int main(int argc, char *argv[])
|
||||
sinkApp.Stop (Seconds (30.0));
|
||||
|
||||
// This tells every node on the network to start a flow to all other nodes on the network ...
|
||||
for (unsigned int i = 0 ; i < MaxNodes;i++)
|
||||
for (unsigned int i = 0 ; i < MaxNodes; i++)
|
||||
{
|
||||
for (unsigned int j = 0 ; j < MaxNodes;j++)
|
||||
for (unsigned int j = 0 ; j < MaxNodes; j++)
|
||||
{
|
||||
if (i == j)
|
||||
{ // ...but we don't want a node to talk to itself.
|
||||
continue;
|
||||
continue;
|
||||
}
|
||||
Address remoteAddress(InetSocketAddress(ipv4Interfaces.GetAddress (j), servPort));
|
||||
OnOffHelper clientHelper ("ns3::TcpSocketFactory", remoteAddress);
|
||||
clientHelper.SetAttribute
|
||||
("OnTime", RandomVariableValue (ConstantVariable (1)));
|
||||
("OnTime", RandomVariableValue (ConstantVariable (1)));
|
||||
clientHelper.SetAttribute
|
||||
("OffTime", RandomVariableValue (ConstantVariable (0)));
|
||||
("OffTime", RandomVariableValue (ConstantVariable (0)));
|
||||
ApplicationContainer clientApp = clientHelper.Install(n.Get(i));
|
||||
clientApp.Start (Seconds (j)); /* delay startup depending on node number */
|
||||
clientApp.Stop (Seconds (j + runtime));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
csma.EnablePcapAll ("tcp-nsc-zoo", false);
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
\ | /
|
||||
\|/
|
||||
n1---n0---n5
|
||||
/|\
|
||||
/| \
|
||||
/ | \
|
||||
n8 n7 n6
|
||||
*/
|
||||
@@ -96,9 +96,9 @@ main (int argc, char *argv[])
|
||||
//Collect an adjacency list of nodes for the p2p topology
|
||||
std::vector<NodeContainer> nodeAdjacencyList(N-1);
|
||||
for(uint32_t i=0; i<nodeAdjacencyList.size(); ++i)
|
||||
{
|
||||
nodeAdjacencyList[i] = NodeContainer (serverNode, clientNodes.Get (i));
|
||||
}
|
||||
{
|
||||
nodeAdjacencyList[i] = NodeContainer (serverNode, clientNodes.Get (i));
|
||||
}
|
||||
|
||||
// We create the channels first without any IP addressing information
|
||||
NS_LOG_INFO ("Create channels.");
|
||||
@@ -107,21 +107,21 @@ main (int argc, char *argv[])
|
||||
p2p.SetChannelAttribute ("Delay", StringValue ("2ms"));
|
||||
std::vector<NetDeviceContainer> deviceAdjacencyList(N-1);
|
||||
for(uint32_t i=0; i<deviceAdjacencyList.size(); ++i)
|
||||
{
|
||||
deviceAdjacencyList[i] = p2p.Install (nodeAdjacencyList[i]);
|
||||
}
|
||||
{
|
||||
deviceAdjacencyList[i] = p2p.Install (nodeAdjacencyList[i]);
|
||||
}
|
||||
|
||||
// Later, we add IP addresses.
|
||||
// Later, we add IP addresses.
|
||||
NS_LOG_INFO ("Assign IP Addresses.");
|
||||
Ipv4AddressHelper ipv4;
|
||||
std::vector<Ipv4InterfaceContainer> interfaceAdjacencyList(N-1);
|
||||
for(uint32_t i=0; i<interfaceAdjacencyList.size(); ++i)
|
||||
{
|
||||
std::ostringstream subnet;
|
||||
subnet<<"10.1."<<i+1<<".0";
|
||||
ipv4.SetBase (subnet.str().c_str(), "255.255.255.0");
|
||||
interfaceAdjacencyList[i] = ipv4.Assign (deviceAdjacencyList[i]);
|
||||
}
|
||||
{
|
||||
std::ostringstream subnet;
|
||||
subnet<<"10.1."<<i+1<<".0";
|
||||
ipv4.SetBase (subnet.str().c_str(), "255.255.255.0");
|
||||
interfaceAdjacencyList[i] = ipv4.Assign (deviceAdjacencyList[i]);
|
||||
}
|
||||
|
||||
//Turn on global static routing
|
||||
Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
|
||||
@@ -137,19 +137,19 @@ main (int argc, char *argv[])
|
||||
// Create the OnOff applications to send TCP to the server
|
||||
OnOffHelper clientHelper ("ns3::TcpSocketFactory", Address ());
|
||||
clientHelper.SetAttribute
|
||||
("OnTime", RandomVariableValue (ConstantVariable (1)));
|
||||
("OnTime", RandomVariableValue (ConstantVariable (1)));
|
||||
clientHelper.SetAttribute
|
||||
("OffTime", RandomVariableValue (ConstantVariable (0)));
|
||||
("OffTime", RandomVariableValue (ConstantVariable (0)));
|
||||
//normally wouldn't need a loop here but the server IP address is different
|
||||
//on each p2p subnet
|
||||
ApplicationContainer clientApps;
|
||||
for(uint32_t i=0; i<clientNodes.GetN(); ++i)
|
||||
{
|
||||
AddressValue remoteAddress
|
||||
(InetSocketAddress (interfaceAdjacencyList[i].GetAddress (0), port));
|
||||
clientHelper.SetAttribute ("Remote", remoteAddress);
|
||||
clientApps.Add(clientHelper.Install (clientNodes.Get(i)));
|
||||
}
|
||||
{
|
||||
AddressValue remoteAddress
|
||||
(InetSocketAddress (interfaceAdjacencyList[i].GetAddress (0), port));
|
||||
clientHelper.SetAttribute ("Remote", remoteAddress);
|
||||
clientApps.Add(clientHelper.Install (clientNodes.Get(i)));
|
||||
}
|
||||
clientApps.Start (Seconds (1.0));
|
||||
clientApps.Stop (Seconds (10.0));
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ public:
|
||||
void Setup (Ptr<Socket> socket, Address address, uint32_t packetSize, uint32_t nPackets, DataRate dataRate);
|
||||
|
||||
private:
|
||||
virtual void StartApplication (void);
|
||||
virtual void StartApplication (void);
|
||||
virtual void StopApplication (void);
|
||||
|
||||
void ScheduleTx (void);
|
||||
@@ -186,8 +186,8 @@ main (int argc, char *argv[])
|
||||
devices = pointToPoint.Install (nodes);
|
||||
|
||||
Ptr<RateErrorModel> em = CreateObjectWithAttributes<RateErrorModel> (
|
||||
"RanVar", RandomVariableValue (UniformVariable (0., 1.)),
|
||||
"ErrorRate", DoubleValue (0.00001));
|
||||
"RanVar", RandomVariableValue (UniformVariable (0., 1.)),
|
||||
"ErrorRate", DoubleValue (0.00001));
|
||||
devices.Get (1)->SetAttribute ("ReceiveErrorModel", PointerValue (em));
|
||||
|
||||
InternetStackHelper stack;
|
||||
|
||||
@@ -24,7 +24,7 @@ using namespace ns3;
|
||||
|
||||
NS_LOG_COMPONENT_DEFINE ("FirstScriptExample");
|
||||
|
||||
int
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
LogComponentEnable("UdpEchoClientApplication", LOG_LEVEL_INFO);
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include "ns3/trace-source-accessor.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
|
||||
using namespace ns3;
|
||||
|
||||
class MyObject : public Object
|
||||
@@ -34,10 +34,10 @@ public:
|
||||
.AddTraceSource ("MyInteger",
|
||||
"An integer value to trace.",
|
||||
MakeTraceSourceAccessor (&MyObject::m_myInt))
|
||||
;
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
|
||||
|
||||
MyObject () {}
|
||||
TracedValue<int32_t> m_myInt;
|
||||
};
|
||||
|
||||
@@ -20,7 +20,7 @@ NS_LOG_COMPONENT_DEFINE ("HelloSimulator");
|
||||
|
||||
using namespace ns3;
|
||||
|
||||
int
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
NS_LOG_UNCOND ("Hello Simulator");
|
||||
|
||||
@@ -69,7 +69,7 @@ public:
|
||||
void Setup (Ptr<Socket> socket, Address address, uint32_t packetSize, uint32_t nPackets, DataRate dataRate);
|
||||
|
||||
private:
|
||||
virtual void StartApplication (void);
|
||||
virtual void StartApplication (void);
|
||||
virtual void StopApplication (void);
|
||||
|
||||
void ScheduleTx (void);
|
||||
@@ -188,8 +188,8 @@ main (int argc, char *argv[])
|
||||
devices = pointToPoint.Install (nodes);
|
||||
|
||||
Ptr<RateErrorModel> em = CreateObjectWithAttributes<RateErrorModel> (
|
||||
"RanVar", RandomVariableValue (UniformVariable (0., 1.)),
|
||||
"ErrorRate", DoubleValue (0.00001));
|
||||
"RanVar", RandomVariableValue (UniformVariable (0., 1.)),
|
||||
"ErrorRate", DoubleValue (0.00001));
|
||||
devices.Get (1)->SetAttribute ("ReceiveErrorModel", PointerValue (em));
|
||||
|
||||
InternetStackHelper stack;
|
||||
|
||||
@@ -115,7 +115,7 @@ main (int argc, char *argv[])
|
||||
|
||||
client.SetFill(apps.Get (0), 0xa5, 1024);
|
||||
|
||||
uint8_t fill[] = {0, 1, 2, 3, 4, 5, 6};
|
||||
uint8_t fill[] = { 0, 1, 2, 3, 4, 5, 6};
|
||||
client.SetFill(apps.Get (0), fill, sizeof(fill), 1024);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ set style line 5 linewidth 5\n\
|
||||
set style line 6 linewidth 5\n\
|
||||
set style line 7 linewidth 5\n\
|
||||
set style line 8 linewidth 5\n\
|
||||
set style increment user");
|
||||
set style increment user" );
|
||||
yansplot.GenerateOutput (yansfile);
|
||||
yansfile.close ();
|
||||
|
||||
@@ -100,7 +100,7 @@ set style line 5 linewidth 5\n\
|
||||
set style line 6 linewidth 5\n\
|
||||
set style line 7 linewidth 5\n\
|
||||
set style line 8 linewidth 5\n\
|
||||
set style increment user");
|
||||
set style increment user" );
|
||||
|
||||
nistplot.GenerateOutput (nistfile);
|
||||
nistfile.close ();
|
||||
|
||||
@@ -50,7 +50,8 @@ private:
|
||||
};
|
||||
|
||||
Experiment::Experiment ()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
Experiment::Experiment (std::string name)
|
||||
: m_output (name)
|
||||
|
||||
@@ -47,14 +47,15 @@ private:
|
||||
Vector GetPosition (Ptr<Node> node);
|
||||
Ptr<Socket> SetupPacketReceive (Ptr<Node> node);
|
||||
void GenerateTraffic (Ptr<Socket> socket, uint32_t pktSize,
|
||||
uint32_t pktCount, Time pktInterval );
|
||||
uint32_t pktCount, Time pktInterval );
|
||||
|
||||
uint32_t m_pktsTotal;
|
||||
Gnuplot2dDataset m_output;
|
||||
};
|
||||
|
||||
Experiment::Experiment ()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
Experiment::Experiment (std::string name)
|
||||
: m_output (name)
|
||||
@@ -82,7 +83,7 @@ Experiment::ReceivePacket (Ptr<Socket> socket)
|
||||
Ptr<Packet> packet;
|
||||
while (packet = socket->Recv ())
|
||||
{
|
||||
m_pktsTotal ++;
|
||||
m_pktsTotal++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,46 +180,46 @@ int main (int argc, char *argv[])
|
||||
cmd.Parse (argc, argv);
|
||||
|
||||
Gnuplot gnuplot = Gnuplot ("clear-channel.eps");
|
||||
|
||||
|
||||
for (uint32_t i = 0; i < modes.size(); i++)
|
||||
{
|
||||
std::cout << modes[i] << std::endl;
|
||||
Gnuplot2dDataset dataset (modes[i]);
|
||||
{
|
||||
std::cout << modes[i] << std::endl;
|
||||
Gnuplot2dDataset dataset (modes[i]);
|
||||
|
||||
for (double rss = -102.0; rss <= -80.0; rss += 0.5)
|
||||
{
|
||||
Experiment experiment;
|
||||
dataset.SetStyle (Gnuplot2dDataset::LINES);
|
||||
for (double rss = -102.0; rss <= -80.0; rss += 0.5)
|
||||
{
|
||||
Experiment experiment;
|
||||
dataset.SetStyle (Gnuplot2dDataset::LINES);
|
||||
|
||||
WifiHelper wifi;
|
||||
wifi.SetStandard (WIFI_PHY_STANDARD_80211b);
|
||||
NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();
|
||||
Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode",
|
||||
StringValue (modes[i]));
|
||||
wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
|
||||
"DataMode",StringValue(modes[i]),
|
||||
"ControlMode",StringValue(modes[i]));
|
||||
wifiMac.SetType ("ns3::AdhocWifiMac");
|
||||
WifiHelper wifi;
|
||||
wifi.SetStandard (WIFI_PHY_STANDARD_80211b);
|
||||
NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();
|
||||
Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode",
|
||||
StringValue (modes[i]));
|
||||
wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
|
||||
"DataMode",StringValue(modes[i]),
|
||||
"ControlMode",StringValue(modes[i]));
|
||||
wifiMac.SetType ("ns3::AdhocWifiMac");
|
||||
|
||||
YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
|
||||
YansWifiChannelHelper wifiChannel ;
|
||||
wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel");
|
||||
wifiChannel.AddPropagationLoss ("ns3::FixedRssLossModel","Rss",DoubleValue(rss));
|
||||
YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
|
||||
YansWifiChannelHelper wifiChannel ;
|
||||
wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel");
|
||||
wifiChannel.AddPropagationLoss ("ns3::FixedRssLossModel","Rss",DoubleValue(rss));
|
||||
|
||||
|
||||
NS_LOG_DEBUG (modes[i]);
|
||||
experiment = Experiment (modes[i]);
|
||||
wifiPhy.Set ("EnergyDetectionThreshold", DoubleValue (-110.0) );
|
||||
wifiPhy.Set ("CcaMode1Threshold", DoubleValue (-110.0) );
|
||||
wifiPhy.Set ("TxPowerStart", DoubleValue (15.0) );
|
||||
wifiPhy.Set ("RxGain", DoubleValue (0) );
|
||||
wifiPhy.Set ("RxNoiseFigure", DoubleValue (7) );
|
||||
uint32_t pktsRecvd = experiment.Run (wifi, wifiPhy, wifiMac, wifiChannel);
|
||||
dataset.Add (rss, pktsRecvd);
|
||||
}
|
||||
NS_LOG_DEBUG (modes[i]);
|
||||
experiment = Experiment (modes[i]);
|
||||
wifiPhy.Set ("EnergyDetectionThreshold", DoubleValue (-110.0) );
|
||||
wifiPhy.Set ("CcaMode1Threshold", DoubleValue (-110.0) );
|
||||
wifiPhy.Set ("TxPowerStart", DoubleValue (15.0) );
|
||||
wifiPhy.Set ("RxGain", DoubleValue (0) );
|
||||
wifiPhy.Set ("RxNoiseFigure", DoubleValue (7) );
|
||||
uint32_t pktsRecvd = experiment.Run (wifi, wifiPhy, wifiMac, wifiChannel);
|
||||
dataset.Add (rss, pktsRecvd);
|
||||
}
|
||||
|
||||
gnuplot.AddDataset (dataset);
|
||||
}
|
||||
gnuplot.AddDataset (dataset);
|
||||
}
|
||||
gnuplot.SetTerminal ("postscript eps color enh \"Times-BoldItalic\"");
|
||||
gnuplot.SetLegend ("RSS(dBm)", "Number of packets received");
|
||||
gnuplot.SetExtra ("set xrange [-102:-83]");
|
||||
|
||||
@@ -46,17 +46,17 @@ void experiment (bool enableCtsRts)
|
||||
// 0. Enable or disable CTS/RTS
|
||||
UintegerValue ctsThr = (enableCtsRts ? UintegerValue (100) : UintegerValue (2200));
|
||||
Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", ctsThr);
|
||||
|
||||
|
||||
// 1. Create 3 nodes
|
||||
NodeContainer nodes;
|
||||
nodes.Create (3);
|
||||
|
||||
|
||||
// 2. Place nodes somehow, this is required by every wireless simulation
|
||||
for (size_t i = 0; i < 3; ++i)
|
||||
{
|
||||
nodes.Get(i)->AggregateObject (CreateObject<ConstantPositionMobilityModel> ());
|
||||
}
|
||||
|
||||
|
||||
// 3. Create propagation loss matrix
|
||||
Ptr<MatrixPropagationLossModel> lossModel = CreateObject<MatrixPropagationLossModel> ();
|
||||
lossModel->SetDefaultLoss (200); // set default loss to 200 dB (no link)
|
||||
@@ -67,7 +67,7 @@ void experiment (bool enableCtsRts)
|
||||
Ptr<YansWifiChannel> wifiChannel = CreateObject <YansWifiChannel> ();
|
||||
wifiChannel->SetPropagationLossModel (lossModel);
|
||||
wifiChannel->SetPropagationDelayModel (CreateObject <ConstantSpeedPropagationDelayModel> ());
|
||||
|
||||
|
||||
// 5. Install wireless devices
|
||||
WifiHelper wifi;
|
||||
wifi.SetStandard (WIFI_PHY_STANDARD_80211b);
|
||||
@@ -94,7 +94,7 @@ void experiment (bool enableCtsRts)
|
||||
Ipv4AddressHelper ipv4;
|
||||
ipv4.SetBase ("10.0.0.0", "255.0.0.0");
|
||||
ipv4.Assign (devices);
|
||||
|
||||
|
||||
// 7. Install applications: two CBR streams each saturating the channel
|
||||
ApplicationContainer cbrApps;
|
||||
uint16_t cbrPort = 12345;
|
||||
@@ -120,7 +120,7 @@ void experiment (bool enableCtsRts)
|
||||
// we also use separate UDP applications that will send a single
|
||||
// packet before the CBR flows start.
|
||||
// This is a workround for the lack of perfect ARP, see Bug 187
|
||||
// http://www.nsnam.org/bugzilla/show_bug.cgi?id=187
|
||||
// http://www.nsnam.org/bugzilla/show_bug.cgi?id=187
|
||||
|
||||
uint16_t echoPort = 9;
|
||||
UdpEchoClientHelper echoClientHelper (Ipv4Address ("10.0.0.2"), echoPort);
|
||||
@@ -128,24 +128,24 @@ void experiment (bool enableCtsRts)
|
||||
echoClientHelper.SetAttribute ("Interval", TimeValue (Seconds (0.1)));
|
||||
echoClientHelper.SetAttribute ("PacketSize", UintegerValue (10));
|
||||
ApplicationContainer pingApps;
|
||||
|
||||
|
||||
// again using different start times to workaround Bug 388 and Bug 912
|
||||
echoClientHelper.SetAttribute ("StartTime", TimeValue (Seconds (0.001)));
|
||||
pingApps.Add (echoClientHelper.Install (nodes.Get (0)));
|
||||
echoClientHelper.SetAttribute ("StartTime", TimeValue (Seconds (0.006)));
|
||||
pingApps.Add (echoClientHelper.Install (nodes.Get (2)));
|
||||
pingApps.Add (echoClientHelper.Install (nodes.Get (2)));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 8. Install FlowMonitor on all nodes
|
||||
FlowMonitorHelper flowmon;
|
||||
Ptr<FlowMonitor> monitor = flowmon.InstallAll();
|
||||
|
||||
|
||||
// 9. Run simulation for 10 seconds
|
||||
Simulator::Stop (Seconds (10));
|
||||
Simulator::Run ();
|
||||
|
||||
|
||||
// 10. Print per flow statistics
|
||||
monitor->CheckForLostPackets ();
|
||||
Ptr<Ipv4FlowClassifier> classifier = DynamicCast<Ipv4FlowClassifier> (flowmon.GetClassifier ());
|
||||
@@ -161,7 +161,7 @@ void experiment (bool enableCtsRts)
|
||||
std::cout << " Throughput: " << i->second.rxBytes * 8.0 / 10.0 / 1024 / 1024 << " Mbps\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 11. Cleanup
|
||||
Simulator::Destroy ();
|
||||
}
|
||||
@@ -173,6 +173,6 @@ int main (int argc, char **argv)
|
||||
std::cout << "------------------------------------------------\n";
|
||||
std::cout << "Hidden station experiment with RTS/CTS enabled:\n";
|
||||
experiment (true);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
// This program configures a grid (default 5x5) of nodes on an
|
||||
// 802.11b physical layer, with
|
||||
// 802.11b NICs in adhoc mode, and by default, sends one packet of 1000
|
||||
// (application) bytes to node 1.
|
||||
// (application) bytes to node 1.
|
||||
//
|
||||
// The default layout is like this, on a 2-D grid.
|
||||
//
|
||||
@@ -134,7 +134,7 @@ int main (int argc, char *argv[])
|
||||
cmd.AddValue ("numNodes", "number of nodes", numNodes);
|
||||
cmd.AddValue ("sinkNode", "Receiver node number", sinkNode);
|
||||
cmd.AddValue ("sourceNode", "Sender node number", sourceNode);
|
||||
|
||||
|
||||
cmd.Parse (argc, argv);
|
||||
// Convert to time object
|
||||
Time interPacketInterval = Seconds (interval);
|
||||
@@ -173,19 +173,19 @@ int main (int argc, char *argv[])
|
||||
wifi.SetStandard (WIFI_PHY_STANDARD_80211b);
|
||||
wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
|
||||
"DataMode",StringValue(phyMode),
|
||||
"ControlMode",StringValue(phyMode));
|
||||
"ControlMode",StringValue(phyMode));
|
||||
// Set it to adhoc mode
|
||||
wifiMac.SetType ("ns3::AdhocWifiMac");
|
||||
NetDeviceContainer devices = wifi.Install (wifiPhy, wifiMac, c);
|
||||
|
||||
MobilityHelper mobility;
|
||||
mobility.SetPositionAllocator ("ns3::GridPositionAllocator",
|
||||
"MinX", DoubleValue (0.0),
|
||||
"MinY", DoubleValue (0.0),
|
||||
"DeltaX", DoubleValue (distance),
|
||||
"DeltaY", DoubleValue (distance),
|
||||
"GridWidth", UintegerValue (5),
|
||||
"LayoutType", StringValue ("RowFirst"));
|
||||
"MinX", DoubleValue (0.0),
|
||||
"MinY", DoubleValue (0.0),
|
||||
"DeltaX", DoubleValue (distance),
|
||||
"DeltaY", DoubleValue (distance),
|
||||
"GridWidth", UintegerValue (5),
|
||||
"LayoutType", StringValue ("RowFirst"));
|
||||
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
|
||||
mobility.Install (c);
|
||||
|
||||
@@ -227,7 +227,7 @@ int main (int argc, char *argv[])
|
||||
|
||||
// To do-- enable an IP-level trace that shows forwarding events only
|
||||
}
|
||||
|
||||
|
||||
// Give OLSR time to converge-- 30 seconds perhaps
|
||||
Simulator::Schedule (Seconds (30.0), &GenerateTraffic,
|
||||
source, packetSize, numPackets, interPacketInterval);
|
||||
|
||||
@@ -79,7 +79,7 @@ static void GenerateTraffic (Ptr<Socket> socket, uint32_t pktSize,
|
||||
{
|
||||
socket->Send (Create<Packet> (pktSize));
|
||||
Simulator::Schedule (pktInterval, &GenerateTraffic,
|
||||
socket, pktSize,pktCount-1, pktInterval);
|
||||
socket, pktSize,pktCount-1, pktInterval);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -105,7 +105,7 @@ int main (int argc, char *argv[])
|
||||
cmd.AddValue ("numPackets", "number of packets generated", numPackets);
|
||||
cmd.AddValue ("interval", "interval (seconds) between packets", interval);
|
||||
cmd.AddValue ("verbose", "turn on all WifiNetDevice log components", verbose);
|
||||
|
||||
|
||||
cmd.Parse (argc, argv);
|
||||
// Convert to time object
|
||||
Time interPacketInterval = Seconds (interval);
|
||||
@@ -147,7 +147,7 @@ int main (int argc, char *argv[])
|
||||
NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();
|
||||
wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
|
||||
"DataMode",StringValue(phyMode),
|
||||
"ControlMode",StringValue(phyMode));
|
||||
"ControlMode",StringValue(phyMode));
|
||||
// Set it to adhoc mode
|
||||
wifiMac.SetType ("ns3::AdhocWifiMac");
|
||||
NetDeviceContainer devices = wifi.Install (wifiPhy, wifiMac, c);
|
||||
|
||||
@@ -149,7 +149,7 @@ int main (int argc, char *argv[])
|
||||
cmd.AddValue ("PpacketSize", "size of application packet sent", PpacketSize);
|
||||
cmd.AddValue ("IpacketSize", "size of interfering packet sent", IpacketSize);
|
||||
cmd.AddValue ("verbose", "turn on all WifiNetDevice log components", verbose);
|
||||
|
||||
|
||||
cmd.Parse (argc, argv);
|
||||
// Convert to time object
|
||||
Time interPacketInterval = Seconds (interval);
|
||||
@@ -190,7 +190,7 @@ int main (int argc, char *argv[])
|
||||
NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();
|
||||
wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
|
||||
"DataMode",StringValue(phyMode),
|
||||
"ControlMode",StringValue(phyMode));
|
||||
"ControlMode",StringValue(phyMode));
|
||||
// Set it to adhoc mode
|
||||
wifiMac.SetType ("ns3::AdhocWifiMac");
|
||||
NetDeviceContainer devices = wifi.Install (wifiPhy, wifiMac, c.Get (0));
|
||||
@@ -241,7 +241,7 @@ int main (int argc, char *argv[])
|
||||
|
||||
// Tracing
|
||||
wifiPhy.EnablePcap ("wifi-simple-interference", devices.Get (0));
|
||||
|
||||
|
||||
// Output what we are doing
|
||||
NS_LOG_UNCOND ("Primary packet RSS=" << Prss << " dBm and interferer RSS=" << Irss << " dBm at time offset=" << delta << " ms");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user