Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2015 Federico Guerra | 3 * Copyright (c) 2015 Federico Guerra |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 5 * This program is free software; you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 2 as | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
15 * along with this program; if not, write to the Free Software | 15 * along with this program; if not, write to the Free Software |
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
17 * | 17 * |
18 * Author: Federico Guerra <federico@guerra-tlc.com> | 18 * Authors: Federico Guerra <federico@guerra-tlc.com>, Randall Plate <rplate@spa war.navy.mil> |
19 */ | 19 */ |
20 | 20 |
Tom Henderson
2016/04/25 17:45:07
please add some comments about what specifically i
Fedwar
2016/04/30 21:18:09
Acknowledged.
Fedwar
2016/05/08 16:19:48
Done.
| |
21 #ifdef NS3_WOSS_SUPPORT | 21 #ifdef NS3_WOSS_SUPPORT |
22 | 22 |
23 #include "ns3/uan-net-device.h" | 23 #include "ns3/core-module.h" |
24 #include "ns3/uan-module.h" | |
24 #include "ns3/woss-channel.h" | 25 #include "ns3/woss-channel.h" |
25 #include "ns3/uan-mac-aloha.h" | 26 #include "ns3/uan-mac-aloha.h" |
26 #include "ns3/uan-phy-gen.h" | 27 #include "ns3/uan-phy-gen.h" |
27 #include "ns3/uan-transducer-hd.h" | 28 #include "ns3/uan-transducer-hd.h" |
28 #include "ns3/uan-prop-model-ideal.h" | 29 #include "ns3/uan-prop-model-ideal.h" |
29 #include "ns3/constant-position-mobility-model.h" | 30 #include "ns3/constant-position-mobility-model.h" |
30 #include "ns3/simulator.h" | 31 #include "ns3/simulator.h" |
31 #include "ns3/test.h" | 32 #include "ns3/test.h" |
32 #include "ns3/node.h" | 33 #include "ns3/node.h" |
33 #include "ns3/object-factory.h" | 34 #include "ns3/object-factory.h" |
34 #include "ns3/pointer.h" | 35 #include "ns3/pointer.h" |
35 #include "ns3/callback.h" | 36 #include "ns3/callback.h" |
36 #include "ns3/woss-helper.h" | 37 #include "ns3/woss-helper.h" |
37 #include "ns3/woss-position-allocator.h" | 38 #include "ns3/woss-position-allocator.h" |
38 #include "ns3/double.h" | 39 #include "ns3/double.h" |
39 #include "ns3/boolean.h" | 40 #include "ns3/boolean.h" |
40 #include "ns3/integer.h" | 41 #include "ns3/integer.h" |
41 #include "ns3/string.h" | 42 #include "ns3/string.h" |
42 | 43 |
43 using namespace ns3; | 44 using namespace ns3; |
44 | 45 |
46 /** | |
47 * \ingroup woss | |
48 * | |
49 * WOSS test | |
50 * | |
51 * The class test perform the following: | |
52 * -# a Vector to woss::CoordZ conversion check. the conversion should be inside tolerance | |
53 * -# it creates two nodes at 1000m distance and then it checks that the WOSS co mputed attenuation of both channels is within tolerance | |
54 * -# it then performs PHY tests by: | |
55 * -# testing a PSK no-collision scenario | |
56 * -# testing a PSK collision scenario | |
57 * -# Propagation Tests: verify WOSS attenuation matches Thorp for deep water co lumn case | |
58 */ | |
45 class WossTest : public TestCase | 59 class WossTest : public TestCase |
46 { | 60 { |
47 public: | 61 public: |
48 WossTest (); | 62 WossTest (); |
49 | 63 |
50 virtual void DoRun (void); | 64 virtual void DoRun (void); |
51 private: | 65 private: |
52 ·· | 66 Ptr<UanNetDevice> CreateNode (Vector pos, Ptr<UanChannel> chan); |
53 Ptr<UanNetDevice> CreateNode (Vector pos, Ptr<WossChannel> chan); | 67 |
54 | |
55 void InitWossHelper (Ptr<WossPropModel> wossProp); | 68 void InitWossHelper (Ptr<WossPropModel> wossProp); |
56 | 69 |
57 bool DoPhyTests (Ptr<WossPropModel> prop); | 70 bool DoPhyTests (Ptr<WossPropModel> prop); |
58 uint32_t DoOnePhyTest (Time t1, Time t2, uint32_t r1, uint32_t r2, Ptr<WossPro pModel> prop, uint32_t mode1 = 0, uint32_t mode2 = 0); | 71 uint32_t DoOnePhyTest (Time t1, Time t2, uint32_t r1, uint32_t r2, Ptr<WossPro pModel> prop, uint32_t mode1 = 0, uint32_t mode2 = 0); |
59 bool RxPacket (Ptr<NetDevice> dev, Ptr<const Packet> pkt, uint16_t mode, const Address &sender); | 72 bool RxPacket (Ptr<NetDevice> dev, Ptr<const Packet> pkt, uint16_t mode, const Address &sender); |
60 void SendOnePacket (Ptr<UanNetDevice> dev, uint32_t mode); | 73 void SendOnePacket (Ptr<UanNetDevice> dev, uint32_t mode); |
61 ·· | 74 void WossThorpRun(Ptr<UanChannel> chan); |
75 void DoWossThorpTests(Ptr<WossPropModel> prop, double ranges[], double windNoi se, double shipNoise); | |
76 void PktRxOkThorpCallback (std::string trace_str, Ptr< const Packet > pkt, dou ble sinr, UanTxMode mode); | |
77 void PktRxOkWossCallback (std::string trace_str, Ptr< const Packet > pkt, doub le sinr, UanTxMode mode); | |
78 | |
62 ObjectFactory m_phyFac; | 79 ObjectFactory m_phyFac; |
63 uint32_t m_bytesRx; | 80 uint32_t m_bytesRx; |
81 std::vector <double> m_thorpSinr; | |
82 std::vector <double> m_wossSinr; | |
64 Ptr<WossHelper> m_wossHelper; | 83 Ptr<WossHelper> m_wossHelper; |
65 ::std::string m_databasePath; | 84 ::std::string m_databasePath; |
66 bool m_useTimeEvolution; | 85 bool m_useTimeEvolution; |
67 bool m_useMultithread; | 86 bool m_useMultithread; |
68 woss::CoordZ m_sinkCoord; | 87 woss::CoordZ m_sinkCoord; |
69 | 88 |
70 }; | 89 }; |
71 | 90 |
72 | 91 |
73 WossTest::WossTest ()· | 92 WossTest::WossTest () |
74 : TestCase ("WOSS"), | 93 : TestCase ("WOSS"), |
75 m_databasePath (""), | 94 m_databasePath (""), |
76 m_useTimeEvolution (false), | 95 m_useTimeEvolution (false), |
77 m_useMultithread (false), | 96 m_useMultithread (false), |
78 m_sinkCoord (42.59, 10.125, 70.0) | 97 m_sinkCoord (42.59, 10.125, 70.0) |
79 { | 98 { |
80 | 99 |
81 } | 100 } |
82 | 101 |
83 void | 102 void |
84 WossTest::InitWossHelper (Ptr<WossPropModel> wossProp) | 103 WossTest::InitWossHelper (Ptr<WossPropModel> wossProp) |
85 { | 104 { |
86 m_wossHelper->SetAttribute ("ResDbUseBinary", BooleanValue (false)); | 105 m_wossHelper->SetAttribute ("ResDbUseBinary", BooleanValue (false)); |
87 m_wossHelper->SetAttribute ("ResDbUseTimeArr", BooleanValue (true)); | 106 m_wossHelper->SetAttribute ("ResDbUseTimeArr", BooleanValue (true)); |
88 m_wossHelper->SetAttribute ("ResDbFilePath", StringValue ("/dev/shm/ns3_woss_t est/")); | 107 m_wossHelper->SetAttribute ("ResDbFilePath", StringValue ("./woss-test-output/ res-db/")); |
Fedwar
2016/05/08 16:19:48
changing this path to "./ns3-woss_test/results" le
| |
89 m_wossHelper->SetAttribute ("ResDbFileName", StringValue ("test.dat"));· | 108 |
90 ·· | |
91 if (m_databasePath != "") | 109 if (m_databasePath != "") |
92 { | 110 { |
93 m_wossHelper->SetAttribute ("SedimDbCoordFilePath", StringValue (m_databaseP ath + "/sea_floor/DECK41_coordinates.nc")); | 111 m_wossHelper->SetAttribute ("SedimDbCoordFilePath", StringValue (m_databas ePath + "/sea_floor/DECK41_coordinates.nc")); |
94 m_wossHelper->SetAttribute ("SedimDbMarsdenFilePath", StringValue (m_databas ePath + "/sea_floor/DECK41_mardsen_square.nc")); | 112 m_wossHelper->SetAttribute ("SedimDbMarsdenFilePath", StringValue (m_datab asePath + "/sea_floor/DECK41_mardsen_square.nc")); |
95 m_wossHelper->SetAttribute ("SedimDbMarsdenOneFilePath", StringValue (m_data basePath + "/sea_floor/DECK41_mardsen_one_degree.nc")); | 113 m_wossHelper->SetAttribute ("SedimDbMarsdenOneFilePath", StringValue (m_da tabasePath + "/sea_floor/DECK41_mardsen_one_degree.nc")); |
96 m_wossHelper->SetAttribute ("SspDbCoordFilePath", StringValue (m_databasePat h + "/ssp/standard_depth/2WOA2009_SSP_April.nc")); | 114 m_wossHelper->SetAttribute ("SspDbCoordFilePath", StringValue (m_databaseP ath + "/ssp/standard_depth/2WOA2009_SSP_April.nc")); |
97 m_wossHelper->SetAttribute ("BathyDbCoordFilePath", StringValue (m_databaseP ath + "/bathymetry/gebco_08.nc")); | 115 m_wossHelper->SetAttribute ("BathyDbCoordFilePath", StringValue (m_databas ePath + "/bathymetry/gebco_08.nc")); |
98 } | 116 } |
99 ·· | 117 |
100 m_wossHelper->SetAttribute ("WossCleanWorkDir", BooleanValue (false)); | 118 m_wossHelper->SetAttribute ("WossCleanWorkDir", BooleanValue (false)); |
101 m_wossHelper->SetAttribute ("WossWorkDirPath", StringValue ("/dev/shm/ns3_woss _test/")); | 119 m_wossHelper->SetAttribute ("WossWorkDirPath", StringValue ("./woss-test-outpu t/work-dir/")); |
102 m_wossHelper->SetAttribute ("WossSimTime", StringValue ("1|10|2012|0|1|1|1|10| 2012|0|1|1")); | 120 m_wossHelper->SetAttribute ("WossSimTime", StringValue ("1|10|2012|0|1|1|1|10| 2012|0|1|1")); |
103 m_wossHelper->SetAttribute ("WossManagerTimeEvoActive", BooleanValue(m_useTime Evolution)); | 121 m_wossHelper->SetAttribute ("WossManagerTimeEvoActive", BooleanValue (m_useTim eEvolution)); |
104 m_wossHelper->SetAttribute ("WossManagerTotalThreads", IntegerValue (4)); | 122 m_wossHelper->SetAttribute ("WossManagerTotalThreads", IntegerValue (4)); |
105 m_wossHelper->SetAttribute ("WossManagerUseMultithread", BooleanValue (m_useMu ltithread)); | 123 m_wossHelper->SetAttribute ("WossManagerUseMultithread", BooleanValue (m_useMu ltithread)); |
106 | 124 |
107 m_wossHelper->Initialize (wossProp); | 125 m_wossHelper->Initialize (wossProp); |
108 | 126 |
109 if (m_databasePath == "") | 127 if (m_databasePath == "") |
110 { | 128 { |
111 m_wossHelper->SetCustomBathymetry ("5|0.0|100.0|100.0|200.0|300.0|150.0|400. 0|100.0|700.0|300.0", m_sinkCoord); | 129 m_wossHelper->SetCustomBathymetry ("5|0.0|100.0|100.0|202.0|300.0|150.0|40 0.0|100.0|700.0|303.0", m_sinkCoord); |
112 m_wossHelper->SetCustomSediment ("TestSediment|1560.0|200.0|1.5|0.9|0.8|300. 0"); | 130 m_wossHelper->SetCustomSediment ("TestSediment|1560.0|200.0|1.5|0.9|0.8|30 0.0"); |
113 m_wossHelper->SetCustomSsp ("12|0|1508.42|10|1508.02|20|1507.71|30|1507.53|5 0|1507.03|75|1507.56|100|1508.08|125|1508.49|150|1508.91|200|1509.75|250|1510.58 |300|1511.42"); | 131 m_wossHelper->SetCustomSsp ("12|0|1508.42|10|1508.02|20|1507.71|30|1507.53 |50|1507.03|75|1507.56|100|1508.08|125|1508.49|150|1508.91|200|1509.75|250|1510. 58|300|1511.42"); |
114 } | 132 } |
115 ·· | 133 |
116 } | 134 } |
117 | 135 |
118 bool | 136 bool |
119 WossTest::RxPacket (Ptr<NetDevice> dev, Ptr<const Packet> pkt, uint16_t mode, co nst Address &sender) | 137 WossTest::RxPacket (Ptr<NetDevice> dev, Ptr<const Packet> pkt, uint16_t mode, co nst Address &sender) |
120 { | 138 { |
121 m_bytesRx += pkt->GetSize (); | 139 m_bytesRx += pkt->GetSize (); |
122 return true; | 140 return true; |
123 } | 141 } |
124 void | 142 void |
125 WossTest::SendOnePacket (Ptr<UanNetDevice> dev, uint32_t mode) | 143 WossTest::SendOnePacket (Ptr<UanNetDevice> dev, uint32_t mode) |
126 { | 144 { |
127 Ptr<Packet> pkt = Create<Packet> (17); | 145 Ptr<Packet> pkt = Create<Packet> (17); |
128 dev->Send (pkt, dev->GetBroadcast (), mode); | 146 dev->Send (pkt, dev->GetBroadcast (), mode); |
129 | 147 |
130 } | 148 } |
149 | |
131 Ptr<UanNetDevice> | 150 Ptr<UanNetDevice> |
132 WossTest::CreateNode (Vector pos, Ptr<WossChannel> chan) | 151 WossTest::CreateNode (Vector pos, Ptr<UanChannel> chan) |
133 { | 152 { |
134 | 153 |
135 | 154 |
136 Ptr<UanPhy> phy = m_phyFac.Create<UanPhy> (); | 155 Ptr<UanPhy> phy = m_phyFac.Create<UanPhy> (); |
156 phy->SetTxPowerDb(150); | |
157 phy->SetRxThresholdDb(0); | |
137 Ptr<Node> node = CreateObject<Node> (); | 158 Ptr<Node> node = CreateObject<Node> (); |
138 Ptr<UanNetDevice> dev = CreateObject<UanNetDevice> (); | 159 Ptr<UanNetDevice> dev = CreateObject<UanNetDevice> (); |
139 Ptr<UanMacAloha> mac = CreateObject<UanMacAloha> (); | 160 Ptr<UanMacAloha> mac = CreateObject<UanMacAloha> (); |
140 Ptr<ConstantPositionMobilityModel> mobility = CreateObject<ConstantPositionMob ilityModel> (); | 161 Ptr<ConstantPositionMobilityModel> mobility = CreateObject<ConstantPositionMob ilityModel> (); |
141 | 162 |
142 Ptr<UanTransducerHd> trans = CreateObject<UanTransducerHd> (); | 163 Ptr<UanTransducerHd> trans = CreateObject<UanTransducerHd> (); |
143 | 164 |
144 mobility->SetPosition (pos); | 165 mobility->SetPosition (pos); |
145 node->AggregateObject (mobility); | 166 node->AggregateObject (mobility); |
146 mac->SetAddress (UanAddress::Allocate ()); | 167 mac->SetAddress (UanAddress::Allocate ()); |
147 | 168 |
148 dev->SetPhy (phy); | 169 dev->SetPhy (phy); |
149 dev->SetMac (mac); | 170 dev->SetMac (mac); |
150 dev->SetChannel (chan); | 171 dev->SetChannel (chan); |
151 dev->SetTransducer (trans); | 172 dev->SetTransducer (trans); |
152 node->AddDevice (dev); | 173 node->AddDevice (dev); |
153 | 174 |
154 return dev; | 175 return dev; |
155 } | 176 } |
156 | 177 |
157 | 178 |
158 uint32_t | 179 uint32_t |
159 WossTest::DoOnePhyTest (Time txTime1, | 180 WossTest::DoOnePhyTest (Time txTime1, |
160 Time txTime2, | 181 Time txTime2, |
161 uint32_t r1, | 182 uint32_t r1, |
162 uint32_t r2, | 183 uint32_t r2, |
163 Ptr<WossPropModel> prop, | 184 Ptr<WossPropModel> prop, |
164 uint32_t mode1, | 185 uint32_t mode1, |
165 uint32_t mode2) | 186 uint32_t mode2) |
166 { | 187 { |
167 | 188 |
168 Ptr<WossChannel> channel = CreateObject<WossChannel> (); | 189 Ptr<WossChannel> channel = CreateObject<WossChannel> (); |
169 channel->SetAttribute ("PropagationModel", PointerValue (prop)); | 190 channel->SetAttribute ("PropagationModel", PointerValue (prop)); |
170 channel->SetAttribute ("ChannelEqSnrThresholdDb", DoubleValue (-100.0)); | 191 channel->SetAttribute ("ChannelEqSnrThresholdDb", DoubleValue (-100.0)); |
171 | 192 |
172 | 193 |
173 | 194 |
174 Ptr<UanNetDevice> dev0 = CreateNode (CreateVectorFromCoordZ (woss::CoordZ (wos s::Coord::getCoordFromBearing (m_sinkCoord, M_PI/2.0, r1), 70.0)), channel); | 195 Ptr<UanNetDevice> dev0 = CreateNode (CreateVectorFromCoordZ (woss::CoordZ (wos s::Coord::getCoordFromBearing (m_sinkCoord, M_PI / 2.0, r1), 70.0)), channel); |
175 Ptr<UanNetDevice> dev1 = CreateNode (CreateVectorFromCoordZ (m_sinkCoord), cha nnel); | 196 Ptr<UanNetDevice> dev1 = CreateNode (CreateVectorFromCoordZ (m_sinkCoord), cha nnel); |
176 Ptr<UanNetDevice> dev2 = CreateNode (CreateVectorFromCoordZ (woss::CoordZ (wos s::Coord::getCoordFromBearing (m_sinkCoord, M_PI/2.0, r1+r2), 70.0)), channel); | 197 Ptr<UanNetDevice> dev2 = CreateNode (CreateVectorFromCoordZ (woss::CoordZ (wos s::Coord::getCoordFromBearing (m_sinkCoord, M_PI / 2.0, r1 + r2), 70.0)), channe l); |
177 | 198 |
178 dev0->SetReceiveCallback (MakeCallback (&WossTest::RxPacket, this)); | 199 dev0->SetReceiveCallback (MakeCallback (&WossTest::RxPacket, this)); |
179 | 200 |
180 Simulator::Schedule (txTime1, &WossTest::SendOnePacket, this, dev1, mode1); | 201 Simulator::Schedule (txTime1, &WossTest::SendOnePacket, this, dev1, mode1); |
181 Simulator::Schedule (txTime2, &WossTest::SendOnePacket, this, dev2, mode2); | 202 Simulator::Schedule (txTime2, &WossTest::SendOnePacket, this, dev2, mode2); |
182 | 203 |
183 m_bytesRx = 0; | 204 m_bytesRx = 0; |
184 Simulator::Stop (Seconds (20.0)); | 205 Simulator::Stop (Seconds (20.0)); |
185 Simulator::Run (); | 206 Simulator::Run (); |
186 Simulator::Destroy (); | 207 Simulator::Destroy (); |
(...skipping 23 matching lines...) Expand all Loading... | |
210 34, "Should have received 34 bytes from 2 disjoint packets"); | 231 34, "Should have received 34 bytes from 2 disjoint packets"); |
211 | 232 |
212 // Collision (Lose both packets) | 233 // Collision (Lose both packets) |
213 NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL (DoOnePhyTest (Seconds (1.0), Seconds (1.5) , 50, 50, prop), | 234 NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL (DoOnePhyTest (Seconds (1.0), Seconds (1.5) , 50, 50, prop), |
214 0, "Expected collision resulting in loss o f both packets"); | 235 0, "Expected collision resulting in loss o f both packets"); |
215 | 236 |
216 return false; | 237 return false; |
217 } | 238 } |
218 | 239 |
219 void | 240 void |
241 WossTest::PktRxOkThorpCallback (std::string trace_str, Ptr< const Packet > pkt, double sinr, UanTxMode mode) | |
242 { | |
243 std::cout << "PktRxOkThorpCallback: SINR = " << sinr << std::endl; | |
244 m_thorpSinr.push_back(sinr); | |
245 } | |
246 | |
247 void | |
248 WossTest::PktRxOkWossCallback (std::string trace_str, Ptr< const Packet > pkt, d ouble sinr, UanTxMode mode) | |
249 { | |
250 std::cout << "PktRxOkWossCallback: SINR = " << sinr << std::endl; | |
251 m_wossSinr.push_back(sinr); | |
252 } | |
253 | |
254 void | |
255 WossTest::DoWossThorpTests (Ptr<WossPropModel> prop, double ranges[], double win dNoise, double shipNoise) | |
256 { | |
257 // Phy Gen / Default PER / Default SINR | |
258 UanModesList mList; | |
259 | |
260 uint32_t phy_bitrate = 160; | |
261 //type, dataRateBps, phyRateSps, cfHz, bwHz, constellati onSize, name | |
262 UanTxMode mode = UanTxModeFactory::CreateMode (UanTxMode::PSK, //PSK, QA M, FSK, OTHER | |
263 phy_bitrate, phy_bitrate/2, 11520, 160, 2, "Default mode"); | |
264 | |
265 mList.AppendMode (UanTxMode (mode)); | |
266 Ptr<UanPhyPerGenDefault> perDef = CreateObject<UanPhyPerGenDefault> (); | |
267 Ptr<UanPhyCalcSinrDefault> sinrDef = CreateObject<UanPhyCalcSinrDefault> (); | |
268 m_phyFac.SetTypeId ("ns3::UanPhyGen"); | |
269 m_phyFac.Set ("PerModel", PointerValue (perDef)); | |
270 m_phyFac.Set ("SinrModel", PointerValue (sinrDef)); | |
271 m_phyFac.Set ("SupportedModes", UanModesListValue (mList)); | |
272 | |
273 double depth = 2500; //depth of all nodes (m) | |
274 m_sinkCoord = woss::CoordZ(38.1, -130.7, depth); | |
275 | |
276 //WOSS channel | |
277 m_wossHelper->SetCustomBathymetry ("2|0.0|5000.0|10000.0|5000.0", m_sink Coord); | |
278 m_wossHelper->SetCustomSediment ("TestSediment|1560.0|210.0|1.5|0.9|0.8| 5000.0"); | |
279 m_wossHelper->SetCustomSsp ("2|0|1510|5000|1510"); | |
280 | |
281 Ptr<WossChannel> wossChannel = CreateObject<WossChannel> (); | |
282 wossChannel->SetAttribute ("PropagationModel", PointerValue (prop)); | |
283 wossChannel->SetAttribute ("ChannelEqSnrThresholdDb", DoubleValue (-100. 0)); | |
284 | |
285 | |
286 //Thorp channel | |
287 double spread_coef = 2.0; | |
288 Ptr<UanPropModelThorp> propThorp = CreateObjectWithAttributes<UanPropMod elThorp> ("SpreadCoef", DoubleValue (spread_coef)); //create the propagation mod el for the channel | |
289 Ptr<UanChannel> thorpChannel = CreateObjectWithAttributes<UanChannel> (" PropagationModel", PointerValue (propThorp)); //plug prop model (and default noi se model) into channel | |
290 | |
291 Ptr<UanNoiseModel> noise_model = CreateObjectWithAttributes<UanNoiseMode lDefault> ("Wind", DoubleValue (windNoise), "Shipping", DoubleValue(shipNoise)); | |
292 thorpChannel->SetNoiseModel(PointerValue(noise_model)); | |
293 wossChannel->SetNoiseModel(PointerValue(noise_model)); | |
294 | |
295 //Create the Thorp nodes | |
296 Ptr<UanNetDevice> devt0 = CreateNode (Vector(0, 0, depth), thorpChannel) ; | |
297 Ptr<UanNetDevice> devt1 = CreateNode (Vector(ranges[0], 0, depth), thorp Channel); | |
298 Ptr<UanNetDevice> devt2 = CreateNode (Vector(ranges[1], 0, depth), thorp Channel); | |
299 Ptr<UanNetDevice> devt3 = CreateNode (Vector(ranges[2], 0, depth), thorp Channel); | |
300 | |
301 //Create the WOSS nodes | |
302 Ptr<UanNetDevice> devw0 = CreateNode (CreateVectorFromCoordZ (m_sinkCoor d), wossChannel); | |
303 Ptr<UanNetDevice> devw1 = CreateNode (CreateVectorFromCoordZ (woss::Coor dZ (woss::Coord::getCoordFromBearing (m_sinkCoord, M_PI / 2.0, ranges[0]), depth )), wossChannel); | |
304 Ptr<UanNetDevice> devw2 = CreateNode (CreateVectorFromCoordZ (woss::Coor dZ (woss::Coord::getCoordFromBearing (m_sinkCoord, M_PI / 2.0, ranges[1]), depth )), wossChannel); | |
305 Ptr<UanNetDevice> devw3 = CreateNode (CreateVectorFromCoordZ (woss::Coor dZ (woss::Coord::getCoordFromBearing (m_sinkCoord, M_PI / 2.0, ranges[2]), depth )), wossChannel); | |
306 | |
307 Simulator::Schedule (Seconds (1.0), &WossTest::SendOnePacket, this, devt 0, 0); | |
308 Simulator::Schedule (Seconds (10.0), &WossTest::SendOnePacket, this, dev w0, 0); | |
309 | |
310 //Connect RxOk callbacks | |
311 Config::Connect ( | |
312 "/NodeList/1/DeviceList/0/$ns3::UanNetDevice/Phy/$ns3::UanPhyGen /RxOk", | |
313 MakeCallback (&WossTest::PktRxOkThorpCallback, this)); | |
314 Config::Connect ( | |
315 "/NodeList/2/DeviceList/0/$ns3::UanNetDevice/Phy/$ns3::U anPhyGen/RxOk", | |
316 MakeCallback (&WossTest::PktRxOkThorpCallback, this)); | |
317 Config::Connect ( | |
318 "/NodeList/3/DeviceList/0/$ns3::UanNetDevice/Phy/$ns3::U anPhyGen/RxOk", | |
319 MakeCallback (&WossTest::PktRxOkThorpCallback, this)); | |
320 | |
321 Config::Connect ( | |
322 "/NodeList/5/DeviceList/0/$ns3::UanNetDevice/Phy/$ns3::U anPhyGen/RxOk", | |
323 MakeCallback (&WossTest::PktRxOkWossCallback, this)); | |
324 Config::Connect ( | |
325 "/NodeList/6/DeviceList/0/$ns3::UanNetDevice/Phy /$ns3::UanPhyGen/RxOk", | |
326 MakeCallback (&WossTest::PktRxOkWossCallback, th is)); | |
327 Config::Connect ( | |
328 "/NodeList/7/DeviceList/0/$ns3::UanNetDevice/Phy /$ns3::UanPhyGen/RxOk", | |
329 MakeCallback (&WossTest::PktRxOkWossCallback, th is)); | |
330 | |
331 Simulator::Stop (Seconds (20.0)); | |
332 Simulator::Run (); | |
333 Simulator::Destroy (); | |
334 | |
335 //Verify that the transmitted packets are received at all the nodes for both channels | |
336 NS_TEST_ASSERT_MSG_EQ(m_thorpSinr.size(), 3, "Not all packets received a t Thorp nodes"); | |
337 NS_TEST_ASSERT_MSG_EQ(m_wossSinr.size(), 3, "Not all packets received at Woss nodes"); | |
338 | |
339 //Verify that the SINR matches between Thorp and WOSS for all ranges | |
340 std::ostringstream oss; | |
341 for(unsigned int i=0;i<m_thorpSinr.size();i++) | |
342 { | |
343 std::cout << "Thorp SINR = " << m_thorpSinr[i] << "; WOSS SINR = " << m_wossSinr[i] << std::endl; | |
344 oss << "WOSS SINR does not match Thorp within tolerance: case " << i; | |
345 NS_TEST_ASSERT_MSG_EQ_TOL (m_thorpSinr[i], m_wossSinr[i], 1.0, o ss.str()); | |
346 } | |
347 | |
348 m_thorpSinr.clear(); | |
349 m_wossSinr.clear(); | |
350 } | |
351 | |
352 | |
353 void | |
220 WossTest::DoRun (void) | 354 WossTest::DoRun (void) |
221 { | 355 { |
222 UanTxMode mode = UanTxModeFactory::CreateMode (UanTxMode::PSK, 200, 200, 22000 , 4000, 4, "Test Mode"); | 356 UanTxMode mode = UanTxModeFactory::CreateMode (UanTxMode::PSK, 200, 200, 22000 , 4000, 4, "Test Mode"); |
223 | 357 |
224 Ptr<ConstantPositionMobilityModel> mobility = CreateObject<ConstantPositionMob ilityModel> (); | 358 Ptr<ConstantPositionMobilityModel> mobility = CreateObject<ConstantPositionMob ilityModel> (); |
225 Ptr<ConstantPositionMobilityModel> mobility2 = CreateObject<ConstantPositionMo bilityModel> (); | 359 Ptr<ConstantPositionMobilityModel> mobility2 = CreateObject<ConstantPositionMo bilityModel> (); |
226 | 360 |
227 Ptr<WossPropModel> wossProp = CreateObjectWithAttributes<WossPropModel> (); | 361 Ptr<WossPropModel> wossProp = CreateObjectWithAttributes<WossPropModel> (); |
228 m_wossHelper = CreateObjectWithAttributes<WossHelper> (); | 362 m_wossHelper = CreateObjectWithAttributes<WossHelper> (); |
229 | 363 |
230 InitWossHelper (wossProp); | 364 InitWossHelper (wossProp); |
231 | 365 |
232 // CoordZ to Vector conversion check | 366 // CoordZ to Vector conversion check |
233 woss::CoordZ txCoordz = woss::CoordZ (woss::Coord::getCoordFromBearing (m_sink Coord, M_PI/2.0, 1000.0), 70.0); | 367 woss::CoordZ txCoordz = woss::CoordZ (woss::Coord::getCoordFromBearing (m_sink Coord, M_PI / 2.0, 1000.0), 70.0); |
234 | 368 |
235 Vector txVector = CreateVectorFromCoordZ (CreateCoordZFromVector (CreateVector FromCoordZ (txCoordz))); | 369 Vector txVector = CreateVectorFromCoordZ (CreateCoordZFromVector (CreateVector FromCoordZ (txCoordz))); |
236 | 370 |
237 mobility->SetPosition (CreateVectorFromCoordZ (txCoordz)); | 371 mobility->SetPosition (CreateVectorFromCoordZ (txCoordz)); |
238 mobility2->SetPosition (txVector); | 372 mobility2->SetPosition (txVector); |
239 | 373 |
240 double dist = mobility->GetDistanceFrom (mobility2); | 374 double dist = mobility->GetDistanceFrom (mobility2); |
241 | 375 |
242 NS_TEST_ASSERT_MSG_EQ_TOL (dist, 0.0, 0.001, "Vector conversion outside of tol erance"); | 376 NS_TEST_ASSERT_MSG_EQ_TOL (dist, 0.0, 0.001, "Vector conversion outside of tol erance"); |
243 | 377 |
244 // propagation delay of forward == reverse channel check | 378 // propagation delay of forward == reverse channel check |
245 Time delay = wossProp->GetDelay (m_sinkCoord, txCoordz, mode, -100.0); | 379 Time delay = wossProp->GetDelay (m_sinkCoord, txCoordz, mode, -100.0); |
246 Time delay2 = wossProp->GetDelay (txCoordz, m_sinkCoord, mode, -100.0); | 380 Time delay2 = wossProp->GetDelay (txCoordz, m_sinkCoord, mode, -100.0); |
247 | 381 |
248 NS_TEST_ASSERT_MSG_EQ_TOL (delay.GetSeconds (), delay2.GetSeconds (), 0.001, " Got two delays outside of tolerance"); | 382 NS_TEST_ASSERT_MSG_EQ_TOL (delay.GetSeconds (), delay2.GetSeconds (), 0.001, " Got two delays outside of tolerance"); |
249 | 383 |
250 // channel total attenuation db of forward == reverse channel check | 384 // channel total attenuation db of forward == reverse channel check |
251 mobility->SetPosition (CreateVectorFromCoordZ (m_sinkCoord)); | 385 mobility->SetPosition (CreateVectorFromCoordZ (m_sinkCoord)); |
252 mobility2->SetPosition (CreateVectorFromCoordZ (txCoordz)); | 386 mobility2->SetPosition (CreateVectorFromCoordZ (txCoordz)); |
253 | 387 |
254 UanPdp pdp = wossProp->GetPdp (mobility, mobility2, mode); | 388 UanPdp pdp = wossProp->GetPdp (mobility, mobility2, mode); |
255 UanPdp pdp2 = wossProp->GetPdp (mobility2, mobility, mode); | 389 UanPdp pdp2 = wossProp->GetPdp (mobility2, mobility, mode); |
256 | 390 |
257 double channelAttDb = 0.0; | 391 double channelAttDb = 0.0; |
258 double channelAttDb2 = 0.0; | 392 double channelAttDb2 = 0.0; |
259 | 393 |
260 for (UanPdp::Iterator it = pdp.GetBegin (); it != pdp.GetEnd (); ++it) | 394 for (UanPdp::Iterator it = pdp.GetBegin (); it != pdp.GetEnd (); ++it) |
261 { · | 395 { |
262 channelAttDb += ::std::pow (::std::abs (it->GetAmp ()), 2.0); | 396 channelAttDb += ::std::pow (::std::abs (it->GetAmp ()), 2.0); |
263 }·· | 397 } |
264 | 398 |
265 for (UanPdp::Iterator it2 = pdp2.GetBegin (); it2 != pdp2.GetEnd (); ++it2) | 399 for (UanPdp::Iterator it2 = pdp2.GetBegin (); it2 != pdp2.GetEnd (); ++it2) |
266 { · | 400 { |
267 channelAttDb2 += ::std::pow (::std::abs (it2->GetAmp ()), 2.0); | 401 channelAttDb2 += ::std::pow (::std::abs (it2->GetAmp ()), 2.0); |
268 }·· | 402 } |
269 ::std::cout << "channelAttDb = " << channelAttDb << "; channelAttDb2 = " << ch annelAttDb2 << ::std::endl; | 403 ::std::cout << "channelAttDb = " << channelAttDb << "; channelAttDb2 = " << ch annelAttDb2 << ::std::endl; |
270 | 404 |
271 channelAttDb = ::std::sqrt (channelAttDb); | 405 channelAttDb = ::std::sqrt (channelAttDb); |
272 channelAttDb = -10.0*::std::log10 (channelAttDb); | 406 channelAttDb = -10.0 * ::std::log10 (channelAttDb); |
273 | 407 |
274 channelAttDb2 = ::std::sqrt (channelAttDb2); | 408 channelAttDb2 = ::std::sqrt (channelAttDb2); |
275 channelAttDb2 = -10.0*::std::log10 (channelAttDb2); | 409 channelAttDb2 = -10.0 * ::std::log10 (channelAttDb2); |
276 | 410 |
277 ::std::cout << "channelAttDb = " << channelAttDb << "; channelAttDb2 = " << ch annelAttDb2 << ::std::endl; | 411 ::std::cout << "channelAttDb = " << channelAttDb << "; channelAttDb2 = " << ch annelAttDb2 << ::std::endl; |
278 | 412 |
279 NS_TEST_ASSERT_MSG_EQ_TOL (channelAttDb, channelAttDb2, 0.01, "Got two attenua tion dbs outside of tolerance"); | 413 NS_TEST_ASSERT_MSG_EQ_TOL (channelAttDb, channelAttDb2, 0.01, "Got two attenua tion dbs outside of tolerance"); |
280 | 414 |
281 // phy tests | 415 // phy tests |
282 DoPhyTests (wossProp); | 416 DoPhyTests (wossProp); |
417 | |
418 // Propagation Tests: verify WOSS attenuation matches Thorp for deep water col umn case | |
419 double ranges[3] = {500, 1000, 2500}; //create nodes at these ranges to receiv e packets (m) | |
420 DoWossThorpTests (wossProp, ranges, 0, 0); | |
421 DoWossThorpTests (wossProp, ranges, 3, 0.5); | |
283 } | 422 } |
284 | 423 |
285 | 424 |
286 class WossTestSuite : public TestSuite | 425 class WossTestSuite : public TestSuite |
287 { | 426 { |
288 public: | 427 public: |
289 WossTestSuite (); | 428 WossTestSuite (); |
290 }; | 429 }; |
291 | 430 |
292 WossTestSuite::WossTestSuite () | 431 WossTestSuite::WossTestSuite () |
293 : TestSuite ("devices-woss", UNIT) | 432 : TestSuite ("devices-woss", UNIT) |
294 { | 433 { |
295 AddTestCase (new WossTest, TestCase::QUICK); | 434 AddTestCase (new WossTest, TestCase::QUICK); |
296 } | 435 } |
297 | 436 |
298 static WossTestSuite g_uanWossTestSuite; | 437 static WossTestSuite g_uanWossTestSuite; |
299 | 438 |
300 #endif // NS3_WOSS_SUPPORT | 439 #endif // NS3_WOSS_SUPPORT |
301 | 440 |
302 | 441 |
LEFT | RIGHT |