OLD | NEW |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * This program is free software; you can redistribute it and/or modify | 3 * This program is free software; you can redistribute it and/or modify |
4 * it under the terms of the GNU General Public License version 2 as | 4 * it under the terms of the GNU General Public License version 2 as |
5 * published by the Free Software Foundation; | 5 * published by the Free Software Foundation; |
6 * | 6 * |
7 * This program is distributed in the hope that it will be useful, | 7 * This program is distributed in the hope that it will be useful, |
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 8 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
10 * GNU General Public License for more details. | 10 * GNU General Public License for more details. |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 // RFC 863 discard port ("9") indicates packet should be thrown away | 85 // RFC 863 discard port ("9") indicates packet should be thrown away |
86 // by the system. We allow this silent discard to be overridden | 86 // by the system. We allow this silent discard to be overridden |
87 // by the PacketSink application. | 87 // by the PacketSink application. |
88 uint16_t port = 9; | 88 uint16_t port = 9; |
89 | 89 |
90 // Create the OnOff application to send UDP datagrams of size | 90 // Create the OnOff application to send UDP datagrams of size |
91 // 512 bytes (default) at a rate of 500 Kb/s (default) from n0 | 91 // 512 bytes (default) at a rate of 500 Kb/s (default) from n0 |
92 NS_LOG_INFO ("Create Applications."); | 92 NS_LOG_INFO ("Create Applications."); |
93 OnOffHelper onoff ("ns3::UdpSocketFactory",· | 93 OnOffHelper onoff ("ns3::UdpSocketFactory",· |
94 Address (InetSocketAddress (Ipv4Address ("255.255.255.255")
, port))); | 94 Address (InetSocketAddress (Ipv4Address ("255.255.255.255")
, port))); |
95 onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1))); | 95 onoff.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Consta
nt=1]")); |
96 onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0))); | 96 onoff.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Const
ant=0]")); |
97 | 97 |
98 ApplicationContainer app = onoff.Install (c0.Get (0)); | 98 ApplicationContainer app = onoff.Install (c0.Get (0)); |
99 // Start the application | 99 // Start the application |
100 app.Start (Seconds (1.0)); | 100 app.Start (Seconds (1.0)); |
101 app.Stop (Seconds (10.0)); | 101 app.Stop (Seconds (10.0)); |
102 | 102 |
103 // Create an optional packet sink to receive these packets | 103 // Create an optional packet sink to receive these packets |
104 PacketSinkHelper sink ("ns3::UdpSocketFactory", | 104 PacketSinkHelper sink ("ns3::UdpSocketFactory", |
105 Address (InetSocketAddress (Ipv4Address::GetAny (), por
t))); | 105 Address (InetSocketAddress (Ipv4Address::GetAny (), por
t))); |
106 app = sink.Install (c0.Get (1)); | 106 app = sink.Install (c0.Get (1)); |
(...skipping 11 matching lines...) Expand all Loading... |
118 // The output files will be named· | 118 // The output files will be named· |
119 // csma-broadcast-<nodeId>-<interfaceId>.pcap | 119 // csma-broadcast-<nodeId>-<interfaceId>.pcap |
120 // and can be read by the "tcpdump -tt -r" command· | 120 // and can be read by the "tcpdump -tt -r" command· |
121 csma.EnablePcapAll ("csma-broadcast", false); | 121 csma.EnablePcapAll ("csma-broadcast", false); |
122 | 122 |
123 NS_LOG_INFO ("Run Simulation."); | 123 NS_LOG_INFO ("Run Simulation."); |
124 Simulator::Run (); | 124 Simulator::Run (); |
125 Simulator::Destroy (); | 125 Simulator::Destroy (); |
126 NS_LOG_INFO ("Done."); | 126 NS_LOG_INFO ("Done."); |
127 } | 127 } |
OLD | NEW |