A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
animation-interface.h
Go to the documentation of this file.
1/*
2 * SPDX-License-Identifier: GPL-2.0-only
3 *
4 * Author: George F. Riley<riley@ece.gatech.edu>
5 * Author: John Abraham <john.abraham@gatech.edu>
6 * Contributions: Eugene Kalishenko <ydginster@gmail.com> (Open Source and Linux Laboratory
7 * http://wiki.osll.ru/doku.php/start)
8 */
9
10// Interface between ns3 and the network animator
11
12#ifndef ANIMATION_INTERFACE__H
13#define ANIMATION_INTERFACE__H
14
15#include "ns3/config.h"
16#include "ns3/ipv4-l3-protocol.h"
17#include "ns3/ipv4.h"
18#include "ns3/log.h"
19#include "ns3/lte-enb-net-device.h"
20#include "ns3/lte-ue-net-device.h"
21#include "ns3/mac48-address.h"
22#include "ns3/net-device.h"
23#include "ns3/node-container.h"
24#include "ns3/node-list.h"
25#include "ns3/nstime.h"
26#include "ns3/ptr.h"
27#include "ns3/random-variable-stream.h"
28#include "ns3/rectangle.h"
29#include "ns3/simulator.h"
30#include "ns3/uan-phy-gen.h"
31#include "ns3/wifi-phy.h"
32
33#include <cstdio>
34#include <map>
35#include <string>
36
37namespace ns3
38{
39
40#define MAX_PKTS_PER_TRACE_FILE 100000
41#define PURGE_INTERVAL 5
42#define NETANIM_VERSION "netanim-3.109"
43#define CHECK_STARTED_INTIMEWINDOW \
44 { \
45 if (!m_started || !IsInTimeWindow()) \
46 { \
47 return; \
48 } \
49 }
50#define CHECK_STARTED_INTIMEWINDOW_TRACKPACKETS \
51 { \
52 if (!m_started || !IsInTimeWindow() || !m_trackPackets) \
53 { \
54 return; \
55 } \
56 }
57
58struct NodeSize;
59class WifiPsdu;
60
61/**
62 * @defgroup netanim Network Animation
63 *
64 * This section documents the API of the ns-3 netanim module. For a generic functional description,
65 * please refer to the ns-3 manual.
66 */
67
68/**
69 * @ingroup netanim
70 *
71 * @brief Interface to network animator
72 *
73 * Provides functions that facilitate communications with an
74 * external or internal network animator.
75 */
77{
78 public:
79 /**
80 * @brief Constructor
81 * @param filename The Filename for the trace file used by the Animator
82 *
83 */
84 AnimationInterface(const std::string filename);
85
86 /**
87 * Counter Types
88 */
94
95 /**
96 * @brief typedef for WriteCallBack used for listening to AnimationInterface
97 * write messages
98 *
99 */
100 typedef void (*AnimWriteCallback)(const char* str);
101
102 /**
103 * @brief Destructor for the animator interface.
104 *
105 */
107
108 /**
109 * @brief Enable tracking of Ipv4 L3 Protocol Counters such as Tx, Rx, Drop
110 *
111 * @param startTime Start Time for capturing values
112 * @param stopTime Stop Time for capturing values
113 * @param pollInterval The periodic interval at which the counters are written to the trace file
114 * Default: 1s
115 */
116 void EnableIpv4L3ProtocolCounters(Time startTime,
118 Time pollInterval = Seconds(1));
119
120 /**
121 * @brief Enable tracking of Queue Counters such as Enqueue, Dequeue, Queue Drops
122 *
123 * @param startTime Start Time for capturing values
124 * @param stopTime Stop Time for capturing values
125 * @param pollInterval The periodic interval at which the counters are written to the trace file
126 * Default: 1s
127 */
128 void EnableQueueCounters(Time startTime, Time stopTime, Time pollInterval = Seconds(1));
129
130 /**
131 * @brief Enable tracking of Wifi Mac Counters such as Tx, TxDrop, Rx, RxDrop
132 *
133 * @param startTime Start Time for capturing values
134 * @param stopTime Stop Time for capturing values
135 * @param pollInterval The periodic interval at which the counters are written to the trace file
136 * Default: 1s
137 */
138 void EnableWifiMacCounters(Time startTime, Time stopTime, Time pollInterval = Seconds(1));
139
140 /**
141 * @brief Enable tracking of Wifi Phy Counters such as TxDrop, RxDrop
142 *
143 * @param startTime Start Time for capturing values
144 * @param stopTime Stop Time for capturing values
145 * @param pollInterval The periodic interval at which the counters are written to the trace file
146 * Default: 1s
147 */
148 void EnableWifiPhyCounters(Time startTime, Time stopTime, Time pollInterval = Seconds(1));
149
150 /**
151 * @brief Enable tracking of the Ipv4 routing table for all Nodes
152 *
153 * @param fileName Trace file for storing routing table information
154 * @param startTime Start time for capture
155 * @param stopTime End time for capture
156 * @param pollInterval The periodic interval at which routing table information is polled
157 * Default: 5s
158 *
159 * @returns reference to this AnimationInterface object
160 */
161 AnimationInterface& EnableIpv4RouteTracking(std::string fileName,
162 Time startTime,
164 Time pollInterval = Seconds(5));
165
166 /**
167 * @brief Enable tracking of the Ipv4 routing table for a set of Nodes
168 *
169 * @param fileName Trace file for storing routing table information
170 * @param startTime Start time for capture
171 * @param stopTime End time for capture
172 * @param nc A NodeContainer containing nodes for which Routing table has to be tracked
173 * @param pollInterval The periodic interval at which routing table information is polled
174 * Default: 5s
175 *
176 * @returns reference to this AnimationInterface object
177 */
178 AnimationInterface& EnableIpv4RouteTracking(std::string fileName,
179 Time startTime,
181 NodeContainer nc,
182 Time pollInterval = Seconds(5));
183
184 /**
185 * @brief Check if AnimationInterface is initialized
186 *
187 * @returns true if AnimationInterface was already initialized
188 *
189 */
190 static bool IsInitialized();
191
192 /**
193 * @brief Specify the time at which capture should start
194 *
195 * @param t The time at which AnimationInterface should begin capture of traffic info
196 *
197 */
198 void SetStartTime(Time t);
199
200 /**
201 * @brief Specify the time at which capture should stop
202 *
203 * @param t The time at which AnimationInterface should stop capture of traffic info
204 *
205 */
206 void SetStopTime(Time t);
207
208 /**
209 * @brief Set Max packets per trace file
210 * @param maxPktsPerFile The maximum number of packets per trace file.
211 AnimationInterface will create trace files with the following
212 filenames : filename, filename-1, filename-2..., filename-N
213 where each file contains packet info for 'maxPktsPerFile' number of packets
214 *
215 */
216 void SetMaxPktsPerTraceFile(uint64_t maxPktsPerFile);
217
218 /**
219 * @brief Set mobility poll interval:WARNING: setting a low interval can
220 * cause slowness
221 *
222 * @param t Time interval between fetching mobility/position information
223 * Default: 0.25s
224 *
225 */
227
228 /**
229 * @brief Set a callback function to listen to AnimationInterface write events
230 *
231 * @param cb Address of callback function
232 *
233 */
235
236 /**
237 * @brief Reset the write callback function
238 *
239 */
241
242 /**
243 * @brief Helper function to set Constant Position for a given node
244 * @param n Ptr to the node
245 * @param x X coordinate of the node
246 * @param y Y coordinate of the node
247 * @param z Z coordinate of the node
248 *
249 */
250 static void SetConstantPosition(Ptr<Node> n, double x, double y, double z = 0);
251
252 /**
253 * @brief Helper function to update the description for a given node
254 * @param n Ptr to the node
255 * @param descr A string to briefly describe the node
256 *
257 */
258 void UpdateNodeDescription(Ptr<Node> n, std::string descr);
259
260 /**
261 * @brief Helper function to update the description for a given node
262 * @param nodeId Id of the node
263 * @param descr A string to briefly describe the node
264 *
265 */
266 void UpdateNodeDescription(uint32_t nodeId, std::string descr);
267
268 /**
269 * @brief Helper function to update the image of a node
270 * @param nodeId Id of the node
271 * @param resourceId Id of the image resource that was previously added
272 *
273 */
274 void UpdateNodeImage(uint32_t nodeId, uint32_t resourceId);
275
276 /**
277 * @brief Helper function to update the size of a node
278 * @param n Ptr to the node
279 * @param width Width of the node
280 * @param height Height of the node
281 *
282 */
283 void UpdateNodeSize(Ptr<Node> n, double width, double height);
284
285 /**
286 * @brief Helper function to update the size of a node
287 * @param nodeId Id of the node
288 * @param width Width of the node
289 * @param height Height of the node
290 *
291 */
292 void UpdateNodeSize(uint32_t nodeId, double width, double height);
293
294 /**
295 * @brief Helper function to update the node color
296 * @param n Ptr to the node
297 * @param r Red component value (0-255)
298 * @param g Green component value (0-255)
299 * @param b Blue component value (0-255)
300 *
301 */
302 void UpdateNodeColor(Ptr<Node> n, uint8_t r, uint8_t g, uint8_t b);
303
304 /**
305 * @brief Helper function to update the node color
306 * @param nodeId Id of the node
307 * @param r Red component value (0-255)
308 * @param g Green component value (0-255)
309 * @param b Blue component value (0-255)
310 *
311 */
312 void UpdateNodeColor(uint32_t nodeId, uint8_t r, uint8_t g, uint8_t b);
313
314 /**
315 * @brief Helper function to update a node's counter referenced by the nodeCounterId
316 * @param nodeCounterId The counter Id obtained from AddNodeCounter
317 * @param nodeId Node Id of the node
318 * @param counter Current value of the counter
319 *
320 */
321 void UpdateNodeCounter(uint32_t nodeCounterId, uint32_t nodeId, double counter);
322
323 /**
324 * @brief Helper function to set the background image
325 * @param fileName File name of the background image
326 * @param x X coordinate of the image
327 * @param y Y coordinate of the image
328 * @param scaleX X scale of the image
329 * @param scaleY Y scale of the image
330 * @param opacity Opacity of the background: A value between 0.0 and 1.0. 0.0 is transparent,
331 * 1.0 is opaque
332 *
333 */
334 void SetBackgroundImage(std::string fileName,
335 double x,
336 double y,
337 double scaleX,
338 double scaleY,
339 double opacity);
340
341 /**
342 * @brief Helper function to update the description for a link
343 * @param fromNode Node Id of the "from Node" of the p2p link
344 * @param toNode Node Id of the "to Node" of the p2p link
345 * @param linkDescription Description of the link such as link bandwidth
346 *
347 */
348 void UpdateLinkDescription(uint32_t fromNode, uint32_t toNode, std::string linkDescription);
349
350 /**
351 * @brief Helper function to update the description for a link
352 * @param fromNode Ptr to the "from Node" of the p2p link
353 * @param toNode Ptr to the "to Node" of the p2p link
354 * @param linkDescription Description of the link such as link bandwidth
355 *
356 */
357 void UpdateLinkDescription(Ptr<Node> fromNode, Ptr<Node> toNode, std::string linkDescription);
358
359 /**
360 * @brief Helper function to print the routing path from a source node to destination IP
361 * @param fromNodeId The source node
362 * @param destinationIpv4Address The destination Ipv4 Address
363 *
364 * @returns reference to this AnimationInterface object
365 */
367 std::string destinationIpv4Address);
368
369 /**
370 * @brief Is AnimationInterface started
371 *
372 * @returns true if AnimationInterface was started
373 */
374 bool IsStarted() const;
375
376 /**
377 * @brief Do not trace packets. This helps reduce the trace file size if AnimationInterface is
378 * solely used for tracking mobility, routing paths and counters
379 */
380 void SkipPacketTracing();
381
382 /**
383 *
384 * @brief Enable Packet metadata
385 * @param enable if true enables writing the packet metadata to the XML trace file
386 * if false disables writing the packet metadata
387 *
388 */
389 void EnablePacketMetadata(bool enable = true);
390
391 /**
392 *
393 * @brief Get trace file packet count (This used only for testing)
394 *
395 * @returns Number of packets recorded in the current trace file
396 */
397 uint64_t GetTracePktCount() const;
398
399 /**
400 *
401 * @brief Setup a node counter
402 * @param counterName A string to identify the counter
403 * @param counterType The type of the counter, such as uint32, double etc
404 *
405 * @returns The id of the counter to be used as a reference for future
406 */
407 uint32_t AddNodeCounter(std::string counterName, CounterType counterType);
408
409 /**
410 *
411 * @brief Add a resource such as the path to an image file
412 * @param resourcePath Absolute Path to an image/resource
413 *
414 * @returns a number identifying the resource
415 */
416 uint32_t AddResource(std::string resourcePath);
417
418 /**
419 *
420 * @brief Get node's energy fraction (This used only for testing)
421 * @param node
422 *
423 * @returns current node's remaining energy (between [0, 1])
424 */
425 double GetNodeEnergyFraction(Ptr<const Node> node) const;
426
427 private:
428 /**
429 * AnimPacketInfo class
430 */
432
433 {
434 public:
436 /**
437 * Constructor
438 *
439 * @param pInfo anim packet info
440 */
441 AnimPacketInfo(const AnimPacketInfo& pInfo);
442 /**
443 * Constructor
444 *
445 * @param tx_nd transmit device
446 * @param fbTx fb transmit
447 * @param txNodeId transmit node ID
448 */
449 AnimPacketInfo(Ptr<const NetDevice> tx_nd, const Time fbTx, uint32_t txNodeId = 0);
450 Ptr<const NetDevice> m_txnd; ///< transmit device
451 uint32_t m_txNodeId; ///< node ID
452 double m_fbTx; ///< fb transmit
453 double m_lbTx; ///< lb transmit
454 double m_fbRx; ///< fb receive
455 double m_lbRx; ///< lb receive
456 Ptr<const NetDevice> m_rxnd; ///< receive device
457 /**
458 * Process receive begin
459 * @param nd the device
460 * @param fbRx
461 */
462 void ProcessRxBegin(Ptr<const NetDevice> nd, const double fbRx);
463 };
464
465 /// RGB structure
466 struct Rgb
467 {
468 uint8_t r; ///< r
469 uint8_t g; ///< g
470 uint8_t b; ///< b
471 };
472
473 /// P2pLinkNodeIdPair structure
475 {
476 uint32_t fromNode; ///< from node
477 uint32_t toNode; ///< to node
478 };
479
480 /// LinkProperties structure
482 {
483 std::string fromNodeDescription; ///< from node description
484 std::string toNodeDescription; ///< to node description
485 std::string linkDescription; ///< link description
486 };
487
488 /// LinkPairCompare structure
490 {
491 /**
492 * comparison operator
493 *
494 * @param first
495 * @param second
496 * @return true if equal
497 */
499 {
500 // Check if they are the same node pairs but flipped
501 if (((first.fromNode == second.fromNode) && (first.toNode == second.toNode)) ||
502 ((first.fromNode == second.toNode) && (first.toNode == second.fromNode)))
503 {
504 return false;
505 }
506 std::ostringstream oss1;
507 oss1 << first.fromNode << first.toNode;
508 std::ostringstream oss2;
509 oss2 << second.fromNode << second.toNode;
510 return oss1.str() < oss2.str();
511 }
512 };
513
514 /// Ipv4RouteTrackElement structure
516 {
517 std::string destination; ///< destination
518 uint32_t fromNodeId; ///< from node ID
519 };
520
521 /// Ipv4RoutePathElement structure
523 {
524 uint32_t nodeId; ///< node ID
525 std::string nextHop; ///< next hop
526 };
527
528 /// ProtocolType enumeration
537
538 /// NodeSize structure
539 struct NodeSize
540 {
541 double width; ///< width
542 double height; ///< height
543 };
544
545 typedef std::map<P2pLinkNodeIdPair, LinkProperties, LinkPairCompare>
546 LinkPropertiesMap; ///< LinkPropertiesMap typedef
547 typedef std::map<uint32_t, std::string> NodeDescriptionsMap; ///< NodeDescriptionsMap typedef
548 typedef std::map<uint32_t, Rgb> NodeColorsMap; ///< NodeColorsMap typedef
549 typedef std::map<uint64_t, AnimPacketInfo>
550 AnimUidPacketInfoMap; ///< AnimUidPacketInfoMap typedef
551 typedef std::map<uint32_t, double> EnergyFractionMap; ///< EnergyFractionMap typedef
552 typedef std::vector<Ipv4RoutePathElement>
553 Ipv4RoutePathElements; ///< Ipv4RoutePathElements typedef
554 typedef std::multimap<uint32_t, std::string> NodeIdIpv4Map; ///< NodeIdIpv4Map typedef
555 typedef std::multimap<uint32_t, std::string> NodeIdIpv6Map; ///< NodeIdIpv6Map typedef
556 typedef std::pair<uint32_t, std::string> NodeIdIpv4Pair; ///< NodeIdIpv4Pair typedef
557 typedef std::pair<uint32_t, std::string> NodeIdIpv6Pair; ///< NodeIdIpv6Pair typedef
558
559 // Node Counters
560 typedef std::map<uint32_t, uint64_t> NodeCounterMap64; ///< NodeCounterMap64 typedef
561
562 /// AnimXmlElement class
564 {
565 public:
566 /**
567 * Constructor
568 *
569 * @param tagName tag name
570 * @param emptyElement empty element?
571 */
572 AnimXmlElement(std::string tagName, bool emptyElement = true);
573 template <typename T>
574 /**
575 * Add attribute function
576 * @param attribute the attribute name
577 * @param value the attribute value
578 * @param xmlEscape true to escape
579 */
580 void AddAttribute(std::string attribute, T value, bool xmlEscape = false);
581 /**
582 * Set text function
583 * @param text the text for the element
584 */
585 void SetText(std::string text);
586 /**
587 * Append child function
588 * @param e the element to add as a child
589 */
591 /**
592 * Get text for the element function
593 * @param autoClose auto close the element
594 * @returns the text
595 */
596 std::string ToString(bool autoClose = true);
597
598 private:
599 std::string m_tagName; ///< tag name
600 std::string m_text; ///< element string
601 std::vector<std::string> m_attributes; ///< list of attributes
602 std::vector<std::string> m_children; ///< list of children
603 };
604
605 // ##### State #####
606
607 FILE* m_f; ///< File handle for output (0 if none)
608 FILE* m_routingF; ///< File handle for routing table output (0 if None);
609 Time m_mobilityPollInterval; ///< mobility poll interval
610 std::string m_outputFileName; ///< output file name
611 uint64_t gAnimUid; ///< Packet unique identifier used by AnimationInterface
613 bool m_started; ///< started
614 bool m_enablePacketMetadata; ///< enable packet metadata
615 Time m_startTime; ///< start time
616 Time m_stopTime; ///< stop time
617 uint64_t m_maxPktsPerFile; ///< maximum packets per file
618 std::string m_originalFileName; ///< original file name
619 Time m_routingStopTime; ///< routing stop time
620 std::string m_routingFileName; ///< routing file name
621 Time m_routingPollInterval; ///< routing poll interval
622 NodeContainer m_routingNc; ///< routing node container
623 Time m_ipv4L3ProtocolCountersStopTime; ///< IPv4 L3 protocol counters stop time
624 Time m_ipv4L3ProtocolCountersPollInterval; ///< IPv4 L3 protocol counters poll interval
625 Time m_queueCountersStopTime; ///< queue counters stop time
626 Time m_queueCountersPollInterval; ///< queue counters poll interval
627 Time m_wifiMacCountersStopTime; ///< wifi MAC counters stop time
628 Time m_wifiMacCountersPollInterval; ///< wifi MAC counters poll interval
629 Time m_wifiPhyCountersStopTime; ///< wifi Phy counters stop time
630 Time m_wifiPhyCountersPollInterval; ///< wifi Phy counters poll interval
631 static Rectangle* userBoundary; ///< user boundary
632 bool m_trackPackets; ///< track packets
633
634 // Counter ID
635 uint32_t m_remainingEnergyCounterId; ///< remaining energy counter ID
636
637 uint32_t m_ipv4L3ProtocolTxCounterId; ///< IPv4 L3 protocol transmit counter ID
638 uint32_t m_ipv4L3ProtocolRxCounterId; ///< IPv4 L3 protocol receive counter ID
639 uint32_t m_ipv4L3ProtocolDropCounterId; ///< IPv4 protocol drop counter ID
640
641 uint32_t m_queueEnqueueCounterId; ///< queue enqueue counter ID
642 uint32_t m_queueDequeueCounterId; ///< queue dequeue counter ID
643 uint32_t m_queueDropCounterId; ///< queue drop counter ID
644
645 uint32_t m_wifiMacTxCounterId; ///< wifi MAC transmit counter ID
646 uint32_t m_wifiMacTxDropCounterId; ///< wifi MAC transmit drop counter ID
647 uint32_t m_wifiMacRxCounterId; ///< wifi MAC receive counter ID
648 uint32_t m_wifiMacRxDropCounterId; ///< wifi MAC receive drop counter ID
649
650 uint32_t m_wifiPhyTxDropCounterId; ///< wifi Phy transmit drop counter ID
651 uint32_t m_wifiPhyRxDropCounterId; ///< wifi Phy receive drop counter ID
652
654 AnimUidPacketInfoMap m_pendingLrWpanPackets; ///< pending LR-WPAN packets
658
659 std::map<uint32_t, Vector> m_nodeLocation; ///< node location
660 std::map<std::string, uint32_t> m_macToNodeIdMap; ///< MAC to node ID map
661 std::map<std::string, uint32_t> m_ipv4ToNodeIdMap; ///< IPv4 to node ID map
662 std::map<std::string, uint32_t> m_ipv6ToNodeIdMap; ///< IPv6 to node ID map
663 NodeIdIpv4Map m_nodeIdIpv4Map; ///< node ID to IPv4 map
664 NodeIdIpv6Map m_nodeIdIpv6Map; ///< node ID to IPv6 map
665
666 NodeColorsMap m_nodeColors; ///< node colors
669 EnergyFractionMap m_nodeEnergyFraction; ///< node energy fraction
670 uint64_t m_currentPktCount; ///< current packet count
671 std::vector<Ipv4RouteTrackElement> m_ipv4RouteTrackElements; ///< IPv route track elements
672 std::map<uint32_t, NodeSize> m_nodeSizes; ///< node sizes
673 std::vector<std::string> m_resources; ///< resources
674 std::vector<std::string> m_nodeCounters; ///< node counters
675
676 /* Value-added custom counters */
677 NodeCounterMap64 m_nodeIpv4Drop; ///< node IPv4 drop
678 NodeCounterMap64 m_nodeIpv4Tx; ///< node IPv4 transmit
679 NodeCounterMap64 m_nodeIpv4Rx; ///< node IPv4 receive
680 NodeCounterMap64 m_nodeQueueEnqueue; ///< node queue enqueue
681 NodeCounterMap64 m_nodeQueueDequeue; ///< node queue dequeue
682 NodeCounterMap64 m_nodeQueueDrop; ///< node queue drop
683 NodeCounterMap64 m_nodeWifiMacTx; ///< node wifi MAC transmit
684 NodeCounterMap64 m_nodeWifiMacTxDrop; ///< node wifi MAC transmit drop
685 NodeCounterMap64 m_nodeWifiMacRx; ///< node wifi MAC receive
686 NodeCounterMap64 m_nodeWifiMacRxDrop; ///< node wifi MAC receive drop
687 NodeCounterMap64 m_nodeWifiPhyTxDrop; ///< node wifi Phy transmit drop
688 NodeCounterMap64 m_nodeWifiPhyRxDrop; ///< node wifi Phy receive drop
689 NodeCounterMap64 m_nodeLrWpanMacTx; ///< node LR-WPAN MAC transmit
690 NodeCounterMap64 m_nodeLrWpanMacTxDrop; ///< node LR-WPAN MAC transmit drop
691 NodeCounterMap64 m_nodeLrWpanMacRx; ///< node LR-WPAN MAC receive
692 NodeCounterMap64 m_nodeLrWpanMacRxDrop; ///< node LR-WPAN MAC receive drop
693
694 /**
695 * Get elements from context
696 * @param context the context string
697 * @returns the elements
698 */
699 const std::vector<std::string> GetElementsFromContext(const std::string& context) const;
700 /**
701 * Get node from context
702 * @param context the context string
703 * @returns the node
704 */
705 Ptr<Node> GetNodeFromContext(const std::string& context) const;
706 /**
707 * Get net device from context
708 * @param context the context string
709 * @returns the device
710 */
711 Ptr<NetDevice> GetNetDeviceFromContext(std::string context);
712
713 // ##### General #####
714 /**
715 * Start animation function
716 *
717 * @param restart
718 */
719 void StartAnimation(bool restart = false);
720 /**
721 * Set output file function
722 *
723 * @param fn the file name
724 * @param routing
725 */
726 void SetOutputFile(const std::string& fn, bool routing = false);
727 /**
728 * Stop animation function
729 *
730 * @param onlyAnimation
731 */
732 void StopAnimation(bool onlyAnimation = false);
733 /**
734 * Counter type to string function
735 * @param counterType the counter type
736 * @returns the string
737 */
738 std::string CounterTypeToString(CounterType counterType);
739 /**
740 * Get packet metadata function
741 * @param p the packet
742 * @returns the meta data
743 */
745 /**
746 * Add byte tag function
747 * @param animUid the UID
748 * @param p the packet
749 */
750 void AddByteTag(uint64_t animUid, Ptr<const Packet> p);
751 /**
752 * WriteN function
753 * @param data the data t write
754 * @param count the number of bytes to write
755 * @param f the file to write to
756 * @returns the number of bytes written
757 */
758 int WriteN(const char* data, uint32_t count, FILE* f);
759 /**
760 * WriteN function
761 * @param st the string to output
762 * @param f the file to write to
763 * @returns the number of bytes written
764 */
765 int WriteN(const std::string& st, FILE* f);
766 /**
767 * Get MAC address function
768 * @param nd the device
769 * @returns the MAC address
770 */
771 std::string GetMacAddress(Ptr<NetDevice> nd);
772 /**
773 * Get IPv4 address
774 * @param nd the device
775 * @returns the IPv4 address
776 */
777 std::string GetIpv4Address(Ptr<NetDevice> nd);
778 /**
779 * Get IPv6 address
780 * @param nd the device
781 * @returns the IPv6 address
782 */
783 std::string GetIpv6Address(Ptr<NetDevice> nd);
784 /**
785 * Get IPv4 addresses
786 * @param nd the device
787 * @returns the IPv4 address list
788 */
789 std::vector<std::string> GetIpv4Addresses(Ptr<NetDevice> nd);
790 /**
791 * Get IPv6 addresses
792 * @param nd the device
793 * @returns the IPv6 address list
794 */
795 std::vector<std::string> GetIpv6Addresses(Ptr<NetDevice> nd);
796
797 /**
798 * Get netanim version function
799 * @returns the net anim version string
800 */
801 std::string GetNetAnimVersion();
802 /// Mobility auto check function
803 void MobilityAutoCheck();
804 /**
805 * Is packet pending function
806 * @param animUid the UID
807 * @param protocolType the protocol type
808 * @returns true if a packet is pending
809 */
810 bool IsPacketPending(uint64_t animUid, ProtocolType protocolType);
811 /**
812 * Purge pending packets function
813 * @param protocolType the protocol type
814 */
815 void PurgePendingPackets(ProtocolType protocolType);
816 /**
817 * Protocol type to pending packets function
818 * @param protocolType the protocol type
819 * @returns AnimUidPacketInfoMap *
820 */
822 /**
823 * Protocol type to string function
824 * @param protocolType the protocol type
825 * @returns the protocol type string
826 */
827 std::string ProtocolTypeToString(ProtocolType protocolType);
828 /**
829 * Add pending packet function
830 * @param protocolType the protocol type
831 * @param animUid the UID
832 * @param pktInfo the packet info
833 */
834 void AddPendingPacket(ProtocolType protocolType, uint64_t animUid, AnimPacketInfo pktInfo);
835 /**
836 * Get anim UID from packet function
837 * @param p the packet
838 * @returns the UID
839 */
841 /**
842 * Add to IPv4 address node ID table function
843 * @param ipv4Address the IPv4 address
844 * @param nodeId the node ID
845 */
846 void AddToIpv4AddressNodeIdTable(std::string ipv4Address, uint32_t nodeId);
847 /**
848 * Add to IPv4 address node ID table function
849 * @param ipv4Addresses the list of IPv4 addresses
850 * @param nodeId the node ID
851 */
852 void AddToIpv4AddressNodeIdTable(std::vector<std::string> ipv4Addresses, uint32_t nodeId);
853 /**
854 * Add to IPv6 address node ID table function
855 * @param ipv6Address the IPv6 address
856 * @param nodeId the node ID
857 */
858 void AddToIpv6AddressNodeIdTable(std::string ipv6Address, uint32_t nodeId);
859 /**
860 * Add to IPv6 address node ID table function
861 * @param ipv6Addresses the list of IPv6 addresses
862 * @param nodeId the node ID
863 */
864 void AddToIpv6AddressNodeIdTable(std::vector<std::string> ipv6Addresses, uint32_t nodeId);
865 /**
866 * Is in time window function
867 * @returns true if in the time window
868 */
869 bool IsInTimeWindow();
870 /// Check maximum packets per trace file function
872
873 /// Track wifi phy counters function
875 /// Track wifi MAC counters function
877 /// Track IPv4 L3 protocol counters function
879 /// Track queue counters function
880 void TrackQueueCounters();
881 // ##### Routing #####
882 /// Track IPv4 router function
883 void TrackIpv4Route();
884 /// Track IPv4 route paths function
885 void TrackIpv4RoutePaths();
886 /**
887 * Get IPv4 routing table function
888 * @param n the node
889 * @returns the IPv4 routing table
890 */
891 std::string GetIpv4RoutingTable(Ptr<Node> n);
892 /**
893 * Recursive IPv4 route path search function
894 * @param from the source node
895 * @param to the destination node
896 * @param rpElements the IPv4 routing path elements
897 */
898 void RecursiveIpv4RoutePathSearch(std::string from,
899 std::string to,
900 Ipv4RoutePathElements& rpElements);
901 /**
902 * Write route path function
903 * @param nodeId the node ID
904 * @param destination the destination
905 * @param rpElements the IPv4 routing path elements
906 */
907 void WriteRoutePath(uint32_t nodeId, std::string destination, Ipv4RoutePathElements rpElements);
908
909 // ##### Trace #####
910 /**
911 * Enqueue trace function
912 * @param context the context
913 * @param p the packet
914 */
915 void EnqueueTrace(std::string context, Ptr<const Packet>);
916 /**
917 * Dequeue trace function
918 * @param context the context
919 * @param p the packet
920 */
921 void DequeueTrace(std::string context, Ptr<const Packet>);
922 /**
923 * Queue trace function
924 * @param context the context
925 * @param p the packet
926 */
927 void QueueDropTrace(std::string context, Ptr<const Packet>);
928 /**
929 * IPv4 transmit trace function
930 * @param context the context
931 * @param p the packet
932 * @param ipv4 the IP
933 * @param interfaceIndex the interface index
934 */
935 void Ipv4TxTrace(std::string context,
937 Ptr<Ipv4> ipv4,
938 uint32_t interfaceIndex);
939 /**
940 * IPv4 receive trace function
941 * @param context the context
942 * @param p the packet
943 * @param ipv4 the IP
944 * @param interfaceIndex the interface index
945 */
946 void Ipv4RxTrace(std::string context,
948 Ptr<Ipv4> ipv4,
949 uint32_t interfaceIndex);
950 /**
951 * IPv4 drop trace function
952 * @param context the context
953 * @param ipv4Header the IPv4 header
954 * @param p the packet
955 * @param dropReason the reason for the drop
956 * @param ipv4 the IP
957 * @param interfaceIndex the interface index
958 */
959 void Ipv4DropTrace(std::string context,
960 const Ipv4Header& ipv4Header,
963 Ptr<Ipv4> ipv4,
964 uint32_t interfaceIndex);
965
966 /**
967 * wifi MAC transmit trace function
968 * @param context the context
969 * @param p the packet
970 */
971 void WifiMacTxTrace(std::string context, Ptr<const Packet> p);
972 /**
973 * wifi MAC transmit drop trace function
974 * @param context the context
975 * @param p the packet
976 */
977 void WifiMacTxDropTrace(std::string context, Ptr<const Packet> p);
978 /**
979 * wifi MAC receive trace function
980 * @param context the context
981 * @param p the packet
982 */
983 void WifiMacRxTrace(std::string context, Ptr<const Packet> p);
984 /**
985 * wifi MAC receive drop trace function
986 * @param context the context
987 * @param p the packet
988 */
989 void WifiMacRxDropTrace(std::string context, Ptr<const Packet> p);
990 /**
991 * wifi Phy transmit drop trace function
992 * @param context the context
993 * @param p the packet
994 */
995 void WifiPhyTxDropTrace(std::string context, Ptr<const Packet> p);
996 /**
997 * wifi Phy receive drop trace function
998 * @param context the context
999 * @param p the packet
1000 * @param reason the reason
1001 */
1002 void WifiPhyRxDropTrace(std::string context,
1004 WifiPhyRxfailureReason reason);
1005 /**
1006 * LR-WPAN MAC transmit trace function
1007 * @param context the context
1008 * @param p the packet
1009 */
1010 void LrWpanMacTxTrace(std::string context, Ptr<const Packet> p);
1011 /**
1012 * LR-WPAN MAC transmit drop trace function
1013 * @param context the context
1014 * @param p the packet
1015 */
1016 void LrWpanMacTxDropTrace(std::string context, Ptr<const Packet> p);
1017 /**
1018 * LR-WPAN MAC receive trace function
1019 * @param context the context
1020 * @param p the packet
1021 */
1022 void LrWpanMacRxTrace(std::string context, Ptr<const Packet> p);
1023 /**
1024 * LR-WPAN MAC receive drop trace function
1025 * @param context the context
1026 * @param p the packet
1027 */
1028 void LrWpanMacRxDropTrace(std::string context, Ptr<const Packet> p);
1029 /**
1030 * Device transmit trace function
1031 * @param context the context
1032 * @param p the packet
1033 * @param tx the transmit device
1034 * @param rx the receive device
1035 * @param txTime the transmit time
1036 * @param rxTime the receive time
1037 */
1038 void DevTxTrace(std::string context,
1040 Ptr<NetDevice> tx,
1041 Ptr<NetDevice> rx,
1042 Time txTime,
1043 Time rxTime);
1044 /**
1045 * wifi Phy transmit PSDU begin trace function
1046 * @param context the context
1047 * @param psduMap the PSDU map
1048 * @param txVector the TXVECTOR
1049 * @param txPowerW the tx power in Watts
1050 */
1051 void WifiPhyTxBeginTrace(std::string context,
1052 WifiConstPsduMap psduMap,
1053 WifiTxVector txVector,
1054 double txPowerW);
1055 /**
1056 * wifi Phy receive begin trace function
1057 *
1058 * @param context the context
1059 * @param p the packet
1060 * @param rxPowersW the receive power per channel band in Watts
1061 */
1062 void WifiPhyRxBeginTrace(std::string context,
1064 RxPowerWattPerChannelBand rxPowersW);
1065 /**
1066 * LR-WPAN Phy receive begin trace function
1067 *
1068 * @param context the context
1069 * @param p the packet
1070 */
1071 void LrWpanPhyTxBeginTrace(std::string context, Ptr<const Packet> p);
1072 /**
1073 * LR-WPAN Phy receive begin trace function
1074 *
1075 * @param context the context
1076 * @param p the packet
1077 */
1078 void LrWpanPhyRxBeginTrace(std::string context, Ptr<const Packet> p);
1079 /**
1080 * CSMA Phy transmit begin trace function
1081 * @param context the context
1082 * @param p the packet
1083 */
1084 void CsmaPhyTxBeginTrace(std::string context, Ptr<const Packet> p);
1085 /**
1086 * CSMA Phy transmit end trace function
1087 *
1088 * @param context the context
1089 * @param p the packet
1090 */
1091 void CsmaPhyTxEndTrace(std::string context, Ptr<const Packet> p);
1092 /**
1093 * CSMA Phy receive end trace function
1094 *
1095 * @param context the context
1096 * @param p the packet
1097 */
1098 void CsmaPhyRxEndTrace(std::string context, Ptr<const Packet> p);
1099 /**
1100 * CSMA MAC receive trace function
1101 *
1102 * @param context the context
1103 * @param p the packet
1104 */
1105 void CsmaMacRxTrace(std::string context, Ptr<const Packet> p);
1106 /**
1107 * LTE transmit trace function
1108 * @param context the context
1109 * @param p the packet
1110 * @param m the MAC address
1111 */
1112 void LteTxTrace(std::string context, Ptr<const Packet> p, const Mac48Address& m);
1113 /**
1114 * LTE receive trace function
1115 * @param context the context
1116 * @param p the packet
1117 * @param m the MAC address
1118 */
1119 void LteRxTrace(std::string context, Ptr<const Packet> p, const Mac48Address& m);
1120 /**
1121 * LTE Spectrum Phy transmit start function
1122 * @param context the context
1123 * @param pb the packet burst
1124 */
1125 void LteSpectrumPhyTxStart(std::string context, Ptr<const PacketBurst> pb);
1126 /**
1127 * LTE Spectrum Phy receive start function
1128 * @param context the context
1129 * @param pb the packet burst
1130 */
1131 void LteSpectrumPhyRxStart(std::string context, Ptr<const PacketBurst> pb);
1132 /**
1133 * UAN Phy gen transmit trace function
1134 * @param context the context
1135 * @param p the packet
1136 */
1137 void UanPhyGenTxTrace(std::string context, Ptr<const Packet>);
1138 /**
1139 * UAN Phy gen receive trace function
1140 * @param context the context
1141 * @param p the packet
1142 */
1143 void UanPhyGenRxTrace(std::string context, Ptr<const Packet>);
1144 /**
1145 * Remaining energy trace function
1146 * @param context the context
1147 * @param previousEnergy The previous energy
1148 * @param currentEnergy The current energy
1149 */
1150 void RemainingEnergyTrace(std::string context, double previousEnergy, double currentEnergy);
1151 /**
1152 * Generic wireless transmit trace function
1153 * @param context the context
1154 * @param p the packet
1155 * @param protocolType the protocol type
1156 */
1157 void GenericWirelessTxTrace(std::string context,
1159 ProtocolType protocolType);
1160 /**
1161 * Generic wireless receive trace function
1162 * @param context the context
1163 * @param p the packet
1164 * @param protocolType the protocol type
1165 */
1166 void GenericWirelessRxTrace(std::string context,
1168 ProtocolType protocolType);
1169
1170 /// Connect callbacks function
1171 void ConnectCallbacks();
1172 /// Connect LTE function
1173 void ConnectLte();
1174 /**
1175 * Connect LTE ue function
1176 * @param n the node
1177 * @param nd the device
1178 * @param devIndex the device index
1179 */
1180 void ConnectLteUe(Ptr<Node> n, Ptr<LteUeNetDevice> nd, uint32_t devIndex);
1181 /**
1182 * Connect LTE ENB function
1183 * @param n the node
1184 * @param nd the device
1185 * @param devIndex the device index
1186 */
1188
1189 // ##### Mobility #####
1190 /**
1191 * Get position function
1192 * @param n the node
1193 * @returns the position vector
1194 */
1195 Vector GetPosition(Ptr<Node> n);
1196 /**
1197 * Update position function
1198 * @param n the node
1199 * @returns the position vector
1200 */
1201 Vector UpdatePosition(Ptr<Node> n);
1202 /**
1203 * Update position function
1204 * @param n the node
1205 * @param v the vector
1206 * @returns the position vector
1207 */
1208 Vector UpdatePosition(Ptr<Node> n, Vector v);
1209 /**
1210 * Update position function
1211 * @param ndev the device
1212 * @returns the position vector
1213 */
1214 Vector UpdatePosition(Ptr<NetDevice> ndev);
1215 /**
1216 * Node has moved function
1217 * @param n the node
1218 * @param newLocation the new location vector
1219 * @returns true if the node has moved
1220 */
1221 bool NodeHasMoved(Ptr<Node> n, Vector newLocation);
1222 /**
1223 * Get moved nodes function
1224 * @returns the list of moved nodes
1225 */
1226 std::vector<Ptr<Node>> GetMovedNodes();
1227 /**
1228 * Mobility course change trace function
1229 * @param mob the mobility model
1230 */
1232
1233 // ##### XML Helpers #####
1234
1235 /**
1236 * Write non P2P link properties function
1237 * @param id the ID
1238 * @param ipv4Address the IP address
1239 * @param channelType the channel type
1240 */
1241 void WriteNonP2pLinkProperties(uint32_t id, std::string ipv4Address, std::string channelType);
1242 /**
1243 * Write node update function
1244 * @param nodeId the node ID
1245 */
1247 /**
1248 * Output wireless packet transmit info
1249 * @param p the packet
1250 * @param pktInfo the packet info
1251 * @param animUid the UID
1252 */
1253 void OutputWirelessPacketTxInfo(Ptr<const Packet> p, AnimPacketInfo& pktInfo, uint64_t animUid);
1254 /**
1255 * Output wireless packet receive info
1256 * @param p the packet
1257 * @param pktInfo the packet info
1258 * @param animUid the UID
1259 */
1260 void OutputWirelessPacketRxInfo(Ptr<const Packet> p, AnimPacketInfo& pktInfo, uint64_t animUid);
1261 /**
1262 * Output CSMA packet function
1263 * @param p the packet
1264 * @param pktInfo the packet info
1265 */
1267 /// Write link properties function
1268 void WriteLinkProperties();
1269 /// Write IPv4 Addresses function
1270 void WriteIpv4Addresses();
1271 /// Write IPv6 Addresses function
1272 void WriteIpv6Addresses();
1273 /// Write nodes function
1274 void WriteNodes();
1275 /// Write node colors function
1276 void WriteNodeColors();
1277 /// Write node sizes function
1278 void WriteNodeSizes();
1279 /// Write node energies function
1280 void WriteNodeEnergies();
1281 /**
1282 * Write XML anim function
1283 * @param routing the routing
1284 */
1285 void WriteXmlAnim(bool routing = false);
1286 /**
1287 * Write XML update node position function
1288 * @param nodeId the node ID
1289 * @param x the X position
1290 * @param y the Y position
1291 */
1292 void WriteXmlUpdateNodePosition(uint32_t nodeId, double x, double y);
1293 /**
1294 * Write XML update node color function
1295 * @param nodeId the node ID
1296 * @param r the red color
1297 * @param g the green color
1298 * @param b the blue color
1299 */
1300 void WriteXmlUpdateNodeColor(uint32_t nodeId, uint8_t r, uint8_t g, uint8_t b);
1301 /**
1302 * Write XML update node description function
1303 * @param nodeId the node ID
1304 */
1306 /**
1307 * Write XML update node size function
1308 * @param nodeId the node ID
1309 * @param width the width
1310 * @param height the height
1311 */
1312 void WriteXmlUpdateNodeSize(uint32_t nodeId, double width, double height);
1313 /**
1314 * Write XML add resource function
1315 * @param resourceId the resource ID
1316 * @param resourcePath the resource path
1317 */
1318 void WriteXmlAddResource(uint32_t resourceId, std::string resourcePath);
1319 /**
1320 * Write XML add node counter function
1321 * @param counterId the counter ID
1322 * @param counterName the counter name
1323 * @param counterType the counter type
1324 */
1325 void WriteXmlAddNodeCounter(uint32_t counterId,
1326 std::string counterName,
1327 CounterType counterType);
1328 /**
1329 * Write XML update node image function
1330 * @param nodeId the node ID
1331 * @param resourceId the resource ID
1332 */
1333 void WriteXmlUpdateNodeImage(uint32_t nodeId, uint32_t resourceId);
1334 /**
1335 * Write XML update node counter function
1336 * @param counterId the counter ID
1337 * @param nodeId the node ID
1338 * @param value the node counter value
1339 */
1340 void WriteXmlUpdateNodeCounter(uint32_t counterId, uint32_t nodeId, double value);
1341 /**
1342 * Write XML node function
1343 * @param id the ID
1344 * @param sysId the system ID
1345 * @param locX the x location
1346 * @param locY the y location
1347 */
1348 void WriteXmlNode(uint32_t id, uint32_t sysId, double locX, double locY);
1349 /**
1350 * Write XML link counter function
1351 * @param fromId the from device
1352 * @param toLp the to device
1353 * @param toId the to ID
1354 */
1355 void WriteXmlLink(uint32_t fromId, uint32_t toLp, uint32_t toId);
1356 /**
1357 * Write XML update link counter function
1358 * @param fromId the from device
1359 * @param toId the to device
1360 * @param linkDescription the link description
1361 */
1362 void WriteXmlUpdateLink(uint32_t fromId, uint32_t toId, std::string linkDescription);
1363 /**
1364 * Write XMLP function
1365 * @param pktType the packet type
1366 * @param fId the FID
1367 * @param fbTx the FB transmit
1368 * @param lbTx the LB transmit
1369 * @param tId the TID
1370 * @param fbRx the FB receive
1371 * @param lbRx the LB receive
1372 * @param metaInfo the meta info
1373 */
1374 void WriteXmlP(std::string pktType,
1375 uint32_t fId,
1376 double fbTx,
1377 double lbTx,
1378 uint32_t tId,
1379 double fbRx,
1380 double lbRx,
1381 std::string metaInfo = "");
1382 /**
1383 * Write XMLP function
1384 * @param animUid the UID
1385 * @param pktType the packet type
1386 * @param fId the FID
1387 * @param fbTx the FB transmit
1388 * @param lbTx the LB transmit
1389 */
1390 void WriteXmlP(uint64_t animUid, std::string pktType, uint32_t fId, double fbTx, double lbTx);
1391 /**
1392 * Write XMLP Ref function
1393 * @param animUid the UID
1394 * @param fId the FID
1395 * @param fbTx the FB transmit
1396 * @param metaInfo the meta info
1397 */
1398 void WriteXmlPRef(uint64_t animUid, uint32_t fId, double fbTx, std::string metaInfo = "");
1399 /**
1400 * Write XML close function
1401 * @param name the name
1402 * @param routing true if routing
1403 */
1404 void WriteXmlClose(std::string name, bool routing = false);
1405 /**
1406 * Write XML non P2P link properties function
1407 * @param id the ID
1408 * @param ipAddress the IP address
1409 * @param channelType the channel type
1410 */
1411 void WriteXmlNonP2pLinkProperties(uint32_t id, std::string ipAddress, std::string channelType);
1412 /**
1413 * Write XML routing function
1414 * @param id the ID
1415 * @param routingInfo the routing info
1416 */
1417 void WriteXmlRouting(uint32_t id, std::string routingInfo);
1418 /**
1419 * Write XMLRP function
1420 * @param nodeId the node ID
1421 * @param destination the destination
1422 * @param rpElements the route path elements
1423 */
1424 void WriteXmlRp(uint32_t nodeId, std::string destination, Ipv4RoutePathElements rpElements);
1425 /**
1426 * Write XML update background function
1427 * @param fileName the file name
1428 * @param x the X value
1429 * @param y the Y value
1430 * @param scaleX the X scale
1431 * @param scaleY the Y scale
1432 * @param opacity the opacity
1433 */
1434 void WriteXmlUpdateBackground(std::string fileName,
1435 double x,
1436 double y,
1437 double scaleX,
1438 double scaleY,
1439 double opacity);
1440 /**
1441 * Write XML Ipv4 addresses function
1442 * @param nodeId the node ID
1443 * @param ipv4Addresses the list of Ipv4 addresses
1444 */
1445 void WriteXmlIpv4Addresses(uint32_t nodeId, std::vector<std::string> ipv4Addresses);
1446 /**
1447 * Write XML Ipv6 addresses function
1448 * @param nodeId the node ID
1449 * @param ipv6Addresses the list of Ipv6 addresses
1450 */
1451 void WriteXmlIpv6Addresses(uint32_t nodeId, std::vector<std::string> ipv6Addresses);
1452};
1453
1454/**
1455 * @ingroup netanim
1456 *
1457 * @brief Byte tag using by Anim to uniquely identify packets
1458 *
1459 * When Anim receives a Tx Notification we tag the packet with a unique global uint64_t identifier
1460 * before recording Tx information
1461 * When Anim receives Rx notifications the tag is used to retrieve Tx information recorded earlier
1462 */
1463
1464class AnimByteTag : public Tag
1465{
1466 public:
1467 /**
1468 * @brief Get Type Id
1469 * @returns Type Id
1470 */
1471 static TypeId GetTypeId();
1472
1473 /**
1474 * @brief Get Instance Type Id
1475 * @returns Type Id
1476 */
1477 TypeId GetInstanceTypeId() const override;
1478
1479 /**
1480 * @brief Get Serialized Size
1481 * @returns Serialized Size (i.e size of uint64_t)
1482 */
1483 uint32_t GetSerializedSize() const override;
1484
1485 /**
1486 * @brief Serialize function
1487 * @param i Tag Buffer
1488 */
1489 void Serialize(TagBuffer i) const override;
1490
1491 /**
1492 * @brief Deserialize function
1493 * @param i Tag Buffer
1494 */
1495 void Deserialize(TagBuffer i) override;
1496
1497 /**
1498 * @brief Print tag info
1499 * @param os Reference of ostream object
1500 */
1501 void Print(std::ostream& os) const override;
1502
1503 /**
1504 * @brief Set global Uid in tag
1505 * @param AnimUid global Uid
1506 */
1507 void Set(uint64_t AnimUid);
1508
1509 /**
1510 * @brief Get Uid in tag
1511 * @returns Uid in tag
1512 */
1513 uint64_t Get() const;
1514
1515 private:
1516 uint64_t m_AnimUid; ///< the UID
1517};
1518
1519} // namespace ns3
1520#endif
Byte tag using by Anim to uniquely identify packets.
TypeId GetInstanceTypeId() const override
Get Instance Type Id.
void Serialize(TagBuffer i) const override
Serialize function.
void Print(std::ostream &os) const override
Print tag info.
uint32_t GetSerializedSize() const override
Get Serialized Size.
uint64_t Get() const
Get Uid in tag.
static TypeId GetTypeId()
Get Type Id.
void Deserialize(TagBuffer i) override
Deserialize function.
uint64_t m_AnimUid
the UID
void Set(uint64_t AnimUid)
Set global Uid in tag.
Ptr< const NetDevice > m_txnd
transmit device
void ProcessRxBegin(Ptr< const NetDevice > nd, const double fbRx)
Process receive begin.
Ptr< const NetDevice > m_rxnd
receive device
void AppendChild(AnimXmlElement e)
Append child function.
std::vector< std::string > m_children
list of children
void SetText(std::string text)
Set text function.
std::vector< std::string > m_attributes
list of attributes
std::string ToString(bool autoClose=true)
Get text for the element function.
AnimXmlElement(std::string tagName, bool emptyElement=true)
Constructor.
void AddAttribute(std::string attribute, T value, bool xmlEscape=false)
Add attribute function.
FILE * m_f
File handle for output (0 if none)
Time m_wifiMacCountersPollInterval
wifi MAC counters poll interval
void CsmaPhyRxEndTrace(std::string context, Ptr< const Packet > p)
CSMA Phy receive end trace function.
void WriteNodeSizes()
Write node sizes function.
uint32_t AddNodeCounter(std::string counterName, CounterType counterType)
Setup a node counter.
void TrackQueueCounters()
Track queue counters function.
void SetMobilityPollInterval(Time t)
Set mobility poll interval:WARNING: setting a low interval can cause slowness.
uint32_t m_wifiMacRxCounterId
wifi MAC receive counter ID
bool IsPacketPending(uint64_t animUid, ProtocolType protocolType)
Is packet pending function.
bool NodeHasMoved(Ptr< Node > n, Vector newLocation)
Node has moved function.
void LrWpanPhyTxBeginTrace(std::string context, Ptr< const Packet > p)
LR-WPAN Phy receive begin trace function.
uint32_t m_queueDropCounterId
queue drop counter ID
void LrWpanPhyRxBeginTrace(std::string context, Ptr< const Packet > p)
LR-WPAN Phy receive begin trace function.
Time m_routingPollInterval
routing poll interval
void OutputCsmaPacket(Ptr< const Packet > p, AnimPacketInfo &pktInfo)
Output CSMA packet function.
uint64_t GetAnimUidFromPacket(Ptr< const Packet >)
Get anim UID from packet function.
EnergyFractionMap m_nodeEnergyFraction
node energy fraction
void GenericWirelessTxTrace(std::string context, Ptr< const Packet > p, ProtocolType protocolType)
Generic wireless transmit trace function.
std::map< uint32_t, Rgb > NodeColorsMap
NodeColorsMap typedef.
void LteRxTrace(std::string context, Ptr< const Packet > p, const Mac48Address &m)
LTE receive trace function.
std::string ProtocolTypeToString(ProtocolType protocolType)
Protocol type to string function.
NodeCounterMap64 m_nodeLrWpanMacRx
node LR-WPAN MAC receive
std::string m_routingFileName
routing file name
NodeCounterMap64 m_nodeIpv4Tx
node IPv4 transmit
std::map< std::string, uint32_t > m_ipv6ToNodeIdMap
IPv6 to node ID map.
void MobilityAutoCheck()
Mobility auto check function.
void WriteXmlRouting(uint32_t id, std::string routingInfo)
Write XML routing function.
void WifiPhyRxDropTrace(std::string context, Ptr< const Packet > p, WifiPhyRxfailureReason reason)
wifi Phy receive drop trace function
void WifiMacRxDropTrace(std::string context, Ptr< const Packet > p)
wifi MAC receive drop trace function
NodeCounterMap64 m_nodeQueueDrop
node queue drop
void ConnectLteUe(Ptr< Node > n, Ptr< LteUeNetDevice > nd, uint32_t devIndex)
Connect LTE ue function.
void DequeueTrace(std::string context, Ptr< const Packet >)
Dequeue trace function.
void ConnectCallbacks()
Connect callbacks function.
void WriteRoutePath(uint32_t nodeId, std::string destination, Ipv4RoutePathElements rpElements)
Write route path function.
AnimUidPacketInfoMap * ProtocolTypeToPendingPackets(ProtocolType protocolType)
Protocol type to pending packets function.
void RemainingEnergyTrace(std::string context, double previousEnergy, double currentEnergy)
Remaining energy trace function.
void Ipv4DropTrace(std::string context, const Ipv4Header &ipv4Header, Ptr< const Packet > p, Ipv4L3Protocol::DropReason dropReason, Ptr< Ipv4 > ipv4, uint32_t interfaceIndex)
IPv4 drop trace function.
NodeColorsMap m_nodeColors
node colors
std::multimap< uint32_t, std::string > NodeIdIpv6Map
NodeIdIpv6Map typedef.
void UpdateNodeCounter(uint32_t nodeCounterId, uint32_t nodeId, double counter)
Helper function to update a node's counter referenced by the nodeCounterId.
void WifiPhyRxBeginTrace(std::string context, Ptr< const Packet > p, RxPowerWattPerChannelBand rxPowersW)
wifi Phy receive begin trace function
void LrWpanMacRxDropTrace(std::string context, Ptr< const Packet > p)
LR-WPAN MAC receive drop trace function.
void LteSpectrumPhyTxStart(std::string context, Ptr< const PacketBurst > pb)
LTE Spectrum Phy transmit start function.
NodeCounterMap64 m_nodeLrWpanMacTx
node LR-WPAN MAC transmit
void WriteXmlAddNodeCounter(uint32_t counterId, std::string counterName, CounterType counterType)
Write XML add node counter function.
void WriteXmlPRef(uint64_t animUid, uint32_t fId, double fbTx, std::string metaInfo="")
Write XMLP Ref function.
NodeCounterMap64 m_nodeWifiPhyTxDrop
node wifi Phy transmit drop
void WriteLinkProperties()
Write link properties function.
void WriteIpv4Addresses()
Write IPv4 Addresses function.
const std::vector< std::string > GetElementsFromContext(const std::string &context) const
Get elements from context.
void WriteXmlAddResource(uint32_t resourceId, std::string resourcePath)
Write XML add resource function.
void OutputWirelessPacketTxInfo(Ptr< const Packet > p, AnimPacketInfo &pktInfo, uint64_t animUid)
Output wireless packet transmit info.
void LteSpectrumPhyRxStart(std::string context, Ptr< const PacketBurst > pb)
LTE Spectrum Phy receive start function.
void SetOutputFile(const std::string &fn, bool routing=false)
Set output file function.
NodeCounterMap64 m_nodeWifiMacTx
node wifi MAC transmit
std::map< uint32_t, std::string > NodeDescriptionsMap
NodeDescriptionsMap typedef.
void LteTxTrace(std::string context, Ptr< const Packet > p, const Mac48Address &m)
LTE transmit trace function.
void EnableIpv4L3ProtocolCounters(Time startTime, Time stopTime, Time pollInterval=Seconds(1))
Enable tracking of Ipv4 L3 Protocol Counters such as Tx, Rx, Drop.
int WriteN(const char *data, uint32_t count, FILE *f)
WriteN function.
std::map< std::string, uint32_t > m_macToNodeIdMap
MAC to node ID map.
Ptr< Node > GetNodeFromContext(const std::string &context) const
Get node from context.
std::map< uint32_t, Vector > m_nodeLocation
node location
Ptr< NetDevice > GetNetDeviceFromContext(std::string context)
Get net device from context.
FILE * m_routingF
File handle for routing table output (0 if None);.
void UpdateNodeImage(uint32_t nodeId, uint32_t resourceId)
Helper function to update the image of a node.
void TrackWifiPhyCounters()
Track wifi phy counters function.
AnimUidPacketInfoMap m_pendingUanPackets
pending UAN packets
void TrackIpv4RoutePaths()
Track IPv4 route paths function.
double GetNodeEnergyFraction(Ptr< const Node > node) const
Get node's energy fraction (This used only for testing)
bool IsInTimeWindow()
Is in time window function.
void CsmaPhyTxBeginTrace(std::string context, Ptr< const Packet > p)
CSMA Phy transmit begin trace function.
bool m_enablePacketMetadata
enable packet metadata
void PurgePendingPackets(ProtocolType protocolType)
Purge pending packets function.
void SetMaxPktsPerTraceFile(uint64_t maxPktsPerFile)
Set Max packets per trace file.
uint64_t m_maxPktsPerFile
maximum packets per file
uint32_t m_ipv4L3ProtocolRxCounterId
IPv4 L3 protocol receive counter ID.
NodeCounterMap64 m_nodeIpv4Rx
node IPv4 receive
~AnimationInterface()
Destructor for the animator interface.
void AddToIpv4AddressNodeIdTable(std::string ipv4Address, uint32_t nodeId)
Add to IPv4 address node ID table function.
NodeIdIpv4Map m_nodeIdIpv4Map
node ID to IPv4 map
Time m_queueCountersPollInterval
queue counters poll interval
std::map< P2pLinkNodeIdPair, LinkProperties, LinkPairCompare > LinkPropertiesMap
LinkPropertiesMap typedef.
std::vector< std::string > GetIpv6Addresses(Ptr< NetDevice > nd)
Get IPv6 addresses.
void UpdateLinkDescription(uint32_t fromNode, uint32_t toNode, std::string linkDescription)
Helper function to update the description for a link.
void Ipv4RxTrace(std::string context, Ptr< const Packet > p, Ptr< Ipv4 > ipv4, uint32_t interfaceIndex)
IPv4 receive trace function.
NodeCounterMap64 m_nodeQueueEnqueue
node queue enqueue
void WriteXmlUpdateNodeCounter(uint32_t counterId, uint32_t nodeId, double value)
Write XML update node counter function.
std::vector< std::string > GetIpv4Addresses(Ptr< NetDevice > nd)
Get IPv4 addresses.
Time m_wifiPhyCountersPollInterval
wifi Phy counters poll interval
uint32_t m_queueDequeueCounterId
queue dequeue counter ID
NodeCounterMap64 m_nodeWifiMacRx
node wifi MAC receive
void AddToIpv6AddressNodeIdTable(std::string ipv6Address, uint32_t nodeId)
Add to IPv6 address node ID table function.
AnimationInterface & AddSourceDestination(uint32_t fromNodeId, std::string destinationIpv4Address)
Helper function to print the routing path from a source node to destination IP.
NodeCounterMap64 m_nodeIpv4Drop
node IPv4 drop
Time m_ipv4L3ProtocolCountersStopTime
IPv4 L3 protocol counters stop time.
uint32_t m_queueEnqueueCounterId
queue enqueue counter ID
void AddByteTag(uint64_t animUid, Ptr< const Packet > p)
Add byte tag function.
Time m_ipv4L3ProtocolCountersPollInterval
IPv4 L3 protocol counters poll interval.
void WriteNonP2pLinkProperties(uint32_t id, std::string ipv4Address, std::string channelType)
Write non P2P link properties function.
void StopAnimation(bool onlyAnimation=false)
Stop animation function.
std::vector< Ipv4RoutePathElement > Ipv4RoutePathElements
Ipv4RoutePathElements typedef.
void UanPhyGenTxTrace(std::string context, Ptr< const Packet >)
UAN Phy gen transmit trace function.
void WifiMacTxDropTrace(std::string context, Ptr< const Packet > p)
wifi MAC transmit drop trace function
uint32_t m_ipv4L3ProtocolTxCounterId
IPv4 L3 protocol transmit counter ID.
Time m_queueCountersStopTime
queue counters stop time
std::string CounterTypeToString(CounterType counterType)
Counter type to string function.
ProtocolType
ProtocolType enumeration.
std::string GetMacAddress(Ptr< NetDevice > nd)
Get MAC address function.
std::vector< Ptr< Node > > GetMovedNodes()
Get moved nodes function.
uint32_t m_wifiMacTxCounterId
wifi MAC transmit counter ID
void SkipPacketTracing()
Do not trace packets.
NodeCounterMap64 m_nodeWifiMacRxDrop
node wifi MAC receive drop
NodeDescriptionsMap m_nodeDescriptions
node description
void WriteXmlAnim(bool routing=false)
Write XML anim function.
std::map< uint32_t, double > EnergyFractionMap
EnergyFractionMap typedef.
void SetStartTime(Time t)
Specify the time at which capture should start.
uint32_t AddResource(std::string resourcePath)
Add a resource such as the path to an image file.
AnimationInterface(const std::string filename)
Constructor.
std::string GetIpv6Address(Ptr< NetDevice > nd)
Get IPv6 address.
void WriteNodeEnergies()
Write node energies function.
std::map< uint32_t, uint64_t > NodeCounterMap64
NodeCounterMap64 typedef.
static Rectangle * userBoundary
user boundary
void CsmaMacRxTrace(std::string context, Ptr< const Packet > p)
CSMA MAC receive trace function.
void WifiPhyTxBeginTrace(std::string context, WifiConstPsduMap psduMap, WifiTxVector txVector, double txPowerW)
wifi Phy transmit PSDU begin trace function
void UanPhyGenRxTrace(std::string context, Ptr< const Packet >)
UAN Phy gen receive trace function.
LinkPropertiesMap m_linkProperties
link properties
void WriteXmlUpdateNodeDescription(uint32_t nodeId)
Write XML update node description function.
void UpdateNodeSize(Ptr< Node > n, double width, double height)
Helper function to update the size of a node.
std::map< uint32_t, NodeSize > m_nodeSizes
node sizes
std::pair< uint32_t, std::string > NodeIdIpv6Pair
NodeIdIpv6Pair typedef.
void(* AnimWriteCallback)(const char *str)
typedef for WriteCallBack used for listening to AnimationInterface write messages
void ConnectLte()
Connect LTE function.
bool m_trackPackets
track packets
std::string GetNetAnimVersion()
Get netanim version function.
void WriteXmlNonP2pLinkProperties(uint32_t id, std::string ipAddress, std::string channelType)
Write XML non P2P link properties function.
AnimationInterface & EnableIpv4RouteTracking(std::string fileName, Time startTime, Time stopTime, Time pollInterval=Seconds(5))
Enable tracking of the Ipv4 routing table for all Nodes.
void WriteXmlClose(std::string name, bool routing=false)
Write XML close function.
uint64_t gAnimUid
Packet unique identifier used by AnimationInterface.
void CheckMaxPktsPerTraceFile()
Check maximum packets per trace file function.
NodeCounterMap64 m_nodeLrWpanMacTxDrop
node LR-WPAN MAC transmit drop
NodeIdIpv6Map m_nodeIdIpv6Map
node ID to IPv6 map
void TrackIpv4Route()
Track IPv4 router function.
void EnableWifiPhyCounters(Time startTime, Time stopTime, Time pollInterval=Seconds(1))
Enable tracking of Wifi Phy Counters such as TxDrop, RxDrop.
AnimUidPacketInfoMap m_pendingWifiPackets
pending wifi packets
void EnablePacketMetadata(bool enable=true)
Enable Packet metadata.
Time m_routingStopTime
routing stop time
void SetStopTime(Time t)
Specify the time at which capture should stop.
void MobilityCourseChangeTrace(Ptr< const MobilityModel > mob)
Mobility course change trace function.
void EnableWifiMacCounters(Time startTime, Time stopTime, Time pollInterval=Seconds(1))
Enable tracking of Wifi Mac Counters such as Tx, TxDrop, Rx, RxDrop.
void WriteXmlP(std::string pktType, uint32_t fId, double fbTx, double lbTx, uint32_t tId, double fbRx, double lbRx, std::string metaInfo="")
Write XMLP function.
uint32_t m_wifiMacTxDropCounterId
wifi MAC transmit drop counter ID
void WriteXmlRp(uint32_t nodeId, std::string destination, Ipv4RoutePathElements rpElements)
Write XMLRP function.
AnimUidPacketInfoMap m_pendingLrWpanPackets
pending LR-WPAN packets
void WifiMacTxTrace(std::string context, Ptr< const Packet > p)
wifi MAC transmit trace function
void ResetAnimWriteCallback()
Reset the write callback function.
void LrWpanMacTxDropTrace(std::string context, Ptr< const Packet > p)
LR-WPAN MAC transmit drop trace function.
void LrWpanMacRxTrace(std::string context, Ptr< const Packet > p)
LR-WPAN MAC receive trace function.
std::vector< std::string > m_nodeCounters
node counters
void WriteXmlNode(uint32_t id, uint32_t sysId, double locX, double locY)
Write XML node function.
AnimWriteCallback m_writeCallback
write callback
NodeCounterMap64 m_nodeWifiMacTxDrop
node wifi MAC transmit drop
uint64_t m_currentPktCount
current packet count
std::string GetIpv4RoutingTable(Ptr< Node > n)
Get IPv4 routing table function.
void Ipv4TxTrace(std::string context, Ptr< const Packet > p, Ptr< Ipv4 > ipv4, uint32_t interfaceIndex)
IPv4 transmit trace function.
std::pair< uint32_t, std::string > NodeIdIpv4Pair
NodeIdIpv4Pair typedef.
void EnqueueTrace(std::string context, Ptr< const Packet >)
Enqueue trace function.
uint64_t GetTracePktCount() const
Get trace file packet count (This used only for testing)
void WriteXmlUpdateNodeColor(uint32_t nodeId, uint8_t r, uint8_t g, uint8_t b)
Write XML update node color function.
Vector UpdatePosition(Ptr< Node > n)
Update position function.
std::string m_outputFileName
output file name
void WriteIpv6Addresses()
Write IPv6 Addresses function.
void AddPendingPacket(ProtocolType protocolType, uint64_t animUid, AnimPacketInfo pktInfo)
Add pending packet function.
NodeCounterMap64 m_nodeWifiPhyRxDrop
node wifi Phy receive drop
void WriteXmlIpv4Addresses(uint32_t nodeId, std::vector< std::string > ipv4Addresses)
Write XML Ipv4 addresses function.
Vector GetPosition(Ptr< Node > n)
Get position function.
AnimUidPacketInfoMap m_pendingLtePackets
pending LTE packets
void SetBackgroundImage(std::string fileName, double x, double y, double scaleX, double scaleY, double opacity)
Helper function to set the background image.
void WriteNodes()
Write nodes function.
NodeCounterMap64 m_nodeLrWpanMacRxDrop
node LR-WPAN MAC receive drop
Time m_wifiMacCountersStopTime
wifi MAC counters stop time
void WriteNodeColors()
Write node colors function.
void RecursiveIpv4RoutePathSearch(std::string from, std::string to, Ipv4RoutePathElements &rpElements)
Recursive IPv4 route path search function.
static bool IsInitialized()
Check if AnimationInterface is initialized.
void LrWpanMacTxTrace(std::string context, Ptr< const Packet > p)
LR-WPAN MAC transmit trace function.
void WriteXmlUpdateBackground(std::string fileName, double x, double y, double scaleX, double scaleY, double opacity)
Write XML update background function.
void CsmaPhyTxEndTrace(std::string context, Ptr< const Packet > p)
CSMA Phy transmit end trace function.
void WriteXmlUpdateNodeSize(uint32_t nodeId, double width, double height)
Write XML update node size function.
uint32_t m_remainingEnergyCounterId
remaining energy counter ID
void WriteXmlUpdateNodeImage(uint32_t nodeId, uint32_t resourceId)
Write XML update node image function.
uint32_t m_wifiMacRxDropCounterId
wifi MAC receive drop counter ID
void TrackWifiMacCounters()
Track wifi MAC counters function.
void WriteNodeUpdate(uint32_t nodeId)
Write node update function.
std::string m_originalFileName
original file name
void UpdateNodeDescription(Ptr< Node > n, std::string descr)
Helper function to update the description for a given node.
void UpdateNodeColor(Ptr< Node > n, uint8_t r, uint8_t g, uint8_t b)
Helper function to update the node color.
static void SetConstantPosition(Ptr< Node > n, double x, double y, double z=0)
Helper function to set Constant Position for a given node.
NodeCounterMap64 m_nodeQueueDequeue
node queue dequeue
void WifiPhyTxDropTrace(std::string context, Ptr< const Packet > p)
wifi Phy transmit drop trace function
uint32_t m_wifiPhyRxDropCounterId
wifi Phy receive drop counter ID
void WriteXmlUpdateLink(uint32_t fromId, uint32_t toId, std::string linkDescription)
Write XML update link counter function.
void ConnectLteEnb(Ptr< Node > n, Ptr< LteEnbNetDevice > nd, uint32_t devIndex)
Connect LTE ENB function.
void GenericWirelessRxTrace(std::string context, Ptr< const Packet > p, ProtocolType protocolType)
Generic wireless receive trace function.
std::string GetPacketMetadata(Ptr< const Packet > p)
Get packet metadata function.
uint32_t m_wifiPhyTxDropCounterId
wifi Phy transmit drop counter ID
std::vector< Ipv4RouteTrackElement > m_ipv4RouteTrackElements
IPv route track elements.
std::multimap< uint32_t, std::string > NodeIdIpv4Map
NodeIdIpv4Map typedef.
void EnableQueueCounters(Time startTime, Time stopTime, Time pollInterval=Seconds(1))
Enable tracking of Queue Counters such as Enqueue, Dequeue, Queue Drops.
uint32_t m_ipv4L3ProtocolDropCounterId
IPv4 protocol drop counter ID.
Time m_wifiPhyCountersStopTime
wifi Phy counters stop time
Time m_mobilityPollInterval
mobility poll interval
void OutputWirelessPacketRxInfo(Ptr< const Packet > p, AnimPacketInfo &pktInfo, uint64_t animUid)
Output wireless packet receive info.
std::map< std::string, uint32_t > m_ipv4ToNodeIdMap
IPv4 to node ID map.
AnimUidPacketInfoMap m_pendingCsmaPackets
pending CSMA packets
std::vector< std::string > m_resources
resources
void TrackIpv4L3ProtocolCounters()
Track IPv4 L3 protocol counters function.
void WriteXmlUpdateNodePosition(uint32_t nodeId, double x, double y)
Write XML update node position function.
void StartAnimation(bool restart=false)
Start animation function.
void DevTxTrace(std::string context, Ptr< const Packet > p, Ptr< NetDevice > tx, Ptr< NetDevice > rx, Time txTime, Time rxTime)
Device transmit trace function.
std::string GetIpv4Address(Ptr< NetDevice > nd)
Get IPv4 address.
void WifiMacRxTrace(std::string context, Ptr< const Packet > p)
wifi MAC receive trace function
bool IsStarted() const
Is AnimationInterface started.
void WriteXmlIpv6Addresses(uint32_t nodeId, std::vector< std::string > ipv6Addresses)
Write XML Ipv6 addresses function.
NodeContainer m_routingNc
routing node container
void SetAnimWriteCallback(AnimWriteCallback cb)
Set a callback function to listen to AnimationInterface write events.
void QueueDropTrace(std::string context, Ptr< const Packet >)
Queue trace function.
void WriteXmlLink(uint32_t fromId, uint32_t toLp, uint32_t toId)
Write XML link counter function.
std::map< uint64_t, AnimPacketInfo > AnimUidPacketInfoMap
AnimUidPacketInfoMap typedef.
Packet header for IPv4.
Definition ipv4-header.h:23
DropReason
Reason why a packet has been dropped.
an EUI-48 address
keep track of a set of node pointers.
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:67
a 2d rectangle
Definition rectangle.h:24
read and write tag data
Definition tag-buffer.h:41
tag a set of bytes in a packet
Definition tag.h:28
Simulation virtual time values and global simulation resolution.
Definition nstime.h:96
a unique identifier for an interface.
Definition type-id.h:49
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
Time stopTime
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1369
WifiPhyRxfailureReason
Enumeration of the possible reception failure reasons.
Definition first.py:1
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::map< WifiSpectrumBandInfo, Watt_u > RxPowerWattPerChannelBand
A map of the received power for each band.
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
Definition wifi-ppdu.h:38
uint8_t data[writeSize]