author | Raj Bhattacharjea <raj.b@gatech.edu> |
Wed, 01 Apr 2009 19:09:12 -0400 | |
changeset 4306 | 5396ecd09060 |
parent 4268 | c5d79ee51ffc |
permissions | -rw-r--r-- |
3458
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
1 |
# /* |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
2 |
# * This program is free software; you can redistribute it and/or modify |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
3 |
# * it under the terms of the GNU General Public License version 2 as |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
4 |
# * published by the Free Software Foundation |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
5 |
# * |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
6 |
# * This program is distributed in the hope that it will be useful, |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
7 |
# * but WITHOUT ANY WARRANTY; without even the implied warranty of |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
8 |
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
9 |
# * GNU General Public License for more details. |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
10 |
# * |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
11 |
# * You should have received a copy of the GNU General Public License |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
12 |
# * along with this program; if not, write to the Free Software |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
13 |
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
14 |
# */ |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
15 |
|
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
16 |
# Network topology |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
17 |
# |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
18 |
# n0 n1 |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
19 |
# | | |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
20 |
# ---------- |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
21 |
# | Switch | |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
22 |
# ---------- |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
23 |
# | | |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
24 |
# n2 n3 |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
25 |
# |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
26 |
# |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
27 |
# - CBR/UDP flows from n0 to n1 and from n3 to n0 |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
28 |
# - DropTail queues |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
29 |
# - Tracing of queues and packet receptions to file "csma-bridge.tr" |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
30 |
|
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
31 |
import ns3 |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
32 |
|
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
33 |
|
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
34 |
def main(argv): |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
35 |
|
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
36 |
# |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
37 |
# Allow the user to override any of the defaults and the above Bind() at |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
38 |
# run-time, via command-line arguments |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
39 |
# |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
40 |
cmd = ns3.CommandLine() |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
41 |
cmd.Parse(argv) |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
42 |
|
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
43 |
# |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
44 |
# Explicitly create the nodes required by the topology(shown above). |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
45 |
# |
3696
559a7114a1e6
Make the example less verbose (for use in regression)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3458
diff
changeset
|
46 |
#print "Create nodes." |
3458
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
47 |
terminals = ns3.NodeContainer() |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
48 |
terminals.Create(4) |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
49 |
|
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
50 |
csmaSwitch = ns3.NodeContainer() |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
51 |
csmaSwitch.Create(1) |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
52 |
|
3696
559a7114a1e6
Make the example less verbose (for use in regression)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3458
diff
changeset
|
53 |
#print "Build Topology" |
3458
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
54 |
csma = ns3.CsmaHelper() |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
55 |
csma.SetChannelAttribute("DataRate", ns3.DataRateValue(ns3.DataRate(5000000))) |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
56 |
csma.SetChannelAttribute("Delay", ns3.TimeValue(ns3.MilliSeconds(2))) |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
57 |
|
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
58 |
# Create the csma links, from each terminal to the switch |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
59 |
|
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
60 |
terminalDevices = ns3.NetDeviceContainer() |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
61 |
switchDevices = ns3.NetDeviceContainer() |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
62 |
|
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
63 |
for i in range(4): |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
64 |
link = csma.Install(ns3.NodeContainer(ns3.NodeContainer(terminals.Get(i)), csmaSwitch)) |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
65 |
terminalDevices.Add(link.Get(0)) |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
66 |
switchDevices.Add(link.Get(1)) |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
67 |
|
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
68 |
# Create the bridge netdevice, which will do the packet switching |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
69 |
switchNode = csmaSwitch.Get(0) |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
70 |
bridgeDevice = ns3.BridgeNetDevice() |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
71 |
switchNode.AddDevice(bridgeDevice) |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
72 |
|
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
73 |
for portIter in range(switchDevices.GetN()): |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
74 |
bridgeDevice.AddBridgePort(switchDevices.Get(portIter)) |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
75 |
|
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
76 |
# Add internet stack to the terminals |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
77 |
internet = ns3.InternetStackHelper() |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
78 |
internet.Install(terminals) |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
79 |
|
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
80 |
# We've got the "hardware" in place. Now we need to add IP addresses. |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
81 |
# |
3696
559a7114a1e6
Make the example less verbose (for use in regression)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3458
diff
changeset
|
82 |
#print "Assign IP Addresses." |
3458
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
83 |
ipv4 = ns3.Ipv4AddressHelper() |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
84 |
ipv4.SetBase(ns3.Ipv4Address("10.1.1.0"), ns3.Ipv4Mask("255.255.255.0")) |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
85 |
ipv4.Assign(terminalDevices) |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
86 |
|
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
87 |
# |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
88 |
# Create an OnOff application to send UDP datagrams from node zero to node 1. |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
89 |
# |
3696
559a7114a1e6
Make the example less verbose (for use in regression)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3458
diff
changeset
|
90 |
#print "Create Applications." |
3458
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
91 |
port = 9 # Discard port(RFC 863) |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
92 |
|
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
93 |
onoff = ns3.OnOffHelper("ns3::UdpSocketFactory", |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
94 |
ns3.Address(ns3.InetSocketAddress(ns3.Ipv4Address("10.1.1.2"), port))) |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
95 |
onoff.SetAttribute("OnTime", ns3.RandomVariableValue(ns3.ConstantVariable(1))) |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
96 |
onoff.SetAttribute("OffTime", ns3.RandomVariableValue(ns3.ConstantVariable(0))) |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
97 |
|
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
98 |
app = onoff.Install(ns3.NodeContainer(terminals.Get(0))) |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
99 |
# Start the application |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
100 |
app.Start(ns3.Seconds(1.0)) |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
101 |
app.Stop(ns3.Seconds(10.0)) |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
102 |
|
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
103 |
# Create an optional packet sink to receive these packets |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
104 |
sink = ns3.PacketSinkHelper("ns3::UdpSocketFactory", |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
105 |
ns3.Address(ns3.InetSocketAddress(ns3.Ipv4Address.GetAny(), port))) |
3715
594e2052e5b2
make sure that the sinks are started
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3696
diff
changeset
|
106 |
app = sink.Install(ns3.NodeContainer(terminals.Get(1))) |
594e2052e5b2
make sure that the sinks are started
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3696
diff
changeset
|
107 |
app.Start (ns3.Seconds (0.0)) |
3458
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
108 |
|
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
109 |
# |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
110 |
# Create a similar flow from n3 to n0, starting at time 1.1 seconds |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
111 |
# |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
112 |
onoff.SetAttribute("Remote", |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
113 |
ns3.AddressValue(ns3.InetSocketAddress(ns3.Ipv4Address("10.1.1.1"), port))) |
3715
594e2052e5b2
make sure that the sinks are started
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3696
diff
changeset
|
114 |
app = onoff.Install(ns3.NodeContainer(terminals.Get(3))) |
594e2052e5b2
make sure that the sinks are started
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3696
diff
changeset
|
115 |
app.Start(ns3.Seconds(1.1)) |
594e2052e5b2
make sure that the sinks are started
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3696
diff
changeset
|
116 |
app.Stop(ns3.Seconds(10.0)) |
3458
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
117 |
|
3715
594e2052e5b2
make sure that the sinks are started
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3696
diff
changeset
|
118 |
app = sink.Install(ns3.NodeContainer(terminals.Get(0))) |
594e2052e5b2
make sure that the sinks are started
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3696
diff
changeset
|
119 |
app.Start (ns3.Seconds (0.0)) |
3458
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
120 |
|
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
121 |
# |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
122 |
# Configure tracing of all enqueue, dequeue, and NetDevice receive events. |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
123 |
# Trace output will be sent to the file "csma-bridge.tr" |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
124 |
# |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
125 |
#print "Configure Tracing." |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
126 |
#std.ofstream ascii |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
127 |
#ascii.open("csma-bridge.tr") |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
128 |
#CsmaHelper.EnableAsciiAll(ascii) |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
129 |
|
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
130 |
# |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
131 |
# Also configure some tcpdump traces; each interface will be traced. |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
132 |
# The output files will be named: |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
133 |
# csma-bridge.pcap-<nodeId>-<interfaceId> |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
134 |
# and can be read by the "tcpdump -r" command(use "-tt" option to |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
135 |
# display timestamps correctly) |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
136 |
# |
4268
c5d79ee51ffc
add TraceAll False parameter for API change
Craig Dowell <craigdo@ee.washington.edu>
parents:
4225
diff
changeset
|
137 |
ns3.CsmaHelper.EnablePcapAll("csma-bridge", False) |
3458
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
138 |
|
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
139 |
# |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
140 |
# Now, do the actual simulation. |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
141 |
# |
3696
559a7114a1e6
Make the example less verbose (for use in regression)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3458
diff
changeset
|
142 |
#print "Run Simulation." |
3458
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
143 |
ns3.Simulator.Run() |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
144 |
ns3.Simulator.Destroy() |
3696
559a7114a1e6
Make the example less verbose (for use in regression)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3458
diff
changeset
|
145 |
#print "Done." |
3458
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
146 |
|
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
147 |
|
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
148 |
|
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
149 |
if __name__ == '__main__': |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
150 |
import sys |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
151 |
main(sys.argv) |
f289e2045bfc
Add csma-bridge example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
152 |