39 #include "ns3/packet.h" |
39 #include "ns3/packet.h" |
40 #include "ns3/packet-sink-helper.h" |
40 #include "ns3/packet-sink-helper.h" |
41 #include "ns3/packet-socket-helper.h" |
41 #include "ns3/packet-socket-helper.h" |
42 #include "ns3/packet-socket-address.h" |
42 #include "ns3/packet-socket-address.h" |
43 #include "ns3/pointer.h" |
43 #include "ns3/pointer.h" |
44 #include "ns3/random-variable.h" |
|
45 #include "ns3/simple-channel.h" |
44 #include "ns3/simple-channel.h" |
46 #include "ns3/simulator.h" |
45 #include "ns3/simulator.h" |
47 #include "ns3/string.h" |
46 #include "ns3/string.h" |
48 #include "ns3/test.h" |
47 #include "ns3/test.h" |
49 #include "ns3/uinteger.h" |
48 #include "ns3/uinteger.h" |
132 // |
131 // |
133 // Make packets be sent about every DefaultPacketSize / DataRate = |
132 // Make packets be sent about every DefaultPacketSize / DataRate = |
134 // 4096 bits / (5000 bits/second) = 0.82 second. |
133 // 4096 bits / (5000 bits/second) = 0.82 second. |
135 OnOffHelper onoff ("ns3::UdpSocketFactory", |
134 OnOffHelper onoff ("ns3::UdpSocketFactory", |
136 Address (InetSocketAddress (Ipv4Address ("10.1.1.2"), port))); |
135 Address (InetSocketAddress (Ipv4Address ("10.1.1.2"), port))); |
137 onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1))); |
136 onoff.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]")); |
138 onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0))); |
137 onoff.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]")); |
139 onoff.SetAttribute ("DataRate", DataRateValue (DataRate (5000))); |
138 onoff.SetAttribute ("DataRate", DataRateValue (DataRate (5000))); |
140 |
139 |
141 ApplicationContainer app = onoff.Install (terminals.Get (0)); |
140 ApplicationContainer app = onoff.Install (terminals.Get (0)); |
142 app.Start (Seconds (1.0)); |
141 app.Start (Seconds (1.0)); |
143 app.Stop (Seconds (10.0)); |
142 app.Stop (Seconds (10.0)); |
248 // |
247 // |
249 // Make packets be sent about every DefaultPacketSize / DataRate = |
248 // Make packets be sent about every DefaultPacketSize / DataRate = |
250 // 4096 bits / (5000 bits/second) = 0.82 second. |
249 // 4096 bits / (5000 bits/second) = 0.82 second. |
251 OnOffHelper onoff ("ns3::UdpSocketFactory", |
250 OnOffHelper onoff ("ns3::UdpSocketFactory", |
252 Address (InetSocketAddress (Ipv4Address ("255.255.255.255"), port))); |
251 Address (InetSocketAddress (Ipv4Address ("255.255.255.255"), port))); |
253 onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1))); |
252 onoff.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]")); |
254 onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0))); |
253 onoff.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]")); |
255 onoff.SetAttribute ("DataRate", DataRateValue (DataRate (5000))); |
254 onoff.SetAttribute ("DataRate", DataRateValue (DataRate (5000))); |
256 |
255 |
257 ApplicationContainer app = onoff.Install (c0.Get (0)); |
256 ApplicationContainer app = onoff.Install (c0.Get (0)); |
258 // Start the application |
257 // Start the application |
259 app.Start (Seconds (1.0)); |
258 app.Start (Seconds (1.0)); |
405 // |
404 // |
406 // Make packets be sent about every defaultPacketSize / dataRate = |
405 // Make packets be sent about every defaultPacketSize / dataRate = |
407 // 4096 bits / (5000 bits/second) = 0.82 second. |
406 // 4096 bits / (5000 bits/second) = 0.82 second. |
408 OnOffHelper onoff ("ns3::UdpSocketFactory", |
407 OnOffHelper onoff ("ns3::UdpSocketFactory", |
409 Address (InetSocketAddress (multicastGroup, multicastPort))); |
408 Address (InetSocketAddress (multicastGroup, multicastPort))); |
410 onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1))); |
409 onoff.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]")); |
411 onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0))); |
410 onoff.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]")); |
412 onoff.SetAttribute ("DataRate", DataRateValue (DataRate (5000))); |
411 onoff.SetAttribute ("DataRate", DataRateValue (DataRate (5000))); |
413 |
412 |
414 ApplicationContainer srcC = onoff.Install (c0.Get (0)); |
413 ApplicationContainer srcC = onoff.Install (c0.Get (0)); |
415 |
414 |
416 // |
415 // |
527 // |
526 // |
528 // Make packets be sent about every defaultPacketSize / dataRate = |
527 // Make packets be sent about every defaultPacketSize / dataRate = |
529 // 4096 bits / (5000 bits/second) = 0.82 second. |
528 // 4096 bits / (5000 bits/second) = 0.82 second. |
530 OnOffHelper onoff ("ns3::UdpSocketFactory", |
529 OnOffHelper onoff ("ns3::UdpSocketFactory", |
531 Address (InetSocketAddress (interfaces.GetAddress (1), port))); |
530 Address (InetSocketAddress (interfaces.GetAddress (1), port))); |
532 onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1))); |
531 onoff.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]")); |
533 onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0))); |
532 onoff.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]")); |
534 onoff.SetAttribute ("DataRate", DataRateValue (DataRate (5000))); |
533 onoff.SetAttribute ("DataRate", DataRateValue (DataRate (5000))); |
535 |
534 |
536 ApplicationContainer app = onoff.Install (nodes.Get (0)); |
535 ApplicationContainer app = onoff.Install (nodes.Get (0)); |
537 // Start the application |
536 // Start the application |
538 app.Start (Seconds (1.0)); |
537 app.Start (Seconds (1.0)); |
645 PacketSocketAddress socket; |
644 PacketSocketAddress socket; |
646 socket.SetSingleDevice (devs.Get (0)->GetIfIndex ()); |
645 socket.SetSingleDevice (devs.Get (0)->GetIfIndex ()); |
647 socket.SetPhysicalAddress (devs.Get (1)->GetAddress ()); |
646 socket.SetPhysicalAddress (devs.Get (1)->GetAddress ()); |
648 socket.SetProtocol (2); |
647 socket.SetProtocol (2); |
649 OnOffHelper onoff ("ns3::PacketSocketFactory", Address (socket)); |
648 OnOffHelper onoff ("ns3::PacketSocketFactory", Address (socket)); |
650 onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1.0))); |
649 onoff.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]")); |
651 onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0.0))); |
650 onoff.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]")); |
652 onoff.SetAttribute ("DataRate", DataRateValue (DataRate (5000))); |
651 onoff.SetAttribute ("DataRate", DataRateValue (DataRate (5000))); |
653 ApplicationContainer apps = onoff.Install (nodes.Get (0)); |
652 ApplicationContainer apps = onoff.Install (nodes.Get (0)); |
654 apps.Start (Seconds (1.0)); |
653 apps.Start (Seconds (1.0)); |
655 apps.Stop (Seconds (10.0)); |
654 apps.Stop (Seconds (10.0)); |
656 |
655 |
657 socket.SetSingleDevice (devs.Get (3)->GetIfIndex ()); |
656 socket.SetSingleDevice (devs.Get (3)->GetIfIndex ()); |
658 socket.SetPhysicalAddress (devs.Get (0)->GetAddress ()); |
657 socket.SetPhysicalAddress (devs.Get (0)->GetAddress ()); |
659 socket.SetProtocol (3); |
658 socket.SetProtocol (3); |
660 onoff.SetAttribute ("Remote", AddressValue (socket)); |
659 onoff.SetAttribute ("Remote", AddressValue (socket)); |
661 onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0.0))); |
660 onoff.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]")); |
662 apps = onoff.Install (nodes.Get (3)); |
661 apps = onoff.Install (nodes.Get (3)); |
663 apps.Start (Seconds (1.0)); |
662 apps.Start (Seconds (1.0)); |
664 apps.Stop (Seconds (10.0)); |
663 apps.Stop (Seconds (10.0)); |
665 |
664 |
666 PacketSinkHelper sink = PacketSinkHelper ("ns3::PacketSocketFactory", |
665 PacketSinkHelper sink = PacketSinkHelper ("ns3::PacketSocketFactory", |
761 // Make packets be sent about every DefaultPacketSize / DataRate = |
760 // Make packets be sent about every DefaultPacketSize / DataRate = |
762 // 4096 bits / (5000 bits/second) = 0.82 second. |
761 // 4096 bits / (5000 bits/second) = 0.82 second. |
763 Config::SetDefault ("ns3::Ipv4RawSocketImpl::Protocol", StringValue ("2")); |
762 Config::SetDefault ("ns3::Ipv4RawSocketImpl::Protocol", StringValue ("2")); |
764 InetSocketAddress dst = InetSocketAddress (addresses.GetAddress (3)); |
763 InetSocketAddress dst = InetSocketAddress (addresses.GetAddress (3)); |
765 OnOffHelper onoff = OnOffHelper ("ns3::Ipv4RawSocketFactory", dst); |
764 OnOffHelper onoff = OnOffHelper ("ns3::Ipv4RawSocketFactory", dst); |
766 onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1.0))); |
765 onoff.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]")); |
767 onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0.0))); |
766 onoff.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]")); |
768 onoff.SetAttribute ("DataRate", DataRateValue (DataRate (5000))); |
767 onoff.SetAttribute ("DataRate", DataRateValue (DataRate (5000))); |
769 |
768 |
770 ApplicationContainer apps = onoff.Install (c.Get (0)); |
769 ApplicationContainer apps = onoff.Install (c.Get (0)); |
771 apps.Start (Seconds (1.0)); |
770 apps.Start (Seconds (1.0)); |
772 apps.Stop (Seconds (10.0)); |
771 apps.Stop (Seconds (10.0)); |
877 // Make packets be sent about every DefaultPacketSize / DataRate = |
876 // Make packets be sent about every DefaultPacketSize / DataRate = |
878 // 4096 bits / (5000 bits/second) = 0.82 second. |
877 // 4096 bits / (5000 bits/second) = 0.82 second. |
879 Config::SetDefault ("ns3::Ipv4RawSocketImpl::Protocol", StringValue ("2")); |
878 Config::SetDefault ("ns3::Ipv4RawSocketImpl::Protocol", StringValue ("2")); |
880 InetSocketAddress dst = InetSocketAddress (addresses.GetAddress (3)); |
879 InetSocketAddress dst = InetSocketAddress (addresses.GetAddress (3)); |
881 OnOffHelper onoff = OnOffHelper ("ns3::Ipv4RawSocketFactory", dst); |
880 OnOffHelper onoff = OnOffHelper ("ns3::Ipv4RawSocketFactory", dst); |
882 onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1.0))); |
881 onoff.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]")); |
883 onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0.0))); |
882 onoff.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]")); |
884 onoff.SetAttribute ("DataRate", DataRateValue (DataRate (5000))); |
883 onoff.SetAttribute ("DataRate", DataRateValue (DataRate (5000))); |
885 |
884 |
886 ApplicationContainer apps = onoff.Install (c.Get (0)); |
885 ApplicationContainer apps = onoff.Install (c.Get (0)); |
887 apps.Start (Seconds (1.0)); |
886 apps.Start (Seconds (1.0)); |
888 apps.Stop (Seconds (10.0)); |
887 apps.Stop (Seconds (10.0)); |
1032 // Create OnOff applications to send TCP to the hub, one on each spoke node. |
1031 // Create OnOff applications to send TCP to the hub, one on each spoke node. |
1033 // |
1032 // |
1034 // Make packets be sent about every DefaultPacketSize / DataRate = |
1033 // Make packets be sent about every DefaultPacketSize / DataRate = |
1035 // 4096 bits / (5000 bits/second) = 0.82 second. |
1034 // 4096 bits / (5000 bits/second) = 0.82 second. |
1036 OnOffHelper onOffHelper ("ns3::TcpSocketFactory", Address ()); |
1035 OnOffHelper onOffHelper ("ns3::TcpSocketFactory", Address ()); |
1037 onOffHelper.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1))); |
1036 onOffHelper.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]")); |
1038 onOffHelper.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0))); |
1037 onOffHelper.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]")); |
1039 onOffHelper.SetAttribute ("DataRate", DataRateValue (DataRate (5000))); |
1038 onOffHelper.SetAttribute ("DataRate", DataRateValue (DataRate (5000))); |
1040 |
1039 |
1041 ApplicationContainer spokeApps; |
1040 ApplicationContainer spokeApps; |
1042 |
1041 |
1043 for (uint32_t i = 0; i < star.SpokeCount (); ++i) |
1042 for (uint32_t i = 0; i < star.SpokeCount (); ++i) |