author | Sébastien Deronne <sebastien.deronne@gmail.com> |
Sat, 08 Dec 2018 16:52:32 +0100 | |
changeset 13892 | 53fa9b4b8c09 |
parent 9266 | d26408b17360 |
permissions | -rw-r--r-- |
6624
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
2 |
/* |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
3 |
* This program is free software; you can redistribute it and/or modify |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
4 |
* it under the terms of the GNU General Public License version 2 as |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
5 |
* published by the Free Software Foundation; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
6 |
* |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
7 |
* This program is distributed in the hope that it will be useful, |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
8 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
9 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
10 |
* GNU General Public License for more details. |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
11 |
* |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
12 |
* You should have received a copy of the GNU General Public License |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
13 |
* along with this program; if not, write to the Free Software |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
14 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
15 |
*/ |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
16 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
17 |
// This is not a test of CsmaNetDevice model behavior per-se, but |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
18 |
// instead is a roll up of several end-to-end examples in examples/csma |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
19 |
// directory, converted into system tests. Writing a test suite |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
20 |
// to test Csma itself is for further study. |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
21 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
22 |
#include <string> |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
23 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
24 |
#include "ns3/address.h" |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
25 |
#include "ns3/application-container.h" |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
26 |
#include "ns3/bridge-helper.h" |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
27 |
#include "ns3/callback.h" |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
28 |
#include "ns3/config.h" |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
29 |
#include "ns3/csma-helper.h" |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
30 |
#include "ns3/csma-star-helper.h" |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
31 |
#include "ns3/inet-socket-address.h" |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
32 |
#include "ns3/internet-stack-helper.h" |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
33 |
#include "ns3/ipv4-address-helper.h" |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
34 |
#include "ns3/ipv4-global-routing-helper.h" |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
35 |
#include "ns3/ipv4-static-routing-helper.h" |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
36 |
#include "ns3/node.h" |
9000
3ec20a64fd08
Add a constant rate setting function to the on-off helper
Mitch Watrous
parents:
8966
diff
changeset
|
37 |
#include "ns3/data-rate.h" |
6624
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
38 |
#include "ns3/node-container.h" |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
39 |
#include "ns3/on-off-helper.h" |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
40 |
#include "ns3/packet.h" |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
41 |
#include "ns3/packet-sink-helper.h" |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
42 |
#include "ns3/packet-socket-helper.h" |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
43 |
#include "ns3/packet-socket-address.h" |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
44 |
#include "ns3/pointer.h" |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
45 |
#include "ns3/simple-channel.h" |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
46 |
#include "ns3/simulator.h" |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
47 |
#include "ns3/string.h" |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
48 |
#include "ns3/test.h" |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
49 |
#include "ns3/uinteger.h" |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
50 |
#include "ns3/v4ping-helper.h" |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
51 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
52 |
using namespace ns3; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
53 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
54 |
class CsmaBridgeTestCase : public TestCase |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
55 |
{ |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
56 |
public: |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
57 |
CsmaBridgeTestCase (); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
58 |
virtual ~CsmaBridgeTestCase (); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
59 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
60 |
private: |
6775
0783f42a364b
Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents:
6624
diff
changeset
|
61 |
virtual void DoRun (void); |
6624
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
62 |
void SinkRx (Ptr<const Packet> p, const Address &ad); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
63 |
uint32_t m_count; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
64 |
}; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
65 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
66 |
// Add some help text to this case to describe what it is intended to test |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
67 |
CsmaBridgeTestCase::CsmaBridgeTestCase () |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
68 |
: TestCase ("Bridge example for Carrier Sense Multiple Access (CSMA) networks"), m_count (0) |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
69 |
{ |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
70 |
} |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
71 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
72 |
CsmaBridgeTestCase::~CsmaBridgeTestCase () |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
73 |
{ |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
74 |
} |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
75 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
76 |
void |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
77 |
CsmaBridgeTestCase::SinkRx (Ptr<const Packet> p, const Address &ad) |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
78 |
{ |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
79 |
m_count++; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
80 |
} |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
81 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
82 |
// Network topology |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
83 |
// |
7191
7b9f3eba908b
test coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7008
diff
changeset
|
84 |
// n0 n1 |
6624
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
85 |
// | | |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
86 |
// ---------- |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
87 |
// | Switch | |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
88 |
// ---------- |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
89 |
// | | |
7191
7b9f3eba908b
test coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7008
diff
changeset
|
90 |
// n2 n3 |
6624
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
91 |
// |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
92 |
// - CBR/UDP test flow from n0 to n1; test that packets received on n1 |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
93 |
// |
6775
0783f42a364b
Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents:
6624
diff
changeset
|
94 |
void |
6624
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
95 |
CsmaBridgeTestCase::DoRun (void) |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
96 |
{ |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
97 |
NodeContainer terminals; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
98 |
terminals.Create (4); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
99 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
100 |
NodeContainer csmaSwitch; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
101 |
csmaSwitch.Create (1); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
102 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
103 |
CsmaHelper csma; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
104 |
csma.SetChannelAttribute ("DataRate", DataRateValue (5000000)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
105 |
csma.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (2))); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
106 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
107 |
NetDeviceContainer terminalDevices; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
108 |
NetDeviceContainer switchDevices; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
109 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
110 |
for (int i = 0; i < 4; i++) |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
111 |
{ |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
112 |
NetDeviceContainer link = csma.Install (NodeContainer (terminals.Get (i), csmaSwitch)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
113 |
terminalDevices.Add (link.Get (0)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
114 |
switchDevices.Add (link.Get (1)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
115 |
} |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
116 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
117 |
// Create the bridge netdevice, which will do the packet switching |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
118 |
Ptr<Node> switchNode = csmaSwitch.Get (0); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
119 |
BridgeHelper bridge; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
120 |
bridge.Install (switchNode, switchDevices); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
121 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
122 |
InternetStackHelper internet; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
123 |
internet.Install (terminals); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
124 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
125 |
Ipv4AddressHelper ipv4; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
126 |
ipv4.SetBase ("10.1.1.0", "255.255.255.0"); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
127 |
ipv4.Assign (terminalDevices); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
128 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
129 |
uint16_t port = 9; // Discard port (RFC 863) |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
130 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
131 |
// Create the OnOff application to send UDP datagrams from n0 to n1. |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
132 |
// |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
133 |
// Make packets be sent about every DefaultPacketSize / DataRate = |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
134 |
// 4096 bits / (5000 bits/second) = 0.82 second. |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
135 |
OnOffHelper onoff ("ns3::UdpSocketFactory", |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
136 |
Address (InetSocketAddress (Ipv4Address ("10.1.1.2"), port))); |
9000
3ec20a64fd08
Add a constant rate setting function to the on-off helper
Mitch Watrous
parents:
8966
diff
changeset
|
137 |
onoff.SetConstantRate (DataRate (5000)); |
6624
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
138 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
139 |
ApplicationContainer app = onoff.Install (terminals.Get (0)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
140 |
app.Start (Seconds (1.0)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
141 |
app.Stop (Seconds (10.0)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
142 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
143 |
PacketSinkHelper sink ("ns3::UdpSocketFactory", |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
144 |
Address (InetSocketAddress (Ipv4Address::GetAny (), port))); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
145 |
app = sink.Install (terminals.Get (1)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
146 |
app.Start (Seconds (0.0)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
147 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
148 |
// Trace receptions |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
149 |
Config::ConnectWithoutContext ("/NodeList/1/ApplicationList/0/$ns3::PacketSink/Rx", MakeCallback (&CsmaBridgeTestCase::SinkRx, this)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
150 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
151 |
Simulator::Run (); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
152 |
Simulator::Destroy (); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
153 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
154 |
// We should have sent and received 10 packets |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
155 |
NS_TEST_ASSERT_MSG_EQ (m_count, 10, "Bridge should have passed 10 packets"); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
156 |
} |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
157 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
158 |
class CsmaBroadcastTestCase : public TestCase |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
159 |
{ |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
160 |
public: |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
161 |
CsmaBroadcastTestCase (); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
162 |
virtual ~CsmaBroadcastTestCase (); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
163 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
164 |
private: |
6775
0783f42a364b
Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents:
6624
diff
changeset
|
165 |
virtual void DoRun (void); |
6624
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
166 |
void SinkRxNode1 (Ptr<const Packet> p, const Address &ad); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
167 |
void SinkRxNode2 (Ptr<const Packet> p, const Address &ad); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
168 |
void DropEvent (Ptr<const Packet> p); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
169 |
uint32_t m_countNode1; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
170 |
uint32_t m_countNode2; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
171 |
uint32_t m_drops; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
172 |
}; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
173 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
174 |
// Add some help text to this case to describe what it is intended to test |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
175 |
CsmaBroadcastTestCase::CsmaBroadcastTestCase () |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
176 |
: TestCase ("Broadcast example for Carrier Sense Multiple Access (CSMA) networks"), m_countNode1 (0), m_countNode2 (0), m_drops (0) |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
177 |
{ |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
178 |
} |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
179 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
180 |
CsmaBroadcastTestCase::~CsmaBroadcastTestCase () |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
181 |
{ |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
182 |
} |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
183 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
184 |
void |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
185 |
CsmaBroadcastTestCase::SinkRxNode1 (Ptr<const Packet> p, const Address &ad) |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
186 |
{ |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
187 |
m_countNode1++; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
188 |
} |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
189 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
190 |
void |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
191 |
CsmaBroadcastTestCase::SinkRxNode2 (Ptr<const Packet> p, const Address &ad) |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
192 |
{ |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
193 |
m_countNode2++; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
194 |
} |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
195 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
196 |
void |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
197 |
CsmaBroadcastTestCase::DropEvent (Ptr<const Packet> p) |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
198 |
{ |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
199 |
m_drops++; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
200 |
} |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
201 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
202 |
// |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
203 |
// Example of the sending of a datagram to a broadcast address |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
204 |
// |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
205 |
// Network topology |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
206 |
// ============== |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
207 |
// | | |
7191
7b9f3eba908b
test coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7008
diff
changeset
|
208 |
// n0 n1 n2 |
7b9f3eba908b
test coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7008
diff
changeset
|
209 |
// | | |
6624
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
210 |
// ========== |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
211 |
// |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
212 |
// n0 originates UDP broadcast to 255.255.255.255/discard port, which |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
213 |
// is replicated and received on both n1 and n2 |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
214 |
// |
6775
0783f42a364b
Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents:
6624
diff
changeset
|
215 |
void |
6624
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
216 |
CsmaBroadcastTestCase::DoRun (void) |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
217 |
{ |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
218 |
NodeContainer c; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
219 |
c.Create (3); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
220 |
NodeContainer c0 = NodeContainer (c.Get (0), c.Get (1)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
221 |
NodeContainer c1 = NodeContainer (c.Get (0), c.Get (2)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
222 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
223 |
CsmaHelper csma; |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7191
diff
changeset
|
224 |
csma.SetChannelAttribute ("DataRate", DataRateValue (DataRate (5000000))); |
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7191
diff
changeset
|
225 |
csma.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (2))); |
6624
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
226 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
227 |
NetDeviceContainer n0 = csma.Install (c0); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
228 |
NetDeviceContainer n1 = csma.Install (c1); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
229 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
230 |
InternetStackHelper internet; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
231 |
internet.Install (c); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
232 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
233 |
Ipv4AddressHelper ipv4; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
234 |
ipv4.SetBase ("10.1.0.0", "255.255.255.0"); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
235 |
ipv4.Assign (n0); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
236 |
ipv4.SetBase ("192.168.1.0", "255.255.255.0"); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
237 |
ipv4.Assign (n1); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
238 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
239 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
240 |
// RFC 863 discard port ("9") indicates packet should be thrown away |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
241 |
// by the system. We allow this silent discard to be overridden |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
242 |
// by the PacketSink application. |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
243 |
uint16_t port = 9; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
244 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
245 |
// Create the OnOff application to send UDP datagrams from n0. |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
246 |
// |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
247 |
// Make packets be sent about every DefaultPacketSize / DataRate = |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
248 |
// 4096 bits / (5000 bits/second) = 0.82 second. |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
249 |
OnOffHelper onoff ("ns3::UdpSocketFactory", |
7191
7b9f3eba908b
test coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7008
diff
changeset
|
250 |
Address (InetSocketAddress (Ipv4Address ("255.255.255.255"), port))); |
9000
3ec20a64fd08
Add a constant rate setting function to the on-off helper
Mitch Watrous
parents:
8966
diff
changeset
|
251 |
onoff.SetConstantRate (DataRate (5000)); |
6624
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
252 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
253 |
ApplicationContainer app = onoff.Install (c0.Get (0)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
254 |
// Start the application |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
255 |
app.Start (Seconds (1.0)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
256 |
app.Stop (Seconds (10.0)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
257 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
258 |
// Create an optional packet sink to receive these packets |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
259 |
PacketSinkHelper sink ("ns3::UdpSocketFactory", |
7191
7b9f3eba908b
test coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7008
diff
changeset
|
260 |
Address (InetSocketAddress (Ipv4Address::GetAny (), port))); |
6624
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
261 |
app = sink.Install (c0.Get (1)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
262 |
app.Add (sink.Install (c1.Get (1))); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
263 |
app.Start (Seconds (1.0)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
264 |
app.Stop (Seconds (10.0)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
265 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
266 |
// Trace receptions |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
267 |
Config::ConnectWithoutContext ("/NodeList/1/ApplicationList/0/$ns3::PacketSink/Rx", MakeCallback (&CsmaBroadcastTestCase::SinkRxNode1, this)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
268 |
Config::ConnectWithoutContext ("/NodeList/2/ApplicationList/0/$ns3::PacketSink/Rx", MakeCallback (&CsmaBroadcastTestCase::SinkRxNode2, this)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
269 |
|
7191
7b9f3eba908b
test coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7008
diff
changeset
|
270 |
Simulator::Run (); |
6624
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
271 |
Simulator::Destroy (); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
272 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
273 |
// We should have sent and received 10 packets |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
274 |
NS_TEST_ASSERT_MSG_EQ (m_countNode1, 10, "Node 1 should have received 10 packets"); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
275 |
NS_TEST_ASSERT_MSG_EQ (m_countNode2, 10, "Node 2 should have received 10 packets"); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
276 |
} |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
277 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
278 |
class CsmaMulticastTestCase : public TestCase |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
279 |
{ |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
280 |
public: |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
281 |
CsmaMulticastTestCase (); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
282 |
virtual ~CsmaMulticastTestCase (); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
283 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
284 |
private: |
6775
0783f42a364b
Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents:
6624
diff
changeset
|
285 |
virtual void DoRun (void); |
6624
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
286 |
void SinkRx (Ptr<const Packet> p, const Address &ad); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
287 |
void DropEvent (Ptr<const Packet> p); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
288 |
uint32_t m_count; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
289 |
uint32_t m_drops; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
290 |
}; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
291 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
292 |
// Add some help text to this case to describe what it is intended to test |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
293 |
CsmaMulticastTestCase::CsmaMulticastTestCase () |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
294 |
: TestCase ("Multicast example for Carrier Sense Multiple Access (CSMA) networks"), m_count (0), m_drops (0) |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
295 |
{ |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
296 |
} |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
297 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
298 |
CsmaMulticastTestCase::~CsmaMulticastTestCase () |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
299 |
{ |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
300 |
} |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
301 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
302 |
void |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
303 |
CsmaMulticastTestCase::SinkRx (Ptr<const Packet> p, const Address& ad) |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
304 |
{ |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
305 |
m_count++; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
306 |
} |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
307 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
308 |
void |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
309 |
CsmaMulticastTestCase::DropEvent (Ptr<const Packet> p) |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
310 |
{ |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
311 |
m_drops++; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
312 |
} |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
313 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
314 |
// Network topology |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
315 |
// |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
316 |
// Lan1 |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
317 |
// =========== |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
318 |
// | | | |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
319 |
// n0 n1 n2 n3 n4 |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
320 |
// | | | |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
321 |
// =========== |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
322 |
// Lan0 |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
323 |
// |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
324 |
// - Multicast source is at node n0; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
325 |
// - Multicast forwarded by node n2 onto LAN1; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
326 |
// - Nodes n0, n1, n2, n3, and n4 receive the multicast frame. |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
327 |
// - Node n4 listens for the data |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
328 |
// |
6775
0783f42a364b
Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents:
6624
diff
changeset
|
329 |
void |
6624
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
330 |
CsmaMulticastTestCase::DoRun (void) |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
331 |
{ |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
332 |
// |
7191
7b9f3eba908b
test coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7008
diff
changeset
|
333 |
// Set up default values for the simulation. |
6624
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
334 |
// |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
335 |
// Select DIX/Ethernet II-style encapsulation (no LLC/Snap header) |
7191
7b9f3eba908b
test coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7008
diff
changeset
|
336 |
Config::SetDefault ("ns3::CsmaNetDevice::EncapsulationMode", StringValue ("Dix")); |
6624
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
337 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
338 |
NodeContainer c; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
339 |
c.Create (5); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
340 |
// We will later want two subcontainers of these nodes, for the two LANs |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
341 |
NodeContainer c0 = NodeContainer (c.Get (0), c.Get (1), c.Get (2)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
342 |
NodeContainer c1 = NodeContainer (c.Get (2), c.Get (3), c.Get (4)); |
7191
7b9f3eba908b
test coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7008
diff
changeset
|
343 |
|
6624
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
344 |
CsmaHelper csma; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
345 |
csma.SetChannelAttribute ("DataRate", DataRateValue (DataRate (5000000))); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
346 |
csma.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (2))); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
347 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
348 |
// We will use these NetDevice containers later, for IP addressing |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
349 |
NetDeviceContainer nd0 = csma.Install (c0); // First LAN |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
350 |
NetDeviceContainer nd1 = csma.Install (c1); // Second LAN |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
351 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
352 |
InternetStackHelper internet; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
353 |
internet.Install (c); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
354 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
355 |
Ipv4AddressHelper ipv4Addr; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
356 |
ipv4Addr.SetBase ("10.1.1.0", "255.255.255.0"); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
357 |
ipv4Addr.Assign (nd0); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
358 |
ipv4Addr.SetBase ("10.1.2.0", "255.255.255.0"); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
359 |
ipv4Addr.Assign (nd1); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
360 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
361 |
// |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
362 |
// Now we can configure multicasting. As described above, the multicast |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
363 |
// source is at node zero, which we assigned the IP address of 10.1.1.1 |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
364 |
// earlier. We need to define a multicast group to send packets to. This |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
365 |
// can be any multicast address from 224.0.0.0 through 239.255.255.255 |
7191
7b9f3eba908b
test coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7008
diff
changeset
|
366 |
// (avoiding the reserved routing protocol addresses). |
6624
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
367 |
// |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
368 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
369 |
Ipv4Address multicastSource ("10.1.1.1"); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
370 |
Ipv4Address multicastGroup ("225.1.2.4"); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
371 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
372 |
// Now, we will set up multicast routing. We need to do three things: |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
373 |
// 1) Configure a (static) multicast route on node n2 |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
374 |
// 2) Set up a default multicast route on the sender n0 |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
375 |
// 3) Have node n4 join the multicast group |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
376 |
// We have a helper that can help us with static multicast |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
377 |
Ipv4StaticRoutingHelper multicast; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
378 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
379 |
// 1) Configure a (static) multicast route on node n2 (multicastRouter) |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
380 |
Ptr<Node> multicastRouter = c.Get (2); // The node in question |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
381 |
Ptr<NetDevice> inputIf = nd0.Get (2); // The input NetDevice |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
382 |
NetDeviceContainer outputDevices; // A container of output NetDevices |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
383 |
outputDevices.Add (nd1.Get (0)); // (we only need one NetDevice here) |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
384 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
385 |
multicast.AddMulticastRoute (multicastRouter, multicastSource, |
7191
7b9f3eba908b
test coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7008
diff
changeset
|
386 |
multicastGroup, inputIf, outputDevices); |
7b9f3eba908b
test coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7008
diff
changeset
|
387 |
|
6624
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
388 |
// 2) Set up a default multicast route on the sender n0 |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
389 |
Ptr<Node> sender = c.Get (0); |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7191
diff
changeset
|
390 |
Ptr<NetDevice> senderIf = nd0.Get (0); |
6624
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
391 |
multicast.SetDefaultMulticastRoute (sender, senderIf); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
392 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
393 |
// |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
394 |
// Create an OnOff application to send UDP datagrams from node zero to the |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
395 |
// multicast group (node four will be listening). |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
396 |
// |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
397 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
398 |
uint16_t multicastPort = 9; // Discard port (RFC 863) |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
399 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
400 |
// Configure a multicast packet generator. |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
401 |
// |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
402 |
// Make packets be sent about every defaultPacketSize / dataRate = |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
403 |
// 4096 bits / (5000 bits/second) = 0.82 second. |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
404 |
OnOffHelper onoff ("ns3::UdpSocketFactory", |
7191
7b9f3eba908b
test coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7008
diff
changeset
|
405 |
Address (InetSocketAddress (multicastGroup, multicastPort))); |
9000
3ec20a64fd08
Add a constant rate setting function to the on-off helper
Mitch Watrous
parents:
8966
diff
changeset
|
406 |
onoff.SetConstantRate (DataRate (5000)); |
6624
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
407 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
408 |
ApplicationContainer srcC = onoff.Install (c0.Get (0)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
409 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
410 |
// |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
411 |
// Tell the application when to start and stop. |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
412 |
// |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7191
diff
changeset
|
413 |
srcC.Start (Seconds (1.)); |
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7191
diff
changeset
|
414 |
srcC.Stop (Seconds (10.)); |
6624
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
415 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
416 |
// Create an optional packet sink to receive these packets |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
417 |
PacketSinkHelper sink ("ns3::UdpSocketFactory", |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7191
diff
changeset
|
418 |
InetSocketAddress (Ipv4Address::GetAny (), multicastPort)); |
6624
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
419 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
420 |
ApplicationContainer sinkC = sink.Install (c1.Get (2)); // Node n4 |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
421 |
// Start the sink |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
422 |
sinkC.Start (Seconds (1.0)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
423 |
sinkC.Stop (Seconds (10.0)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
424 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
425 |
// Trace receptions |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
426 |
Config::ConnectWithoutContext ("/NodeList/4/ApplicationList/0/$ns3::PacketSink/Rx", MakeCallback (&CsmaMulticastTestCase::SinkRx, this)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
427 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
428 |
// |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
429 |
// Now, do the actual simulation. |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
430 |
// |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
431 |
Simulator::Run (); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
432 |
Simulator::Destroy (); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
433 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
434 |
// We should have sent and received 10 packets |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
435 |
NS_TEST_ASSERT_MSG_EQ (m_count, 10, "Node 4 should have received 10 packets"); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
436 |
} |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
437 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
438 |
class CsmaOneSubnetTestCase : public TestCase |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
439 |
{ |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
440 |
public: |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
441 |
CsmaOneSubnetTestCase (); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
442 |
virtual ~CsmaOneSubnetTestCase (); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
443 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
444 |
private: |
6775
0783f42a364b
Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents:
6624
diff
changeset
|
445 |
virtual void DoRun (void); |
6624
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
446 |
void SinkRxNode0 (Ptr<const Packet> p, const Address &ad); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
447 |
void SinkRxNode1 (Ptr<const Packet> p, const Address &ad); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
448 |
void DropEvent (Ptr<const Packet> p); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
449 |
uint32_t m_countNode0; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
450 |
uint32_t m_countNode1; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
451 |
uint32_t m_drops; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
452 |
}; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
453 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
454 |
// Add some help text to this case to describe what it is intended to test |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
455 |
CsmaOneSubnetTestCase::CsmaOneSubnetTestCase () |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
456 |
: TestCase ("One subnet example for Carrier Sense Multiple Access (CSMA) networks"), m_countNode0 (0), m_countNode1 (0), m_drops (0) |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
457 |
{ |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
458 |
} |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
459 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
460 |
CsmaOneSubnetTestCase::~CsmaOneSubnetTestCase () |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
461 |
{ |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
462 |
} |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
463 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
464 |
void |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
465 |
CsmaOneSubnetTestCase::SinkRxNode0 (Ptr<const Packet> p, const Address &ad) |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
466 |
{ |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
467 |
m_countNode0++; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
468 |
} |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
469 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
470 |
void |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
471 |
CsmaOneSubnetTestCase::SinkRxNode1 (Ptr<const Packet> p, const Address &ad) |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
472 |
{ |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
473 |
m_countNode1++; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
474 |
} |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
475 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
476 |
void |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
477 |
CsmaOneSubnetTestCase::DropEvent (Ptr<const Packet> p) |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
478 |
{ |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
479 |
m_drops++; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
480 |
} |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
481 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
482 |
// Network topology |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
483 |
// |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
484 |
// n0 n1 n2 n3 |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
485 |
// | | | | |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
486 |
// ================= |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
487 |
// LAN |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
488 |
// |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
489 |
// - CBR/UDP flows from n0 to n1 and from n3 to n0 |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
490 |
// - DropTail queues |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
491 |
// |
6775
0783f42a364b
Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents:
6624
diff
changeset
|
492 |
void |
6624
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
493 |
CsmaOneSubnetTestCase::DoRun (void) |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
494 |
{ |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
495 |
NodeContainer nodes; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
496 |
nodes.Create (4); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
497 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
498 |
CsmaHelper csma; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
499 |
csma.SetChannelAttribute ("DataRate", DataRateValue (5000000)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
500 |
csma.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (2))); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
501 |
// |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
502 |
// Now fill out the topology by creating the net devices required to connect |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
503 |
// the nodes to the channels and hooking them up. |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
504 |
// |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
505 |
NetDeviceContainer devices = csma.Install (nodes); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
506 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
507 |
InternetStackHelper internet; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
508 |
internet.Install (nodes); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
509 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
510 |
// We've got the "hardware" in place. Now we need to add IP addresses. |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
511 |
// |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
512 |
Ipv4AddressHelper ipv4; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
513 |
ipv4.SetBase ("10.1.1.0", "255.255.255.0"); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
514 |
Ipv4InterfaceContainer interfaces = ipv4.Assign (devices); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
515 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
516 |
uint16_t port = 9; // Discard port (RFC 863) |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
517 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
518 |
// |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
519 |
// Create an OnOff application to send UDP datagrams from node zero |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
520 |
// to node 1. |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
521 |
// |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
522 |
// Make packets be sent about every defaultPacketSize / dataRate = |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
523 |
// 4096 bits / (5000 bits/second) = 0.82 second. |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
524 |
OnOffHelper onoff ("ns3::UdpSocketFactory", |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
525 |
Address (InetSocketAddress (interfaces.GetAddress (1), port))); |
9000
3ec20a64fd08
Add a constant rate setting function to the on-off helper
Mitch Watrous
parents:
8966
diff
changeset
|
526 |
onoff.SetConstantRate (DataRate (5000)); |
6624
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
527 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
528 |
ApplicationContainer app = onoff.Install (nodes.Get (0)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
529 |
// Start the application |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
530 |
app.Start (Seconds (1.0)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
531 |
app.Stop (Seconds (10.0)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
532 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
533 |
// Create an optional packet sink to receive these packets |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
534 |
PacketSinkHelper sink ("ns3::UdpSocketFactory", |
7191
7b9f3eba908b
test coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7008
diff
changeset
|
535 |
Address (InetSocketAddress (Ipv4Address::GetAny (), port))); |
6624
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
536 |
app = sink.Install (nodes.Get (1)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
537 |
app.Start (Seconds (0.0)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
538 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
539 |
// |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
540 |
// Create a similar flow from n3 to n0, starting at time 1.1 seconds |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
541 |
// |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
542 |
onoff.SetAttribute ("Remote", |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
543 |
AddressValue (InetSocketAddress (interfaces.GetAddress (0), port))); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
544 |
app = onoff.Install (nodes.Get (3)); |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7191
diff
changeset
|
545 |
app.Start (Seconds (1.1)); |
6624
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
546 |
app.Stop (Seconds (10.0)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
547 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
548 |
app = sink.Install (nodes.Get (0)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
549 |
app.Start (Seconds (0.0)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
550 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
551 |
// Trace receptions |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
552 |
Config::ConnectWithoutContext ("/NodeList/0/ApplicationList/1/$ns3::PacketSink/Rx", MakeCallback (&CsmaOneSubnetTestCase::SinkRxNode0, this)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
553 |
Config::ConnectWithoutContext ("/NodeList/1/ApplicationList/0/$ns3::PacketSink/Rx", MakeCallback (&CsmaOneSubnetTestCase::SinkRxNode1, this)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
554 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
555 |
// |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
556 |
// Now, do the actual simulation. |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
557 |
// |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
558 |
Simulator::Run (); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
559 |
Simulator::Destroy (); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
560 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
561 |
// We should have sent and received 10 packets |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
562 |
NS_TEST_ASSERT_MSG_EQ (m_countNode0, 10, "Node 0 should have received 10 packets"); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
563 |
NS_TEST_ASSERT_MSG_EQ (m_countNode1, 10, "Node 1 should have received 10 packets"); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
564 |
} |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
565 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
566 |
class CsmaPacketSocketTestCase : public TestCase |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
567 |
{ |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
568 |
public: |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
569 |
CsmaPacketSocketTestCase (); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
570 |
virtual ~CsmaPacketSocketTestCase (); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
571 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
572 |
private: |
6775
0783f42a364b
Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents:
6624
diff
changeset
|
573 |
virtual void DoRun (void); |
6624
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
574 |
void SinkRx (std::string path, Ptr<const Packet> p, const Address &address); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
575 |
void DropEvent (Ptr<const Packet> p); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
576 |
uint32_t m_count; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
577 |
uint32_t m_drops; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
578 |
}; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
579 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
580 |
// Add some help text to this case to describe what it is intended to test |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
581 |
CsmaPacketSocketTestCase::CsmaPacketSocketTestCase () |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
582 |
: TestCase ("Packet socket example for Carrier Sense Multiple Access (CSMA) networks"), m_count (0), m_drops (0) |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
583 |
{ |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
584 |
} |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
585 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
586 |
CsmaPacketSocketTestCase::~CsmaPacketSocketTestCase () |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
587 |
{ |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
588 |
} |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
589 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
590 |
void |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
591 |
CsmaPacketSocketTestCase::SinkRx (std::string path, Ptr<const Packet> p, const Address& address) |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
592 |
{ |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
593 |
m_count++; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
594 |
} |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
595 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
596 |
void |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
597 |
CsmaPacketSocketTestCase::DropEvent (Ptr<const Packet> p) |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
598 |
{ |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
599 |
m_drops++; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
600 |
} |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
601 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
602 |
// |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
603 |
// Network topology |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
604 |
// |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
605 |
// n0 n1 n2 n3 |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
606 |
// | | | | |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
607 |
// ===================== |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
608 |
// |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
609 |
// - Packet socket flow from n0 to n1 and from node n3 to n0 |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
610 |
// -- We will test reception at node n0 |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
611 |
// - Default 512 byte packets generated by traffic generator |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
612 |
// |
6775
0783f42a364b
Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents:
6624
diff
changeset
|
613 |
void |
6624
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
614 |
CsmaPacketSocketTestCase::DoRun (void) |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
615 |
{ |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
616 |
// Here, we will explicitly create four nodes. |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
617 |
NodeContainer nodes; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
618 |
nodes.Create (4); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
619 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
620 |
PacketSocketHelper packetSocket; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
621 |
packetSocket.Install (nodes); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
622 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
623 |
// create the shared medium used by all csma devices. |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
624 |
Ptr<CsmaChannel> channel = CreateObjectWithAttributes<CsmaChannel> ( |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7191
diff
changeset
|
625 |
"DataRate", DataRateValue (DataRate (5000000)), |
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7191
diff
changeset
|
626 |
"Delay", TimeValue (MilliSeconds (2))); |
6624
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
627 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
628 |
// use a helper function to connect our nodes to the shared channel. |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
629 |
CsmaHelper csma; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
630 |
csma.SetDeviceAttribute ("EncapsulationMode", StringValue ("Llc")); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
631 |
NetDeviceContainer devs = csma.Install (nodes, channel); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
632 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
633 |
// Create the OnOff application to send raw datagrams |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
634 |
// |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
635 |
// Make packets be sent about every DefaultPacketSize / DataRate = |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
636 |
// 4096 bits / (5000 bits/second) = 0.82 second. |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
637 |
PacketSocketAddress socket; |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7191
diff
changeset
|
638 |
socket.SetSingleDevice (devs.Get (0)->GetIfIndex ()); |
6624
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
639 |
socket.SetPhysicalAddress (devs.Get (1)->GetAddress ()); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
640 |
socket.SetProtocol (2); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
641 |
OnOffHelper onoff ("ns3::PacketSocketFactory", Address (socket)); |
9000
3ec20a64fd08
Add a constant rate setting function to the on-off helper
Mitch Watrous
parents:
8966
diff
changeset
|
642 |
onoff.SetConstantRate (DataRate (5000)); |
6624
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
643 |
ApplicationContainer apps = onoff.Install (nodes.Get (0)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
644 |
apps.Start (Seconds (1.0)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
645 |
apps.Stop (Seconds (10.0)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
646 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
647 |
socket.SetSingleDevice (devs.Get (3)->GetIfIndex ()); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
648 |
socket.SetPhysicalAddress (devs.Get (0)->GetAddress ()); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
649 |
socket.SetProtocol (3); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
650 |
onoff.SetAttribute ("Remote", AddressValue (socket)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
651 |
apps = onoff.Install (nodes.Get (3)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
652 |
apps.Start (Seconds (1.0)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
653 |
apps.Stop (Seconds (10.0)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
654 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
655 |
PacketSinkHelper sink = PacketSinkHelper ("ns3::PacketSocketFactory", |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
656 |
socket); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
657 |
apps = sink.Install (nodes.Get (0)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
658 |
apps.Start (Seconds (0.0)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
659 |
apps.Stop (Seconds (20.0)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
660 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
661 |
// Trace receptions |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
662 |
Config::Connect ("/NodeList/0/ApplicationList/*/$ns3::PacketSink/Rx", |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
663 |
MakeCallback (&CsmaPacketSocketTestCase::SinkRx, this)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
664 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
665 |
Simulator::Run (); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
666 |
Simulator::Destroy (); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
667 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
668 |
// We should have received 10 packets on node 0 |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
669 |
NS_TEST_ASSERT_MSG_EQ (m_count, 10, "Node 0 should have received 10 packets"); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
670 |
} |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
671 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
672 |
class CsmaPingTestCase : public TestCase |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
673 |
{ |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
674 |
public: |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
675 |
CsmaPingTestCase (); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
676 |
virtual ~CsmaPingTestCase (); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
677 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
678 |
private: |
6775
0783f42a364b
Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents:
6624
diff
changeset
|
679 |
virtual void DoRun (void); |
6624
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
680 |
void SinkRx (Ptr<const Packet> p, const Address &ad); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
681 |
void PingRtt (std::string context, Time rtt); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
682 |
void DropEvent (Ptr<const Packet> p); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
683 |
uint32_t m_countSinkRx; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
684 |
uint32_t m_countPingRtt; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
685 |
uint32_t m_drops; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
686 |
}; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
687 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
688 |
// Add some help text to this case to describe what it is intended to test |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
689 |
CsmaPingTestCase::CsmaPingTestCase () |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
690 |
: TestCase ("Ping example for Carrier Sense Multiple Access (CSMA) networks"), m_countSinkRx (0), m_countPingRtt (0), m_drops (0) |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
691 |
{ |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
692 |
} |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
693 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
694 |
CsmaPingTestCase::~CsmaPingTestCase () |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
695 |
{ |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
696 |
} |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
697 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
698 |
void |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
699 |
CsmaPingTestCase::SinkRx (Ptr<const Packet> p, const Address &ad) |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
700 |
{ |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
701 |
m_countSinkRx++; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
702 |
} |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
703 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
704 |
void |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
705 |
CsmaPingTestCase::PingRtt (std::string context, Time rtt) |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
706 |
{ |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
707 |
m_countPingRtt++; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
708 |
} |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
709 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
710 |
void |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
711 |
CsmaPingTestCase::DropEvent (Ptr<const Packet> p) |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
712 |
{ |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
713 |
m_drops++; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
714 |
} |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
715 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
716 |
// Network topology |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
717 |
// |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
718 |
// n0 n1 n2 n3 |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
719 |
// | | | | |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
720 |
// ===================== |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
721 |
// |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
722 |
// node n0,n1,n3 pings to node n2 |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
723 |
// node n0 generates protocol 2 (IGMP) to node n3 |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
724 |
// |
6775
0783f42a364b
Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents:
6624
diff
changeset
|
725 |
void |
6624
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
726 |
CsmaPingTestCase::DoRun (void) |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
727 |
{ |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
728 |
// Here, we will explicitly create four nodes. |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
729 |
NodeContainer c; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
730 |
c.Create (4); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
731 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
732 |
// connect all our nodes to a shared channel. |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
733 |
CsmaHelper csma; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
734 |
csma.SetChannelAttribute ("DataRate", DataRateValue (DataRate (5000000))); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
735 |
csma.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (2))); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
736 |
csma.SetDeviceAttribute ("EncapsulationMode", StringValue ("Llc")); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
737 |
NetDeviceContainer devs = csma.Install (c); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
738 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
739 |
// add an ip stack to all nodes. |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
740 |
InternetStackHelper ipStack; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
741 |
ipStack.Install (c); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
742 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
743 |
// assign ip addresses |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
744 |
Ipv4AddressHelper ip; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
745 |
ip.SetBase ("192.168.1.0", "255.255.255.0"); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
746 |
Ipv4InterfaceContainer addresses = ip.Assign (devs); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
747 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
748 |
// Create the OnOff application to send UDP datagrams from n0 to n1. |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
749 |
// |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
750 |
// Make packets be sent about every DefaultPacketSize / DataRate = |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
751 |
// 4096 bits / (5000 bits/second) = 0.82 second. |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
752 |
Config::SetDefault ("ns3::Ipv4RawSocketImpl::Protocol", StringValue ("2")); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
753 |
InetSocketAddress dst = InetSocketAddress (addresses.GetAddress (3)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
754 |
OnOffHelper onoff = OnOffHelper ("ns3::Ipv4RawSocketFactory", dst); |
9000
3ec20a64fd08
Add a constant rate setting function to the on-off helper
Mitch Watrous
parents:
8966
diff
changeset
|
755 |
onoff.SetConstantRate (DataRate (5000)); |
6624
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
756 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
757 |
ApplicationContainer apps = onoff.Install (c.Get (0)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
758 |
apps.Start (Seconds (1.0)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
759 |
apps.Stop (Seconds (10.0)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
760 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
761 |
PacketSinkHelper sink = PacketSinkHelper ("ns3::Ipv4RawSocketFactory", dst); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
762 |
apps = sink.Install (c.Get (3)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
763 |
apps.Start (Seconds (0.0)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
764 |
apps.Stop (Seconds (11.0)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
765 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
766 |
V4PingHelper ping = V4PingHelper (addresses.GetAddress (2)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
767 |
NodeContainer pingers; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
768 |
pingers.Add (c.Get (0)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
769 |
pingers.Add (c.Get (1)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
770 |
pingers.Add (c.Get (3)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
771 |
apps = ping.Install (pingers); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
772 |
apps.Start (Seconds (2.0)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
773 |
apps.Stop (Seconds (5.0)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
774 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
775 |
// Trace receptions |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
776 |
Config::ConnectWithoutContext ("/NodeList/3/ApplicationList/0/$ns3::PacketSink/Rx", |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
777 |
MakeCallback (&CsmaPingTestCase::SinkRx, this)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
778 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
779 |
// Trace pings |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
780 |
Config::Connect ("/NodeList/*/ApplicationList/*/$ns3::V4Ping/Rtt", |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
781 |
MakeCallback (&CsmaPingTestCase::PingRtt, this)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
782 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
783 |
Simulator::Run (); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
784 |
Simulator::Destroy (); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
785 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
786 |
// We should have sent and received 10 packets |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
787 |
NS_TEST_ASSERT_MSG_EQ (m_countSinkRx, 10, "Node 3 should have received 10 packets"); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
788 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
789 |
// We should have 3 pingers that ping every second for 3 seconds. |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
790 |
NS_TEST_ASSERT_MSG_EQ (m_countPingRtt, 9, "Node 2 should have been pinged 9 times"); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
791 |
} |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
792 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
793 |
class CsmaRawIpSocketTestCase : public TestCase |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
794 |
{ |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
795 |
public: |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
796 |
CsmaRawIpSocketTestCase (); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
797 |
virtual ~CsmaRawIpSocketTestCase (); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
798 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
799 |
private: |
6775
0783f42a364b
Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents:
6624
diff
changeset
|
800 |
virtual void DoRun (void); |
6624
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
801 |
void SinkRx (Ptr<const Packet> p, const Address &ad); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
802 |
void DropEvent (Ptr<const Packet> p); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
803 |
uint32_t m_count; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
804 |
uint32_t m_drops; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
805 |
}; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
806 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
807 |
// Add some help text to this case to describe what it is intended to test |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
808 |
CsmaRawIpSocketTestCase::CsmaRawIpSocketTestCase () |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
809 |
: TestCase ("Raw internet protocol socket example for Carrier Sense Multiple Access (CSMA) networks"), m_count (0), m_drops (0) |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
810 |
{ |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
811 |
} |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
812 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
813 |
CsmaRawIpSocketTestCase::~CsmaRawIpSocketTestCase () |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
814 |
{ |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
815 |
} |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
816 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
817 |
void |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
818 |
CsmaRawIpSocketTestCase::SinkRx (Ptr<const Packet> p, const Address &ad) |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
819 |
{ |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
820 |
m_count++; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
821 |
} |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
822 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
823 |
void |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
824 |
CsmaRawIpSocketTestCase::DropEvent (Ptr<const Packet> p) |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
825 |
{ |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
826 |
m_drops++; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
827 |
} |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
828 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
829 |
// |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
830 |
// Network topology |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
831 |
// (sender) (receiver) |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
832 |
// n0 n1 n2 n3 |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
833 |
// | | | | |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
834 |
// ===================== |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
835 |
// |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
836 |
// Node n0 sends data to node n3 over a raw IP socket. The protocol |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
837 |
// number used is 2. |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
838 |
// |
6775
0783f42a364b
Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents:
6624
diff
changeset
|
839 |
void |
6624
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
840 |
CsmaRawIpSocketTestCase::DoRun (void) |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
841 |
{ |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
842 |
// Here, we will explicitly create four nodes. |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
843 |
NodeContainer c; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
844 |
c.Create (4); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
845 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
846 |
// connect all our nodes to a shared channel. |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
847 |
CsmaHelper csma; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
848 |
csma.SetChannelAttribute ("DataRate", DataRateValue (DataRate (5000000))); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
849 |
csma.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (2))); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
850 |
csma.SetDeviceAttribute ("EncapsulationMode", StringValue ("Llc")); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
851 |
NetDeviceContainer devs = csma.Install (c); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
852 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
853 |
// add an ip stack to all nodes. |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
854 |
InternetStackHelper ipStack; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
855 |
ipStack.Install (c); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
856 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
857 |
// assign ip addresses |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
858 |
Ipv4AddressHelper ip; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
859 |
ip.SetBase ("192.168.1.0", "255.255.255.0"); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
860 |
Ipv4InterfaceContainer addresses = ip.Assign (devs); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
861 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
862 |
// IP protocol configuration |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
863 |
// |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
864 |
// Make packets be sent about every DefaultPacketSize / DataRate = |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
865 |
// 4096 bits / (5000 bits/second) = 0.82 second. |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
866 |
Config::SetDefault ("ns3::Ipv4RawSocketImpl::Protocol", StringValue ("2")); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
867 |
InetSocketAddress dst = InetSocketAddress (addresses.GetAddress (3)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
868 |
OnOffHelper onoff = OnOffHelper ("ns3::Ipv4RawSocketFactory", dst); |
9000
3ec20a64fd08
Add a constant rate setting function to the on-off helper
Mitch Watrous
parents:
8966
diff
changeset
|
869 |
onoff.SetConstantRate (DataRate (5000)); |
6624
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
870 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
871 |
ApplicationContainer apps = onoff.Install (c.Get (0)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
872 |
apps.Start (Seconds (1.0)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
873 |
apps.Stop (Seconds (10.0)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
874 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
875 |
PacketSinkHelper sink = PacketSinkHelper ("ns3::Ipv4RawSocketFactory", dst); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
876 |
apps = sink.Install (c.Get (3)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
877 |
apps.Start (Seconds (0.0)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
878 |
apps.Stop (Seconds (12.0)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
879 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
880 |
// Trace receptions |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
881 |
Config::ConnectWithoutContext ("/NodeList/3/ApplicationList/0/$ns3::PacketSink/Rx", |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
882 |
MakeCallback (&CsmaRawIpSocketTestCase::SinkRx, this)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
883 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
884 |
Simulator::Run (); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
885 |
Simulator::Destroy (); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
886 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
887 |
// We should have sent and received 10 packets |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
888 |
NS_TEST_ASSERT_MSG_EQ (m_count, 10, "Node 3 should have received 10 packets"); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
889 |
} |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
890 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
891 |
class CsmaStarTestCase : public TestCase |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
892 |
{ |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
893 |
public: |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
894 |
CsmaStarTestCase (); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
895 |
virtual ~CsmaStarTestCase (); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
896 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
897 |
private: |
6775
0783f42a364b
Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents:
6624
diff
changeset
|
898 |
virtual void DoRun (void); |
6624
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
899 |
void SinkRx (Ptr<const Packet> p, const Address &ad); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
900 |
void DropEvent (Ptr<const Packet> p); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
901 |
uint32_t m_count; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
902 |
uint32_t m_drops; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
903 |
}; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
904 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
905 |
// Add some help text to this case to describe what it is intended to test |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
906 |
CsmaStarTestCase::CsmaStarTestCase () |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
907 |
: TestCase ("Star example for Carrier Sense Multiple Access (CSMA) networks"), m_count (0), m_drops (0) |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
908 |
{ |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
909 |
} |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
910 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
911 |
CsmaStarTestCase::~CsmaStarTestCase () |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
912 |
{ |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
913 |
} |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
914 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
915 |
void |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
916 |
CsmaStarTestCase::SinkRx (Ptr<const Packet> p, const Address& ad) |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
917 |
{ |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
918 |
m_count++; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
919 |
} |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
920 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
921 |
void |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
922 |
CsmaStarTestCase::DropEvent (Ptr<const Packet> p) |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
923 |
{ |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
924 |
m_drops++; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
925 |
} |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
926 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
927 |
// Network topology (default) |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
928 |
// |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
929 |
// n2 + + n3 . |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
930 |
// | ... |\ /| ... | . |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
931 |
// ======= \ / ======= . |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
932 |
// CSMA \ / CSMA . |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
933 |
// \ / . |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
934 |
// n1 +--- n0 ---+ n4 . |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
935 |
// | ... | / \ | ... | . |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
936 |
// ======= / \ ======= . |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
937 |
// CSMA / \ CSMA . |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
938 |
// / \ . |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
939 |
// n6 + + n5 . |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
940 |
// | ... | | ... | . |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
941 |
// ======= ======= . |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
942 |
// CSMA CSMA . |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
943 |
// |
6775
0783f42a364b
Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents:
6624
diff
changeset
|
944 |
void |
6624
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
945 |
CsmaStarTestCase::DoRun (void) |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
946 |
{ |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
947 |
// |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
948 |
// Default number of nodes in the star. |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
949 |
// |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
950 |
uint32_t nSpokes = 7; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
951 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
952 |
CsmaHelper csma; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
953 |
csma.SetChannelAttribute ("DataRate", StringValue ("100Mbps")); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
954 |
csma.SetChannelAttribute ("Delay", StringValue ("1ms")); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
955 |
CsmaStarHelper star (nSpokes, csma); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
956 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
957 |
NodeContainer fillNodes; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
958 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
959 |
// |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
960 |
// Just to be nasy, hang some more nodes off of the CSMA channel for each |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
961 |
// spoke, so that there are a total of 16 nodes on each channel. Stash |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
962 |
// all of these new devices into a container. |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
963 |
// |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
964 |
NetDeviceContainer fillDevices; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
965 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
966 |
uint32_t nFill = 14; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
967 |
for (uint32_t i = 0; i < star.GetSpokeDevices ().GetN (); ++i) |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
968 |
{ |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
969 |
Ptr<Channel> channel = star.GetSpokeDevices ().Get (i)->GetChannel (); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
970 |
Ptr<CsmaChannel> csmaChannel = channel->GetObject<CsmaChannel> (); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
971 |
NodeContainer newNodes; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
972 |
newNodes.Create (nFill); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
973 |
fillNodes.Add (newNodes); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
974 |
fillDevices.Add (csma.Install (newNodes, csmaChannel)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
975 |
} |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
976 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
977 |
InternetStackHelper internet; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
978 |
star.InstallStack (internet); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
979 |
internet.Install (fillNodes); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
980 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
981 |
star.AssignIpv4Addresses (Ipv4AddressHelper ("10.1.0.0", "255.255.255.0")); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
982 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
983 |
// |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
984 |
// We assigned addresses to the logical hub and the first "drop" of the |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
985 |
// CSMA network that acts as the spoke, but we also have a number of fill |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
986 |
// devices (nFill) also hanging off the CSMA network. We have got to |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
987 |
// assign addresses to them as well. We put all of the fill devices into |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
988 |
// a single device container, so the first nFill devices are associated |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
989 |
// with the channel connected to spokeDevices.Get (0), the second nFill |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
990 |
// devices afe associated with the channel connected to spokeDevices.Get (1) |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
991 |
// etc. |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
992 |
// |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
993 |
Ipv4AddressHelper address; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
994 |
for(uint32_t i = 0; i < star.SpokeCount (); ++i) |
7191
7b9f3eba908b
test coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7008
diff
changeset
|
995 |
{ |
7b9f3eba908b
test coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7008
diff
changeset
|
996 |
std::ostringstream subnet; |
7b9f3eba908b
test coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7008
diff
changeset
|
997 |
subnet << "10.1." << i << ".0"; |
6624
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
998 |
address.SetBase (subnet.str ().c_str (), "255.255.255.0", "0.0.0.3"); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
999 |
|
7191
7b9f3eba908b
test coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7008
diff
changeset
|
1000 |
for (uint32_t j = 0; j < nFill; ++j) |
7b9f3eba908b
test coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7008
diff
changeset
|
1001 |
{ |
7b9f3eba908b
test coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7008
diff
changeset
|
1002 |
address.Assign (fillDevices.Get (i * nFill + j)); |
7b9f3eba908b
test coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7008
diff
changeset
|
1003 |
} |
7b9f3eba908b
test coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7008
diff
changeset
|
1004 |
} |
6624
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1005 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1006 |
// |
7191
7b9f3eba908b
test coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7008
diff
changeset
|
1007 |
// Create a packet sink on the star "hub" to receive packets. |
6624
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1008 |
// |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1009 |
uint16_t port = 50000; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1010 |
Address hubLocalAddress (InetSocketAddress (Ipv4Address::GetAny (), port)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1011 |
PacketSinkHelper packetSinkHelper ("ns3::TcpSocketFactory", hubLocalAddress); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1012 |
ApplicationContainer hubApp = packetSinkHelper.Install (star.GetHub ()); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1013 |
hubApp.Start (Seconds (1.0)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1014 |
hubApp.Stop (Seconds (10.0)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1015 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1016 |
// |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1017 |
// Create OnOff applications to send TCP to the hub, one on each spoke node. |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1018 |
// |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1019 |
// Make packets be sent about every DefaultPacketSize / DataRate = |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1020 |
// 4096 bits / (5000 bits/second) = 0.82 second. |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1021 |
OnOffHelper onOffHelper ("ns3::TcpSocketFactory", Address ()); |
9000
3ec20a64fd08
Add a constant rate setting function to the on-off helper
Mitch Watrous
parents:
8966
diff
changeset
|
1022 |
onOffHelper.SetConstantRate (DataRate (5000)); |
6624
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1023 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1024 |
ApplicationContainer spokeApps; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1025 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1026 |
for (uint32_t i = 0; i < star.SpokeCount (); ++i) |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1027 |
{ |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1028 |
AddressValue remoteAddress (InetSocketAddress (star.GetHubIpv4Address (i), port)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1029 |
onOffHelper.SetAttribute ("Remote", remoteAddress); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1030 |
spokeApps.Add (onOffHelper.Install (star.GetSpokeNode (i))); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1031 |
} |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1032 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1033 |
spokeApps.Start (Seconds (1.0)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1034 |
spokeApps.Stop (Seconds (10.0)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1035 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1036 |
// |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1037 |
// Because we are evil, we also add OnOff applications to send TCP to the hub |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1038 |
// from the fill devices on each CSMA link. The first nFill nodes in the |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1039 |
// fillNodes container are on the CSMA network talking to the zeroth device |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1040 |
// on the hub node. The next nFill nodes are on the CSMA network talking to |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1041 |
// the first device on the hub node, etc. So the ith fillNode is associated |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1042 |
// with the hub address found on the (i / nFill)th device on the hub node. |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1043 |
// |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1044 |
ApplicationContainer fillApps; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1045 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1046 |
for (uint32_t i = 0; i < fillNodes.GetN (); ++i) |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1047 |
{ |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1048 |
AddressValue remoteAddress (InetSocketAddress (star.GetHubIpv4Address (i / nFill), port)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1049 |
onOffHelper.SetAttribute ("Remote", remoteAddress); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1050 |
fillApps.Add (onOffHelper.Install (fillNodes.Get (i))); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1051 |
} |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1052 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1053 |
fillApps.Start (Seconds (1.0)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1054 |
fillApps.Stop (Seconds (10.0)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1055 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1056 |
// |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1057 |
// Turn on global static routing so we can actually be routed across the star. |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1058 |
// |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1059 |
Ipv4GlobalRoutingHelper::PopulateRoutingTables (); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1060 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1061 |
// Trace receptions |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1062 |
Config::ConnectWithoutContext ("/NodeList/0/ApplicationList/*/$ns3::PacketSink/Rx", |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1063 |
MakeCallback (&CsmaStarTestCase::SinkRx, this)); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1064 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1065 |
Simulator::Run (); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1066 |
Simulator::Destroy (); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1067 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1068 |
// The hub node should have received 10 packets from the nFill + 1 |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1069 |
// nodes on each spoke. |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1070 |
NS_TEST_ASSERT_MSG_EQ (m_count, 10 * ( nSpokes * (nFill + 1)), "Hub node did not receive the proper number of packets"); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1071 |
} |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1072 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1073 |
class CsmaSystemTestSuite : public TestSuite |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1074 |
{ |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1075 |
public: |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1076 |
CsmaSystemTestSuite (); |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1077 |
}; |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1078 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1079 |
CsmaSystemTestSuite::CsmaSystemTestSuite () |
7008
82c66d5c01f7
Relabel all build verification tests (BVT) to be unit tests (UNIT)
Mitch Watrous <watrous@u.washington.edu>
parents:
6775
diff
changeset
|
1080 |
: TestSuite ("csma-system", UNIT) |
6624
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1081 |
{ |
9266
d26408b17360
bug 1563: get rid of default argument value in AddTestCase
Nicola Baldo <nbaldo@cttc.es>
parents:
9000
diff
changeset
|
1082 |
AddTestCase (new CsmaBridgeTestCase, TestCase::QUICK); |
d26408b17360
bug 1563: get rid of default argument value in AddTestCase
Nicola Baldo <nbaldo@cttc.es>
parents:
9000
diff
changeset
|
1083 |
AddTestCase (new CsmaBroadcastTestCase, TestCase::QUICK); |
d26408b17360
bug 1563: get rid of default argument value in AddTestCase
Nicola Baldo <nbaldo@cttc.es>
parents:
9000
diff
changeset
|
1084 |
AddTestCase (new CsmaMulticastTestCase, TestCase::QUICK); |
d26408b17360
bug 1563: get rid of default argument value in AddTestCase
Nicola Baldo <nbaldo@cttc.es>
parents:
9000
diff
changeset
|
1085 |
AddTestCase (new CsmaOneSubnetTestCase, TestCase::QUICK); |
d26408b17360
bug 1563: get rid of default argument value in AddTestCase
Nicola Baldo <nbaldo@cttc.es>
parents:
9000
diff
changeset
|
1086 |
AddTestCase (new CsmaPacketSocketTestCase, TestCase::QUICK); |
d26408b17360
bug 1563: get rid of default argument value in AddTestCase
Nicola Baldo <nbaldo@cttc.es>
parents:
9000
diff
changeset
|
1087 |
AddTestCase (new CsmaPingTestCase, TestCase::QUICK); |
d26408b17360
bug 1563: get rid of default argument value in AddTestCase
Nicola Baldo <nbaldo@cttc.es>
parents:
9000
diff
changeset
|
1088 |
AddTestCase (new CsmaRawIpSocketTestCase, TestCase::QUICK); |
d26408b17360
bug 1563: get rid of default argument value in AddTestCase
Nicola Baldo <nbaldo@cttc.es>
parents:
9000
diff
changeset
|
1089 |
AddTestCase (new CsmaStarTestCase, TestCase::QUICK); |
6624
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1090 |
} |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1091 |
|
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1092 |
// Do not forget to allocate an instance of this TestSuite |
a071889af159
Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1093 |
static CsmaSystemTestSuite csmaSystemTestSuite; |