author | Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
Tue, 11 Mar 2008 13:30:12 -0700 | |
changeset 2592 | 3ebf97150166 |
parent 2494 | 1c69ea12779c |
child 2600 | 6c389d0c717d |
permissions | -rw-r--r-- |
1844 | 1 |
|
2 |
/* |
|
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 |
|
5 |
* published by the Free Software Foundation; |
|
6 |
* |
|
7 |
* This program is distributed in the hope that it will be useful, |
|
8 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
9 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
10 |
* GNU General Public License for more details. |
|
11 |
* |
|
12 |
* You should have received a copy of the GNU General Public License |
|
13 |
* along with this program; if not, write to the Free Software |
|
14 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
15 |
*/ |
|
16 |
||
17 |
#include "ns3/log.h" |
|
18 |
#include "ns3/ipv4-address.h" |
|
19 |
#include "ns3/udp-echo-client.h" |
|
20 |
#include "ns3/udp-echo-server.h" |
|
21 |
#include "ns3/simulator.h" |
|
22 |
#include "ns3/nstime.h" |
|
23 |
#include "ns3/ascii-trace.h" |
|
2494
1c69ea12779c
port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2311
diff
changeset
|
24 |
#include "ns3/inet-socket-address.h" |
1c69ea12779c
port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2311
diff
changeset
|
25 |
#include "ns3/uinteger.h" |
1844 | 26 |
|
1845
836f0c983165
improve obj design example
Craig Dowell <craigdo@ee.washington.edu>
parents:
1844
diff
changeset
|
27 |
#include "ipv4-bus-network.h" |
1844 | 28 |
|
29 |
NS_LOG_COMPONENT_DEFINE ("BusNetworkSimulation"); |
|
30 |
||
31 |
using namespace ns3; |
|
32 |
||
33 |
int |
|
34 |
main (int argc, char *argv[]) |
|
35 |
{ |
|
36 |
LogComponentEnable ("BusNetworkSimulation", LOG_LEVEL_ALL); |
|
37 |
||
38 |
NS_LOG_INFO ("Bus Network Simulation"); |
|
39 |
||
1846
b0a2f5612f4e
don't use any for starting address
Craig Dowell <craigdo@ee.washington.edu>
parents:
1845
diff
changeset
|
40 |
Ipv4BusNetwork bus ("10.1.0.0", "255.255.0.0", "0.0.0.3", |
1845
836f0c983165
improve obj design example
Craig Dowell <craigdo@ee.washington.edu>
parents:
1844
diff
changeset
|
41 |
DataRate(10000000), MilliSeconds(20), 10); |
1844 | 42 |
|
43 |
uint32_t port = 7; |
|
44 |
||
1845
836f0c983165
improve obj design example
Craig Dowell <craigdo@ee.washington.edu>
parents:
1844
diff
changeset
|
45 |
Ptr<Node> n0 = bus.GetNode (0); |
2494
1c69ea12779c
port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2311
diff
changeset
|
46 |
Ptr<UdpEchoClient> client = |
2592
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2494
diff
changeset
|
47 |
CreateObject<UdpEchoClient> ("Node", n0, |
2494
1c69ea12779c
port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2311
diff
changeset
|
48 |
"RemoteIpv4", Ipv4Address ("10.1.0.1"), |
1c69ea12779c
port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2311
diff
changeset
|
49 |
"RemotePort", Uinteger (port), |
1c69ea12779c
port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2311
diff
changeset
|
50 |
"MaxPackets", Uinteger (1), |
1c69ea12779c
port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2311
diff
changeset
|
51 |
"Interval", Seconds(1.), |
1c69ea12779c
port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2311
diff
changeset
|
52 |
"PacketSize", Uinteger (1024)); |
1c69ea12779c
port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2311
diff
changeset
|
53 |
n0->AddApplication (client); |
1844 | 54 |
|
1845
836f0c983165
improve obj design example
Craig Dowell <craigdo@ee.washington.edu>
parents:
1844
diff
changeset
|
55 |
Ptr<Node> n1 = bus.GetNode (1); |
2494
1c69ea12779c
port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2311
diff
changeset
|
56 |
Ptr<UdpEchoServer> server = |
2592
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2494
diff
changeset
|
57 |
CreateObject<UdpEchoServer> ("Node", n1, "Port", Uinteger (port)); |
2494
1c69ea12779c
port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2311
diff
changeset
|
58 |
n1->AddApplication (server); |
1844 | 59 |
|
60 |
server->Start(Seconds(1.)); |
|
61 |
client->Start(Seconds(2.)); |
|
62 |
||
63 |
server->Stop (Seconds(10.)); |
|
64 |
client->Stop (Seconds(10.)); |
|
65 |
||
66 |
AsciiTrace asciitrace ("tutorial.tr"); |
|
67 |
asciitrace.TraceAllQueues (); |
|
68 |
asciitrace.TraceAllNetDeviceRx (); |
|
69 |
||
70 |
Simulator::Run (); |
|
71 |
Simulator::Destroy (); |
|
72 |
} |