Left: | ||
Right: |
OLD | NEW |
---|---|
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2013 University of Washington | 3 * Copyright (c) 2013 University of Washington |
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: Mitch Watrous (watrous@u.washington.edu) | 18 * Author: Mitch Watrous (watrous@u.washington.edu) |
19 */ | 19 */ |
20 | 20 |
21 #include <iostream> | 21 #include <iostream> |
22 #include <fstream> | 22 #include <fstream> |
23 #include <string> | 23 #include <string> |
24 | 24 |
25 #include "file-helper.h" | 25 #include "file-helper.h" |
26 #include "ns3/abort.h" | 26 #include "ns3/abort.h" |
27 #include "ns3/log.h" | 27 #include "ns3/log.h" |
28 #include "ns3/config.h" | 28 #include "ns3/config.h" |
29 #include "ns3/collector.h" | |
29 #include "ns3/get-wildcard-matches.h" | 30 #include "ns3/get-wildcard-matches.h" |
30 | 31 |
31 namespace ns3 { | 32 namespace ns3 { |
32 | 33 |
33 NS_LOG_COMPONENT_DEFINE ("FileHelper"); | 34 NS_LOG_COMPONENT_DEFINE ("FileHelper"); |
34 | 35 |
35 FileHelper::FileHelper () | 36 FileHelper::FileHelper () |
36 : m_aggregator (0), | 37 : m_aggregator (0), |
37 m_fileProbeCount (0), | 38 m_fileProbeCount (0), |
38 m_fileType (FileAggregator::SPACE_SEPARATED), | 39 m_fileType (FileAggregator::SPACE_SEPARATED), |
39 m_outputFileNameWithoutExtension ("file-helper"), | 40 m_outputFileNameWithoutExtension ("file-helper"), |
40 m_hasHeadingBeenSet (false) | 41 m_hasHeadingBeenSet (false) |
41 { | 42 { |
42 NS_LOG_FUNCTION (this); | 43 NS_LOG_FUNCTION (this); |
44 m_collectorFactory.SetTypeId ("ns3::EventDrivenCollector"); | |
43 | 45 |
44 // Note that this does not construct an aggregator. It will be | 46 // Note that this does not construct an aggregator. It will be |
45 // constructed later when needed. | 47 // constructed later when needed. |
46 } | 48 } |
47 | 49 |
48 FileHelper::FileHelper (const std::string &outputFileNameWithoutExtension, | 50 FileHelper::FileHelper (const std::string &outputFileNameWithoutExtension, |
49 enum FileAggregator::FileType fileType) | 51 enum FileAggregator::FileType fileType) |
50 : m_aggregator (0), | 52 : m_aggregator (0), |
51 m_fileProbeCount (0), | 53 m_fileProbeCount (0), |
52 m_fileType (fileType), | 54 m_fileType (fileType), |
53 m_outputFileNameWithoutExtension (outputFileNameWithoutExtension), | 55 m_outputFileNameWithoutExtension (outputFileNameWithoutExtension), |
54 m_hasHeadingBeenSet (false) | 56 m_hasHeadingBeenSet (false) |
55 { | 57 { |
56 NS_LOG_FUNCTION (this); | 58 NS_LOG_FUNCTION (this); |
59 m_collectorFactory.SetTypeId ("ns3::EventDrivenCollector"); | |
57 | 60 |
58 // Note that this does not construct an aggregator. It will be | 61 // Note that this does not construct an aggregator. It will be |
59 // constructed later when needed. | 62 // constructed later when needed. |
60 } | 63 } |
61 | 64 |
62 FileHelper::~FileHelper () | 65 FileHelper::~FileHelper () |
63 { | 66 { |
64 NS_LOG_FUNCTION (this); | 67 NS_LOG_FUNCTION (this); |
65 } | 68 } |
66 | 69 |
(...skipping 13 matching lines...) Expand all Loading... | |
80 // Store these so that they can be used to construct the aggregator. | 83 // Store these so that they can be used to construct the aggregator. |
81 m_fileType = fileType; | 84 m_fileType = fileType; |
82 m_outputFileNameWithoutExtension = outputFileNameWithoutExtension; | 85 m_outputFileNameWithoutExtension = outputFileNameWithoutExtension; |
83 m_hasHeadingBeenSet = false; | 86 m_hasHeadingBeenSet = false; |
84 | 87 |
85 // Note that this does not construct an aggregator. It will be | 88 // Note that this does not construct an aggregator. It will be |
86 // constructed later when needed. | 89 // constructed later when needed. |
87 } | 90 } |
88 | 91 |
89 void | 92 void |
93 FileHelper::SetCollectorType (std::string collectorType, | |
94 std::string n0, const AttributeValue &v0, | |
95 std::string n1, const AttributeValue &v1, | |
96 std::string n2, const AttributeValue &v2, | |
97 std::string n3, const AttributeValue &v3, | |
98 std::string n4, const AttributeValue &v4, | |
99 std::string n5, const AttributeValue &v5, | |
100 std::string n6, const AttributeValue &v6, | |
101 std::string n7, const AttributeValue &v7) | |
102 { | |
103 ObjectFactory factory; | |
104 factory.SetTypeId (collectorType); | |
105 factory.Set (n0, v0); | |
106 factory.Set (n1, v1); | |
107 factory.Set (n2, v2); | |
108 factory.Set (n3, v3); | |
109 factory.Set (n4, v4); | |
110 factory.Set (n5, v5); | |
111 factory.Set (n6, v6); | |
112 factory.Set (n7, v7); | |
113 m_collectorFactory = factory; | |
114 } | |
115 | |
116 void | |
90 FileHelper::WriteProbe (const std::string &typeId, | 117 FileHelper::WriteProbe (const std::string &typeId, |
91 const std::string &path, | 118 const std::string &path, |
92 const std::string &probeTraceSource) | 119 const std::string &probeTraceSource) |
93 { | 120 { |
94 NS_LOG_FUNCTION (this << typeId << path << probeTraceSource); | 121 NS_LOG_FUNCTION (this << typeId << path << probeTraceSource); |
122 AddProbe (typeId, path, probeTraceSource); | |
123 } | |
124 | |
125 void | |
126 FileHelper::AddProbe (const std::string &typeId, | |
127 const std::string &path, | |
128 const std::string &probeTraceSource) | |
129 { | |
130 NS_LOG_FUNCTION (this << typeId << path << probeTraceSource); | |
95 | 131 |
96 std::string pathWithoutLastToken; | 132 std::string pathWithoutLastToken; |
97 std::string lastToken; | 133 std::string lastToken; |
98 | 134 |
99 // See if the path has any wildcards. | 135 // See if the path has any wildcards. |
100 bool pathHasNoWildcards = path.find ("*") == std::string::npos; | 136 bool pathHasNoWildcards = path.find ("*") == std::string::npos; |
101 | 137 |
102 // Remove the last token from the path. | 138 // Remove the last token from the path. |
103 size_t lastSlash = path.find_last_of ("/"); | 139 size_t lastSlash = path.find_last_of ("/"); |
104 if (lastSlash == std::string::npos) | 140 if (lastSlash == std::string::npos) |
(...skipping 22 matching lines...) Expand all Loading... | |
127 bool onlyOneAggregator; | 163 bool onlyOneAggregator; |
128 | 164 |
129 // Hook one or more probes and one or more aggregators together. | 165 // Hook one or more probes and one or more aggregators together. |
130 if (matchCount == 1 && pathHasNoWildcards) | 166 if (matchCount == 1 && pathHasNoWildcards) |
131 { | 167 { |
132 // Connect the probe to the aggregator only once because there | 168 // Connect the probe to the aggregator only once because there |
133 // is only one matching config path. There is no need to find | 169 // is only one matching config path. There is no need to find |
134 // the wildcard matches because the passed in path has none. | 170 // the wildcard matches because the passed in path has none. |
135 matchIdentifier = "0"; | 171 matchIdentifier = "0"; |
136 onlyOneAggregator = true; | 172 onlyOneAggregator = true; |
137 ConnectProbeToAggregator (typeId, | 173 CreateDataCollectionChain (typeId, |
138 matchIdentifier, | 174 matchIdentifier, |
139 path, | 175 path, |
140 probeTraceSource, | 176 probeTraceSource, |
141 m_outputFileNameWithoutExtension, | 177 m_outputFileNameWithoutExtension, |
142 onlyOneAggregator); | 178 onlyOneAggregator); |
143 } | 179 } |
144 else if (matchCount > 0) | 180 else if (matchCount > 0) |
145 { | 181 { |
146 // Handle all of the matches if there are more than one. | 182 // Handle all of the matches if there are more than one. |
147 for (uint32_t i = 0; i < matchCount; i++) | 183 for (uint32_t i = 0; i < matchCount; i++) |
148 { | 184 { |
149 // Set the match identifier. | 185 // Set the match identifier. |
150 std::ostringstream matchIdentifierStream; | 186 std::ostringstream matchIdentifierStream; |
151 matchIdentifierStream << i; | 187 matchIdentifierStream << i; |
152 matchIdentifier = matchIdentifierStream.str (); | 188 matchIdentifier = matchIdentifierStream.str (); |
153 onlyOneAggregator = false; | 189 onlyOneAggregator = false; |
154 | 190 |
155 // Construct the matched path and get the matches for each | 191 // Construct the matched path and get the matches for each |
156 // of the wildcards. | 192 // of the wildcards. |
157 std::string wildcardSeparator = "-"; | 193 std::string wildcardSeparator = "-"; |
158 std::string matchedPath = matches.GetMatchedPath (i) + lastToken; | 194 std::string matchedPath = matches.GetMatchedPath (i) + lastToken; |
159 std::string wildcardMatches = GetWildcardMatches (path, | 195 std::string wildcardMatches = GetWildcardMatches (path, |
160 matchedPath, | 196 matchedPath, |
161 wildcardSeparator); | 197 wildcardSeparator); |
162 | 198 |
163 // Connect the probe to the aggregator for this match. | 199 // Connect the probe to the aggregator for this match. |
164 ConnectProbeToAggregator (typeId, | 200 CreateDataCollectionChain (typeId, |
165 matchIdentifier, | 201 matchIdentifier, |
166 matchedPath, | 202 matchedPath, |
167 probeTraceSource, | 203 probeTraceSource, |
168 m_outputFileNameWithoutExtension + "-" + wil dcardMatches, | 204 m_outputFileNameWithoutExtension + "-" + wil dcardMatches, |
169 onlyOneAggregator); | 205 onlyOneAggregator); |
170 } | 206 } |
171 } | 207 } |
172 else | 208 else |
173 { | 209 { |
174 // There is a problem if there are no matching config paths. | 210 // There is a problem if there are no matching config paths. |
175 NS_FATAL_ERROR ("Lookup of " << path << " got no matches"); | 211 NS_FATAL_ERROR ("Lookup of " << path << " got no matches"); |
176 } | 212 } |
177 } | 213 } |
178 | 214 |
179 void | 215 void |
180 FileHelper::AddProbe (const std::string &typeId, | 216 FileHelper::AddProbeToMap (const std::string &typeId, |
181 const std::string &probeName, | 217 const std::string &probeName, |
182 const std::string &path) | 218 const std::string &path) |
183 { | 219 { |
184 NS_LOG_FUNCTION (this << typeId << probeName << path); | 220 NS_LOG_FUNCTION (this << typeId << probeName << path); |
185 | 221 |
186 // See if this probe had already been added. | 222 // See if this probe had already been added. |
187 if (m_probeMap.count (probeName) > 0) | 223 if (m_probeMap.count (probeName) > 0) |
188 { | 224 { |
189 NS_ABORT_MSG ("That probe has already been added"); | 225 NS_ABORT_MSG ("That probe has already been added"); |
190 } | 226 } |
(...skipping 15 matching lines...) Expand all Loading... | |
206 probe->ConnectByPath (path); | 242 probe->ConnectByPath (path); |
207 | 243 |
208 // Enable logging of data for the probe. | 244 // Enable logging of data for the probe. |
209 probe->Enable (); | 245 probe->Enable (); |
210 | 246 |
211 // Add this probe to the map so that its values can be used. | 247 // Add this probe to the map so that its values can be used. |
212 m_probeMap[probeName] = std::make_pair (probe, typeId); | 248 m_probeMap[probeName] = std::make_pair (probe, typeId); |
213 } | 249 } |
214 | 250 |
215 void | 251 void |
216 FileHelper::AddTimeSeriesAdaptor (const std::string &adaptorName) | 252 FileHelper::AddCollector (const std::string &collectorName) |
217 { | 253 { |
218 NS_LOG_FUNCTION (this << adaptorName); | 254 NS_LOG_FUNCTION (this << collectorName); |
219 | 255 |
220 // See if this time series adaptor had already been added. | 256 Ptr<Collector> collector = DynamicCast<Collector> (m_collectorFactory.Create ( )); |
221 if (m_timeSeriesAdaptorMap.count (adaptorName) > 0) | 257 collector->Enable (); |
258 // See if this collector had already been added. | |
259 | |
260 if (m_collectorMap.count (collectorName) > 0) | |
222 { | 261 { |
223 NS_ABORT_MSG ("That time series adaptor has already been added"); | 262 NS_ABORT_MSG ("That Collector has already been added"); |
224 } | 263 } |
225 | 264 |
226 // Create the time series adaptor. | |
227 Ptr<TimeSeriesAdaptor> timeSeriesAdaptor = CreateObject<TimeSeriesAdaptor> (); | |
228 | |
229 // Enable logging of data for the time series adaptor. | |
230 timeSeriesAdaptor->Enable (); | |
231 | |
232 // Add this time series adaptor to the map so that it can be used. | 265 // Add this time series adaptor to the map so that it can be used. |
buherman
2015/06/29 08:53:53
time series adaptor -> collector
| |
233 m_timeSeriesAdaptorMap[adaptorName] = timeSeriesAdaptor; | 266 m_collectorMap[collectorName] = collector; |
234 } | 267 } |
235 | 268 |
236 void | 269 void |
237 FileHelper::AddAggregator (const std::string &aggregatorName, | 270 FileHelper::AddAggregator (const std::string &aggregatorName, |
238 const std::string &outputFileName, | 271 const std::string &outputFileName, |
239 bool onlyOneAggregator) | 272 bool onlyOneAggregator) |
240 { | 273 { |
241 NS_LOG_FUNCTION (this << aggregatorName << outputFileName << onlyOneAggregator ); | 274 NS_LOG_FUNCTION (this << aggregatorName << outputFileName << onlyOneAggregator ); |
242 | 275 |
243 // See if this file aggregator had already been added. | 276 // See if this file aggregator had already been added. |
244 if (m_aggregatorMap.count (aggregatorName) > 0) | 277 if (m_aggregatorMap.count (aggregatorName) > 0) |
245 { | 278 { |
246 NS_ABORT_MSG ("That file aggregator has already been added"); | 279 NS_ABORT_MSG ("That file aggregator has already been added"); |
247 } | 280 } |
248 | 281 |
249 // If there is only going to be 1 file aggregator, then use the one | 282 // If there is only going to be 1 file aggregator, then use the one |
250 // already constructed in the map. | 283 // already constructed in the map. |
251 if (onlyOneAggregator) | 284 if (onlyOneAggregator) |
252 { | 285 { |
253 // Get a pointer to the aggregator. | 286 // Get a pointer to the aggregator. |
254 Ptr<FileAggregator> singleAggregator = GetAggregatorSingle (); | 287 Ptr<FileAggregator> singleAggregator = GetAggregator (); |
255 | 288 |
256 m_aggregatorMap[aggregatorName] = singleAggregator; | 289 m_aggregatorMap[aggregatorName] = singleAggregator; |
257 return; | 290 return; |
258 } | 291 } |
259 | 292 |
260 // Create the file aggregator with the proper file type. | 293 // Create the file aggregator with the proper file type. |
261 Ptr<FileAggregator> multipleAggregator = | 294 Ptr<FileAggregator> multipleAggregator = |
262 CreateObject<FileAggregator> (outputFileName, m_fileType); | 295 CreateObject<FileAggregator> (outputFileName, m_fileType); |
263 | 296 |
264 // Set all of the format strings for the aggregator. | 297 // Set all of the format strings for the aggregator. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
298 } | 331 } |
299 else | 332 else |
300 { | 333 { |
301 NS_ABORT_MSG ("That probe has not been added"); | 334 NS_ABORT_MSG ("That probe has not been added"); |
302 } | 335 } |
303 } | 336 } |
304 | 337 |
305 Ptr<FileAggregator> | 338 Ptr<FileAggregator> |
306 FileHelper::GetAggregatorSingle () | 339 FileHelper::GetAggregatorSingle () |
307 { | 340 { |
341 return GetAggregator (); | |
342 } | |
343 | |
344 Ptr<FileAggregator> | |
345 FileHelper::GetAggregator () | |
346 { | |
308 NS_LOG_FUNCTION (this); | 347 NS_LOG_FUNCTION (this); |
309 | 348 |
310 // Do a lazy construction of the single aggregator if it hasn't | 349 // Do a lazy construction of the single aggregator if it hasn't |
311 // already been constructed. | 350 // already been constructed. |
312 if (!m_aggregator) | 351 if (!m_aggregator) |
313 { | 352 { |
314 // Create the aggregator. | 353 // Create the aggregator. |
315 std::string outputFileName = m_outputFileNameWithoutExtension + ".txt"; | 354 std::string outputFileName = m_outputFileNameWithoutExtension + ".txt"; |
316 m_aggregator = CreateObject<FileAggregator> (outputFileName, m_fileType); | 355 m_aggregator = CreateObject<FileAggregator> (outputFileName, m_fileType); |
317 | 356 |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
441 | 480 |
442 void | 481 void |
443 FileHelper::Set10dFormat (const std::string &format) | 482 FileHelper::Set10dFormat (const std::string &format) |
444 { | 483 { |
445 NS_LOG_FUNCTION (this << format); | 484 NS_LOG_FUNCTION (this << format); |
446 | 485 |
447 m_10dFormat = format; | 486 m_10dFormat = format; |
448 } | 487 } |
449 | 488 |
450 void | 489 void |
451 FileHelper::ConnectProbeToAggregator (const std::string &typeId, | 490 FileHelper::CreateDataCollectionChain (const std::string &typeId, |
452 const std::string &matchIdentifier, | 491 const std::string &matchIdentifier, |
453 const std::string &path, | 492 const std::string &path, |
454 const std::string &probeTraceSource, | 493 const std::string &probeTraceSource, |
455 const std::string &outputFileNameWithoutEx tension, | 494 const std::string &outputFileNameWithoutEx tension, |
456 bool onlyOneAggregator) | 495 bool onlyOneAggregator) |
457 { | 496 { |
458 NS_LOG_FUNCTION (this << typeId << matchIdentifier << path << probeTraceSource | 497 NS_LOG_FUNCTION (this << typeId << matchIdentifier << path << probeTraceSource |
459 << outputFileNameWithoutExtension << onlyOneAggregator); | 498 << outputFileNameWithoutExtension << onlyOneAggregator); |
460 | 499 |
461 // Increment the total number of file probes that have been created. | 500 // Increment the total number of file probes that have been created. |
462 m_fileProbeCount++; | 501 m_fileProbeCount++; |
463 | 502 |
464 // Create a unique name for this probe. | 503 // Create a unique name for this probe. |
465 std::ostringstream probeNameStream; | 504 std::ostringstream probeNameStream; |
466 probeNameStream << "FileProbe-" << m_fileProbeCount; | 505 probeNameStream << "FileProbe-" << m_fileProbeCount; |
467 std::string probeName = probeNameStream.str (); | 506 std::string probeName = probeNameStream.str (); |
468 | 507 |
469 // Create a unique dataset context string for this probe. | 508 // Create a unique dataset context string for this probe. |
470 std::string probeContext = probeName | 509 std::string probeContext = probeName |
471 + "/" + matchIdentifier + "/" + probeTraceSource; | 510 + "/" + matchIdentifier + "/" + probeTraceSource; |
472 | 511 |
473 // Add the probe to the map of probes, which will keep the probe in | 512 // Add the probe to the map of probes, which will keep the probe in |
474 // memory after this function ends. | 513 // memory after this function ends. |
475 AddProbe (typeId, probeName, path); | 514 AddProbeToMap (typeId, probeName, path); |
476 | 515 |
477 // Because the callbacks to the probes' trace sources don't use the | 516 // Because the callbacks to the probes' trace sources don't use the |
478 // probe's context, a unique adaptor needs to be created for each | 517 // probe's context, a unique adaptor needs to be created for each |
buherman
2015/06/29 08:53:53
adaptor -> collector
| |
479 // probe context so that information is not lost. | 518 // probe context so that information is not lost. |
480 AddTimeSeriesAdaptor (probeContext); | 519 AddCollector (probeContext); |
481 | 520 |
482 // Connect the probe to the adaptor. | 521 ConnectProbeToCollector (probeTraceSource, probeName, probeContext); |
483 if (m_probeMap[probeName].second == "ns3::DoubleProbe") | |
484 { | |
485 m_probeMap[probeName].first->TraceConnectWithoutContext | |
486 (probeTraceSource, | |
487 MakeCallback (&TimeSeriesAdaptor::TraceSinkDouble, | |
488 m_timeSeriesAdaptorMap[probeContext])); | |
489 } | |
490 else if (m_probeMap[probeName].second == "ns3::BooleanProbe") | |
491 { | |
492 m_probeMap[probeName].first->TraceConnectWithoutContext | |
493 (probeTraceSource, | |
494 MakeCallback (&TimeSeriesAdaptor::TraceSinkBoolean, | |
495 m_timeSeriesAdaptorMap[probeContext])); | |
496 } | |
497 else if (m_probeMap[probeName].second == "ns3::PacketProbe") | |
498 { | |
499 m_probeMap[probeName].first->TraceConnectWithoutContext | |
500 (probeTraceSource, | |
501 MakeCallback (&TimeSeriesAdaptor::TraceSinkUinteger32, | |
502 m_timeSeriesAdaptorMap[probeContext])); | |
503 } | |
504 else if (m_probeMap[probeName].second == "ns3::ApplicationPacketProbe") | |
505 { | |
506 m_probeMap[probeName].first->TraceConnectWithoutContext | |
507 (probeTraceSource, | |
508 MakeCallback (&TimeSeriesAdaptor::TraceSinkUinteger32, | |
509 m_timeSeriesAdaptorMap[probeContext])); | |
510 } | |
511 else if (m_probeMap[probeName].second == "ns3::Ipv4PacketProbe") | |
512 { | |
513 m_probeMap[probeName].first->TraceConnectWithoutContext | |
514 (probeTraceSource, | |
515 MakeCallback (&TimeSeriesAdaptor::TraceSinkUinteger32, | |
516 m_timeSeriesAdaptorMap[probeContext])); | |
517 } | |
518 else if (m_probeMap[probeName].second == "ns3::Ipv6PacketProbe") | |
519 { | |
520 m_probeMap[probeName].first->TraceConnectWithoutContext | |
521 (probeTraceSource, | |
522 MakeCallback (&TimeSeriesAdaptor::TraceSinkUinteger32, | |
523 m_timeSeriesAdaptorMap[probeContext])); | |
524 } | |
525 else if (m_probeMap[probeName].second == "ns3::Uinteger8Probe") | |
526 { | |
527 m_probeMap[probeName].first->TraceConnectWithoutContext | |
528 (probeTraceSource, | |
529 MakeCallback (&TimeSeriesAdaptor::TraceSinkUinteger8, | |
530 m_timeSeriesAdaptorMap[probeContext])); | |
531 } | |
532 else if (m_probeMap[probeName].second == "ns3::Uinteger16Probe") | |
533 { | |
534 m_probeMap[probeName].first->TraceConnectWithoutContext | |
535 (probeTraceSource, | |
536 MakeCallback (&TimeSeriesAdaptor::TraceSinkUinteger16, | |
537 m_timeSeriesAdaptorMap[probeContext])); | |
538 } | |
539 else if (m_probeMap[probeName].second == "ns3::Uinteger32Probe") | |
540 { | |
541 m_probeMap[probeName].first->TraceConnectWithoutContext | |
542 (probeTraceSource, | |
543 MakeCallback (&TimeSeriesAdaptor::TraceSinkUinteger32, | |
544 m_timeSeriesAdaptorMap[probeContext])); | |
545 } | |
546 else if (m_probeMap[probeName].second == "ns3::TimeProbe") | |
547 { | |
548 m_probeMap[probeName].first->TraceConnectWithoutContext | |
549 (probeTraceSource, | |
550 MakeCallback (&TimeSeriesAdaptor::TraceSinkDouble, | |
551 m_timeSeriesAdaptorMap[probeContext])); | |
552 } | |
553 else | |
554 { | |
555 NS_FATAL_ERROR ("Unknown probe type " << m_probeMap[probeName].second << " ; need to add support in the helper for this"); | |
556 } | |
557 | 522 |
558 // Add the aggregator to the map of aggregators, which will keep the | 523 // Add the aggregator to the map of aggregators, which will keep the |
559 // aggregator in memory after this function ends. | 524 // aggregator in memory after this function ends. |
560 std::string outputFileName = outputFileNameWithoutExtension + ".txt"; | 525 std::string outputFileName = outputFileNameWithoutExtension + ".txt"; |
561 AddAggregator (probeContext, outputFileName, onlyOneAggregator); | 526 AddAggregator (probeContext, outputFileName, onlyOneAggregator); |
562 | 527 |
563 // Connect the adaptor to the aggregator. | 528 ConnectCollectorToAggregator (probeContext); |
564 std::string adaptorTraceSource = "Output"; | 529 } |
565 m_timeSeriesAdaptorMap[probeContext]->TraceConnect | 530 |
566 (adaptorTraceSource, | 531 void |
532 FileHelper::ConnectCollectorToAggregator (const std::string probeContext) | |
533 { | |
534 // Connect the collector to the aggregator. | |
535 std::string collectorTraceSource = "Output"; | |
536 m_collectorMap[probeContext]->TraceConnect | |
537 (collectorTraceSource, | |
567 probeContext, | 538 probeContext, |
568 MakeCallback (&FileAggregator::Write2d, | 539 MakeCallback (&FileAggregator::Write2d, |
569 m_aggregatorMap[probeContext])); | 540 m_aggregatorMap[probeContext])); |
570 } | 541 } |
571 | 542 |
543 void | |
544 FileHelper::ConnectProbeToCollector (const std::string probeTraceSource, | |
545 const std::string probeName, | |
546 const std::string probeContext) | |
547 { | |
548 // Connect the probe to the adaptor. | |
buherman
2015/06/29 08:53:53
adaptor -> collector
| |
549 if (m_probeMap[probeName].second == "ns3::DoubleProbe") | |
550 { | |
551 m_probeMap[probeName].first->TraceConnectWithoutContext | |
552 (probeTraceSource, | |
553 MakeCallback (&Collector::TraceSinkDouble, | |
554 m_collectorMap[probeContext])); | |
555 } | |
556 else if (m_probeMap[probeName].second == "ns3::BooleanProbe") | |
557 { | |
558 m_probeMap[probeName].first->TraceConnectWithoutContext | |
559 (probeTraceSource, | |
560 MakeCallback (&Collector::TraceSinkBoolean, | |
561 m_collectorMap[probeContext])); | |
562 } | |
563 else if (m_probeMap[probeName].second == "ns3::PacketProbe") | |
564 { | |
565 m_probeMap[probeName].first->TraceConnectWithoutContext | |
566 (probeTraceSource, | |
567 MakeCallback (&Collector::TraceSinkUinteger32, | |
568 m_collectorMap[probeContext])); | |
569 } | |
570 else if (m_probeMap[probeName].second == "ns3::ApplicationPacketProbe") | |
571 { | |
572 m_probeMap[probeName].first->TraceConnectWithoutContext | |
573 (probeTraceSource, | |
574 MakeCallback (&Collector::TraceSinkUinteger32, | |
575 m_collectorMap[probeContext])); | |
576 } | |
577 else if (m_probeMap[probeName].second == "ns3::Ipv4PacketProbe") | |
578 { | |
579 m_probeMap[probeName].first->TraceConnectWithoutContext | |
580 (probeTraceSource, | |
581 MakeCallback (&Collector::TraceSinkUinteger32, | |
582 m_collectorMap[probeContext])); | |
583 } | |
584 else if (m_probeMap[probeName].second == "ns3::Ipv6PacketProbe") | |
585 { | |
586 m_probeMap[probeName].first->TraceConnectWithoutContext | |
587 (probeTraceSource, | |
588 MakeCallback (&Collector::TraceSinkUinteger32, | |
589 m_collectorMap[probeContext])); | |
590 } | |
591 else if (m_probeMap[probeName].second == "ns3::Uinteger8Probe") | |
592 { | |
593 m_probeMap[probeName].first->TraceConnectWithoutContext | |
594 (probeTraceSource, | |
595 MakeCallback (&Collector::TraceSinkUinteger8, | |
596 m_collectorMap[probeContext])); | |
597 } | |
598 else if (m_probeMap[probeName].second == "ns3::Uinteger16Probe") | |
599 { | |
600 m_probeMap[probeName].first->TraceConnectWithoutContext | |
601 (probeTraceSource, | |
602 MakeCallback (&Collector::TraceSinkUinteger16, | |
603 m_collectorMap[probeContext])); | |
604 } | |
605 else if (m_probeMap[probeName].second == "ns3::Uinteger32Probe") | |
606 { | |
607 m_probeMap[probeName].first->TraceConnectWithoutContext | |
608 (probeTraceSource, | |
609 MakeCallback (&Collector::TraceSinkUinteger32, | |
610 m_collectorMap[probeContext])); | |
611 } | |
612 else if (m_probeMap[probeName].second == "ns3::TimeProbe") | |
613 { | |
614 m_probeMap[probeName].first->TraceConnectWithoutContext | |
615 (probeTraceSource, | |
616 MakeCallback (&Collector::TraceSinkDouble, | |
buherman
2015/06/29 08:53:53
TraceSinkDouble -> TraceSinkTime
| |
617 m_collectorMap[probeContext])); | |
618 } | |
619 else | |
620 { | |
621 NS_FATAL_ERROR ("Unknown probe type " << m_probeMap[probeName].second << " ; need to add support in the helper for this"); | |
622 } | |
623 } | |
624 | |
572 } // namespace ns3 | 625 } // namespace ns3 |
573 | 626 |
OLD | NEW |