author | Peter D. Barnes, Jr. <barnes26@llnl.gov> |
Wed, 14 Nov 2012 00:03:41 -0800 | |
branch | ptl |
changeset 9768 | bee4f4bf5044 |
parent 9763 | 038d5627c5a9 |
child 9871 | 90c92578f680 |
permissions | -rw-r--r-- |
150
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
9
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
2 |
/* |
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
3 |
* Copyright (c) 2005,2006 INRIA |
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
4 |
* |
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License version 2 as |
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation; |
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
8 |
* |
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
13 |
* |
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
17 |
* |
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
18 |
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
19 |
*/ |
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
20 |
#ifndef PACKET_H |
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
21 |
#define PACKET_H |
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
22 |
|
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
23 |
#include <stdint.h> |
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
24 |
#include "buffer.h" |
104 | 25 |
#include "header.h" |
107
2cbaa2a1b116
add trailer
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
106
diff
changeset
|
26 |
#include "trailer.h" |
882
777fcfabc1c8
rename packet-history.h to packet-metadata.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
880
diff
changeset
|
27 |
#include "packet-metadata.h" |
3041
a624276a897b
mtag -> tag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3040
diff
changeset
|
28 |
#include "tag.h" |
4502 | 29 |
#include "byte-tag-list.h" |
30 |
#include "packet-tag-list.h" |
|
5224
06f639d05b8f
Merge NixVector Routing code
Josh Pelkey <jpelkey@gatech.edu>
parents:
5074
diff
changeset
|
31 |
#include "nix-vector.h" |
14
6dd7d31c6fc3
replace yans include with ns3 include
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
9
diff
changeset
|
32 |
#include "ns3/callback.h" |
463
c2082308e01a
merge Packet API changes needed for Packet pretty printing.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
239
diff
changeset
|
33 |
#include "ns3/assert.h" |
1865
829dc1815014
add Packet::Ref/Unref methods
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1360
diff
changeset
|
34 |
#include "ns3/ptr.h" |
5751
b50011dc95b1
mark Packet::PeekData deprecated
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
5505
diff
changeset
|
35 |
#include "ns3/deprecated.h" |
9
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
36 |
|
16
99e833adbb46
change yans namespace to ns3
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
14
diff
changeset
|
37 |
namespace ns3 { |
9
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
38 |
|
79
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
39 |
/** |
7149
87514e0d866b
Fix doxygen groups for some new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
6823
diff
changeset
|
40 |
* \ingroup network |
3222
f61c17b62fd1
bug 202: classes disappeared from doxygen output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3193
diff
changeset
|
41 |
* \defgroup packet Packet |
f61c17b62fd1
bug 202: classes disappeared from doxygen output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3193
diff
changeset
|
42 |
*/ |
f61c17b62fd1
bug 202: classes disappeared from doxygen output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3193
diff
changeset
|
43 |
|
f61c17b62fd1
bug 202: classes disappeared from doxygen output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3193
diff
changeset
|
44 |
/** |
f61c17b62fd1
bug 202: classes disappeared from doxygen output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3193
diff
changeset
|
45 |
* \ingroup packet |
9763
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
46 |
* \brief Iterator over the set of byte tags in a packet |
3036
8e29fb88ad26
add a couple of dox comments
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3035
diff
changeset
|
47 |
* |
8e29fb88ad26
add a couple of dox comments
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3035
diff
changeset
|
48 |
* This is a java-style iterator. |
3035
644bfc099992
a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
49 |
*/ |
4502 | 50 |
class ByteTagIterator |
3035
644bfc099992
a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
51 |
{ |
644bfc099992
a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
52 |
public: |
644bfc099992
a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
53 |
/** |
9763
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
54 |
* Identifies a byte tag and a set of bytes within a packet |
3035
644bfc099992
a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
55 |
* to which the tag applies. |
644bfc099992
a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
56 |
*/ |
644bfc099992
a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
57 |
class Item |
644bfc099992
a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
58 |
{ |
6397
a1608a9a11f3
run check-style.py
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
6132
diff
changeset
|
59 |
public: |
3035
644bfc099992
a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
60 |
/** |
644bfc099992
a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
61 |
* \returns the ns3::TypeId associated to this tag. |
644bfc099992
a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
62 |
*/ |
644bfc099992
a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
63 |
TypeId GetTypeId (void) const; |
644bfc099992
a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
64 |
/** |
644bfc099992
a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
65 |
* \returns the index of the first byte tagged by this tag. |
644bfc099992
a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
66 |
* |
644bfc099992
a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
67 |
* The index is an offset from the start of the packet. |
644bfc099992
a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
68 |
*/ |
644bfc099992
a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
69 |
uint32_t GetStart (void) const; |
644bfc099992
a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
70 |
/** |
644bfc099992
a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
71 |
* \returns the index of the last byte tagged by this tag. |
644bfc099992
a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
72 |
* |
644bfc099992
a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
73 |
* The index is an offset from the start of the packet. |
644bfc099992
a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
74 |
*/ |
644bfc099992
a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
75 |
uint32_t GetEnd (void) const; |
644bfc099992
a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
76 |
/** |
9763
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
77 |
* Read the requested tag and store it in the user-provided tag instance. |
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
78 |
* |
3035
644bfc099992
a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
79 |
* \param tag the user tag to which the data should be copied. |
644bfc099992
a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
80 |
* |
9763
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
81 |
* This method will crash if the type of the tag provided |
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
82 |
* by the user does not match the type of the underlying tag. |
3035
644bfc099992
a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
83 |
*/ |
3040
e11e106c7c19
Mtag -> Tag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3039
diff
changeset
|
84 |
void GetTag (Tag &tag) const; |
6397
a1608a9a11f3
run check-style.py
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
6132
diff
changeset
|
85 |
private: |
4502 | 86 |
friend class ByteTagIterator; |
3040
e11e106c7c19
Mtag -> Tag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3039
diff
changeset
|
87 |
Item (TypeId tid, uint32_t start, uint32_t end, TagBuffer buffer); |
3035
644bfc099992
a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
88 |
TypeId m_tid; |
644bfc099992
a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
89 |
uint32_t m_start; |
644bfc099992
a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
90 |
uint32_t m_end; |
3040
e11e106c7c19
Mtag -> Tag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3039
diff
changeset
|
91 |
TagBuffer m_buffer; |
3035
644bfc099992
a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
92 |
}; |
3036
8e29fb88ad26
add a couple of dox comments
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3035
diff
changeset
|
93 |
/** |
8e29fb88ad26
add a couple of dox comments
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3035
diff
changeset
|
94 |
* \returns true if calling Next is safe, false otherwise. |
8e29fb88ad26
add a couple of dox comments
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3035
diff
changeset
|
95 |
*/ |
3035
644bfc099992
a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
96 |
bool HasNext (void) const; |
3036
8e29fb88ad26
add a couple of dox comments
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3035
diff
changeset
|
97 |
/** |
8e29fb88ad26
add a couple of dox comments
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3035
diff
changeset
|
98 |
* \returns the next item found and prepare for the next one. |
8e29fb88ad26
add a couple of dox comments
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3035
diff
changeset
|
99 |
*/ |
3035
644bfc099992
a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
100 |
Item Next (void); |
644bfc099992
a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
101 |
private: |
644bfc099992
a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
102 |
friend class Packet; |
4502 | 103 |
ByteTagIterator (ByteTagList::Iterator i); |
104 |
ByteTagList::Iterator m_current; |
|
105 |
}; |
|
106 |
||
107 |
/** |
|
108 |
* \ingroup packet |
|
9763
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
109 |
* \brief Iterator over the set of packet tags in a packet |
4502 | 110 |
* |
111 |
* This is a java-style iterator. |
|
112 |
*/ |
|
113 |
class PacketTagIterator |
|
114 |
{ |
|
115 |
public: |
|
116 |
/** |
|
9763
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
117 |
* Identifies a packet tag within a packet. |
4502 | 118 |
*/ |
119 |
class Item |
|
120 |
{ |
|
6397
a1608a9a11f3
run check-style.py
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
6132
diff
changeset
|
121 |
public: |
4502 | 122 |
/** |
123 |
* \returns the ns3::TypeId associated to this tag. |
|
124 |
*/ |
|
125 |
TypeId GetTypeId (void) const; |
|
126 |
/** |
|
9763
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
127 |
* Read the requested tag and store it in the user-provided tag instance. |
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
128 |
* |
4502 | 129 |
* \param tag the user tag to which the data should be copied. |
130 |
* |
|
9763
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
131 |
* This method will crash if the type of the tag provided |
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
132 |
* by the user does not match the type of the underlying tag. |
4502 | 133 |
*/ |
134 |
void GetTag (Tag &tag) const; |
|
6397
a1608a9a11f3
run check-style.py
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
6132
diff
changeset
|
135 |
private: |
4502 | 136 |
friend class PacketTagIterator; |
137 |
Item (const struct PacketTagList::TagData *data); |
|
138 |
const struct PacketTagList::TagData *m_data; |
|
139 |
}; |
|
140 |
/** |
|
141 |
* \returns true if calling Next is safe, false otherwise. |
|
142 |
*/ |
|
143 |
bool HasNext (void) const; |
|
144 |
/** |
|
145 |
* \returns the next item found and prepare for the next one. |
|
146 |
*/ |
|
147 |
Item Next (void); |
|
148 |
private: |
|
149 |
friend class Packet; |
|
150 |
PacketTagIterator (const struct PacketTagList::TagData *head); |
|
151 |
const struct PacketTagList::TagData *m_current; |
|
3035
644bfc099992
a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
152 |
}; |
644bfc099992
a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
153 |
|
644bfc099992
a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
154 |
/** |
3222
f61c17b62fd1
bug 202: classes disappeared from doxygen output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3193
diff
changeset
|
155 |
* \ingroup packet |
79
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
156 |
* \brief network packets |
80
3706b1172ab9
start of rationale for packets
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
79
diff
changeset
|
157 |
* |
4502 | 158 |
* Each network packet contains a byte buffer, a set of byte tags, a set of |
159 |
* packet tags, and metadata. |
|
1131
7d0c498c311a
improve dox
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
897
diff
changeset
|
160 |
* |
106
9b7cf31baf8c
remove chunk
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
104
diff
changeset
|
161 |
* - The byte buffer stores the serialized content of the headers and trailers |
9b7cf31baf8c
remove chunk
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
104
diff
changeset
|
162 |
* added to a packet. The serialized representation of these headers is expected |
80
3706b1172ab9
start of rationale for packets
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
79
diff
changeset
|
163 |
* to match that of real network packets bit for bit (although nothing |
3706b1172ab9
start of rationale for packets
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
79
diff
changeset
|
164 |
* forces you to do this) which means that the content of a packet buffer |
3706b1172ab9
start of rationale for packets
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
79
diff
changeset
|
165 |
* is expected to be that of a real packet. |
1131
7d0c498c311a
improve dox
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
897
diff
changeset
|
166 |
* |
7d0c498c311a
improve dox
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
897
diff
changeset
|
167 |
* - The metadata describes the type of the headers and trailers which |
7d0c498c311a
improve dox
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
897
diff
changeset
|
168 |
* were serialized in the byte buffer. The maintenance of metadata is |
7d0c498c311a
improve dox
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
897
diff
changeset
|
169 |
* optional and disabled by default. To enable it, you must call |
4507
7b4adb81e21e
remove dead reference to EnableMetadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4503
diff
changeset
|
170 |
* Packet::EnablePrinting and this will allow you to get non-empty |
7600
57ba46094a0d
fix various doxygen errors
Vedran Miletić <rivanvx@gmail.com>
parents:
7256
diff
changeset
|
171 |
* output from Packet::Print. If you wish to only enable |
4507
7b4adb81e21e
remove dead reference to EnableMetadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4503
diff
changeset
|
172 |
* checking of metadata, and do not need any printing capability, you can |
7600
57ba46094a0d
fix various doxygen errors
Vedran Miletić <rivanvx@gmail.com>
parents:
7256
diff
changeset
|
173 |
* call Packet::EnableChecking: its runtime cost is lower than |
57ba46094a0d
fix various doxygen errors
Vedran Miletić <rivanvx@gmail.com>
parents:
7256
diff
changeset
|
174 |
* Packet::EnablePrinting. |
1131
7d0c498c311a
improve dox
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
897
diff
changeset
|
175 |
* |
4502 | 176 |
* - The set of tags contain simulation-specific information which cannot |
177 |
* be stored in the packet byte buffer because the protocol headers or trailers |
|
178 |
* have no standard-conformant field for this information. So-called |
|
179 |
* 'byte' tags are used to tag a subset of the bytes in the packet byte buffer |
|
180 |
* while 'packet' tags are used to tag the packet itself. The main difference |
|
181 |
* between these two kinds of tags is what happens when packets are copied, |
|
182 |
* fragmented, and reassembled: 'byte' tags follow bytes while 'packet' tags |
|
4503
d70501bf2b14
update documentation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4502
diff
changeset
|
183 |
* follow packets. Another important difference between these two kinds of tags |
d70501bf2b14
update documentation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4502
diff
changeset
|
184 |
* is that byte tags cannot be removed and are expected to be written once, |
d70501bf2b14
update documentation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4502
diff
changeset
|
185 |
* and read many times, while packet tags are expected to be written once, |
d70501bf2b14
update documentation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4502
diff
changeset
|
186 |
* read many times, and removed exactly once. An example of a 'byte' |
d70501bf2b14
update documentation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4502
diff
changeset
|
187 |
* tag is a FlowIdTag which contains a flow id and is set by the application |
d70501bf2b14
update documentation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4502
diff
changeset
|
188 |
* generating traffic. An example of a 'packet' tag is a cross-layer |
d70501bf2b14
update documentation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4502
diff
changeset
|
189 |
* qos class id set by an application and processed by a lower-level MAC |
d70501bf2b14
update documentation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4502
diff
changeset
|
190 |
* layer. |
4502 | 191 |
* |
1131
7d0c498c311a
improve dox
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
897
diff
changeset
|
192 |
* Implementing a new type of Header or Trailer for a new protocol is |
7d0c498c311a
improve dox
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
897
diff
changeset
|
193 |
* pretty easy and is a matter of creating a subclass of the ns3::Header |
1246
b9a73908ce00
beautify packet API doxygen
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1241
diff
changeset
|
194 |
* or of the ns3::Trailer base class, and implementing the methods |
b9a73908ce00
beautify packet API doxygen
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1241
diff
changeset
|
195 |
* described in their respective API documentation. |
1131
7d0c498c311a
improve dox
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
897
diff
changeset
|
196 |
* |
7d0c498c311a
improve dox
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
897
diff
changeset
|
197 |
* Implementing a new type of Tag requires roughly the same amount of |
1246
b9a73908ce00
beautify packet API doxygen
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1241
diff
changeset
|
198 |
* work and this work is described in the ns3::Tag API documentation. |
81
80856bb1e1e8
add high-level intro to Packet API and implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
80
diff
changeset
|
199 |
* |
9763
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
200 |
* The performance aspects copy-on-write semantics of the |
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
201 |
* Packet API are discussed in \ref packetperf |
79
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
202 |
*/ |
5505
c0ac392289c3
replace RefCountBase with SimpleRefCount<> to avoid duplicate refcounting implementations.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
5492
diff
changeset
|
203 |
class Packet : public SimpleRefCount<Packet> |
2630
17b545238ab3
do not use ObjectBase as a base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2370
diff
changeset
|
204 |
{ |
9
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
205 |
public: |
9768
bee4f4bf5044
Undo whitespace-only changes, to ease review
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9763
diff
changeset
|
206 |
|
150
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
207 |
/** |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
208 |
* Create an empty packet with a new uid (as returned |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
209 |
* by getUid). |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
210 |
*/ |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
211 |
Packet (); |
3046
a03270ebc161
test self-assignment of packets
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3045
diff
changeset
|
212 |
Packet (const Packet &o); |
6397
a1608a9a11f3
run check-style.py
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
6132
diff
changeset
|
213 |
Packet &operator = (const Packet &o); |
150
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
214 |
/** |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
215 |
* Create a packet with a zero-filled payload. |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
216 |
* The memory necessary for the payload is not allocated: |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
217 |
* it will be allocated at any later point if you attempt |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
218 |
* to fragment this packet or to access the zero-filled |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
219 |
* bytes. The packet is allocated with a new uid (as |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
220 |
* returned by getUid). |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
221 |
* |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
222 |
* \param size the size of the zero-filled payload |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
223 |
*/ |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
224 |
Packet (uint32_t size); |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
225 |
/** |
6113
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
5939
diff
changeset
|
226 |
* Create a new packet from the serialized buffer. This new packet |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
5939
diff
changeset
|
227 |
* is identical to the serialized packet contained in the buffer |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
5939
diff
changeset
|
228 |
* and is magically deserialized for you |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
5939
diff
changeset
|
229 |
* |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
5939
diff
changeset
|
230 |
* \param buffer the serialized packet to be created |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
5939
diff
changeset
|
231 |
* \param size the size of the packet for deserialization |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
5939
diff
changeset
|
232 |
* \param magic allows packet deserialization; |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
5939
diff
changeset
|
233 |
* asserts when set to false |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
5939
diff
changeset
|
234 |
*/ |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
5939
diff
changeset
|
235 |
Packet (uint8_t const*buffer, uint32_t size, bool magic); |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
5939
diff
changeset
|
236 |
/** |
239
e194d619534b
add packet constructor which accepts payload buffer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
150
diff
changeset
|
237 |
* Create a packet with payload filled with the content |
e194d619534b
add packet constructor which accepts payload buffer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
150
diff
changeset
|
238 |
* of this buffer. The input data is copied: the input |
e194d619534b
add packet constructor which accepts payload buffer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
150
diff
changeset
|
239 |
* buffer is untouched. |
e194d619534b
add packet constructor which accepts payload buffer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
150
diff
changeset
|
240 |
* |
e194d619534b
add packet constructor which accepts payload buffer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
150
diff
changeset
|
241 |
* \param buffer the data to store in the packet. |
e194d619534b
add packet constructor which accepts payload buffer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
150
diff
changeset
|
242 |
* \param size the size of the input buffer. |
e194d619534b
add packet constructor which accepts payload buffer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
150
diff
changeset
|
243 |
*/ |
e194d619534b
add packet constructor which accepts payload buffer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
150
diff
changeset
|
244 |
Packet (uint8_t const*buffer, uint32_t size); |
e194d619534b
add packet constructor which accepts payload buffer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
150
diff
changeset
|
245 |
/** |
150
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
246 |
* Create a new packet which contains a fragment of the original |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
247 |
* packet. The returned packet shares the same uid as this packet. |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
248 |
* |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
249 |
* \param start offset from start of packet to start of fragment to create |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
250 |
* \param length length of fragment to create |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
251 |
* \returns a fragment of the original packet |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
252 |
*/ |
1865
829dc1815014
add Packet::Ref/Unref methods
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1360
diff
changeset
|
253 |
Ptr<Packet> CreateFragment (uint32_t start, uint32_t length) const; |
150
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
254 |
/** |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
255 |
* \returns the size in bytes of the packet (including the zero-filled |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
256 |
* initial payload) |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
257 |
*/ |
6132
cd1902faafb9
inline to optimized iperf
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
6113
diff
changeset
|
258 |
inline uint32_t GetSize (void) const; |
150
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
259 |
/** |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
260 |
* Add header to this packet. This method invokes the |
3364
8e6ac6061680
implement Packet::PeekHeader and Packet::PeekTrailer to avoid evil workarounds when receiving tcp packets.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3224
diff
changeset
|
261 |
* Header::GetSerializedSize and Header::Serialize |
463
c2082308e01a
merge Packet API changes needed for Packet pretty printing.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
239
diff
changeset
|
262 |
* methods to reserve space in the buffer and request the |
c2082308e01a
merge Packet API changes needed for Packet pretty printing.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
239
diff
changeset
|
263 |
* header to serialize itself in the packet buffer. |
150
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
264 |
* |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
265 |
* \param header a reference to the header to add to this packet. |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
266 |
*/ |
2663
dc5314da50aa
remove template methods.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2639
diff
changeset
|
267 |
void AddHeader (const Header & header); |
150
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
268 |
/** |
463
c2082308e01a
merge Packet API changes needed for Packet pretty printing.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
239
diff
changeset
|
269 |
* Deserialize and remove the header from the internal buffer. |
3364
8e6ac6061680
implement Packet::PeekHeader and Packet::PeekTrailer to avoid evil workarounds when receiving tcp packets.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3224
diff
changeset
|
270 |
* This method invokes Header::Deserialize. |
150
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
271 |
* |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
272 |
* \param header a reference to the header to remove from the internal buffer. |
463
c2082308e01a
merge Packet API changes needed for Packet pretty printing.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
239
diff
changeset
|
273 |
* \returns the number of bytes removed from the packet. |
150
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
274 |
*/ |
2663
dc5314da50aa
remove template methods.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2639
diff
changeset
|
275 |
uint32_t RemoveHeader (Header &header); |
150
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
276 |
/** |
3364
8e6ac6061680
implement Packet::PeekHeader and Packet::PeekTrailer to avoid evil workarounds when receiving tcp packets.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3224
diff
changeset
|
277 |
* Deserialize but does _not_ remove the header from the internal buffer. |
8e6ac6061680
implement Packet::PeekHeader and Packet::PeekTrailer to avoid evil workarounds when receiving tcp packets.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3224
diff
changeset
|
278 |
* This method invokes Header::Deserialize. |
8e6ac6061680
implement Packet::PeekHeader and Packet::PeekTrailer to avoid evil workarounds when receiving tcp packets.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3224
diff
changeset
|
279 |
* |
8e6ac6061680
implement Packet::PeekHeader and Packet::PeekTrailer to avoid evil workarounds when receiving tcp packets.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3224
diff
changeset
|
280 |
* \param header a reference to the header to read from the internal buffer. |
8e6ac6061680
implement Packet::PeekHeader and Packet::PeekTrailer to avoid evil workarounds when receiving tcp packets.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3224
diff
changeset
|
281 |
* \returns the number of bytes read from the packet. |
6397
a1608a9a11f3
run check-style.py
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
6132
diff
changeset
|
282 |
*/ |
3738
011897c60e9c
bug 331: constify Packet::PeekHeader
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3553
diff
changeset
|
283 |
uint32_t PeekHeader (Header &header) const; |
3364
8e6ac6061680
implement Packet::PeekHeader and Packet::PeekTrailer to avoid evil workarounds when receiving tcp packets.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3224
diff
changeset
|
284 |
/** |
150
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
285 |
* Add trailer to this packet. This method invokes the |
3364
8e6ac6061680
implement Packet::PeekHeader and Packet::PeekTrailer to avoid evil workarounds when receiving tcp packets.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3224
diff
changeset
|
286 |
* Trailer::GetSerializedSize and Trailer::Serialize |
463
c2082308e01a
merge Packet API changes needed for Packet pretty printing.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
239
diff
changeset
|
287 |
* methods to reserve space in the buffer and request the trailer |
c2082308e01a
merge Packet API changes needed for Packet pretty printing.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
239
diff
changeset
|
288 |
* to serialize itself in the packet buffer. |
150
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
289 |
* |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
290 |
* \param trailer a reference to the trailer to add to this packet. |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
291 |
*/ |
2663
dc5314da50aa
remove template methods.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2639
diff
changeset
|
292 |
void AddTrailer (const Trailer &trailer); |
150
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
293 |
/** |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
294 |
* Remove a deserialized trailer from the internal buffer. |
1246
b9a73908ce00
beautify packet API doxygen
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1241
diff
changeset
|
295 |
* This method invokes the Deserialize method. |
150
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
296 |
* |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
297 |
* \param trailer a reference to the trailer to remove from the internal buffer. |
463
c2082308e01a
merge Packet API changes needed for Packet pretty printing.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
239
diff
changeset
|
298 |
* \returns the number of bytes removed from the end of the packet. |
150
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
299 |
*/ |
2663
dc5314da50aa
remove template methods.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2639
diff
changeset
|
300 |
uint32_t RemoveTrailer (Trailer &trailer); |
150
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
301 |
/** |
3364
8e6ac6061680
implement Packet::PeekHeader and Packet::PeekTrailer to avoid evil workarounds when receiving tcp packets.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3224
diff
changeset
|
302 |
* Deserialize but does _not_ remove a trailer from the internal buffer. |
8e6ac6061680
implement Packet::PeekHeader and Packet::PeekTrailer to avoid evil workarounds when receiving tcp packets.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3224
diff
changeset
|
303 |
* This method invokes the Trailer::Deserialize method. |
8e6ac6061680
implement Packet::PeekHeader and Packet::PeekTrailer to avoid evil workarounds when receiving tcp packets.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3224
diff
changeset
|
304 |
* |
8e6ac6061680
implement Packet::PeekHeader and Packet::PeekTrailer to avoid evil workarounds when receiving tcp packets.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3224
diff
changeset
|
305 |
* \param trailer a reference to the trailer to read from the internal buffer. |
8e6ac6061680
implement Packet::PeekHeader and Packet::PeekTrailer to avoid evil workarounds when receiving tcp packets.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3224
diff
changeset
|
306 |
* \returns the number of bytes read from the end of the packet. |
8e6ac6061680
implement Packet::PeekHeader and Packet::PeekTrailer to avoid evil workarounds when receiving tcp packets.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3224
diff
changeset
|
307 |
*/ |
8e6ac6061680
implement Packet::PeekHeader and Packet::PeekTrailer to avoid evil workarounds when receiving tcp packets.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3224
diff
changeset
|
308 |
uint32_t PeekTrailer (Trailer &trailer); |
1246
b9a73908ce00
beautify packet API doxygen
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1241
diff
changeset
|
309 |
|
b9a73908ce00
beautify packet API doxygen
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1241
diff
changeset
|
310 |
/** |
150
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
311 |
* Concatenate the input packet at the end of the current |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
312 |
* packet. This does not alter the uid of either packet. |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
313 |
* |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
314 |
* \param packet packet to concatenate |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
315 |
*/ |
1865
829dc1815014
add Packet::Ref/Unref methods
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1360
diff
changeset
|
316 |
void AddAtEnd (Ptr<const Packet> packet); |
150
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
317 |
/** |
463
c2082308e01a
merge Packet API changes needed for Packet pretty printing.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
239
diff
changeset
|
318 |
* \param size number of padding bytes to add. |
150
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
319 |
*/ |
463
c2082308e01a
merge Packet API changes needed for Packet pretty printing.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
239
diff
changeset
|
320 |
void AddPaddingAtEnd (uint32_t size); |
150
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
321 |
/** |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
322 |
* Remove size bytes from the end of the current packet |
9768
bee4f4bf5044
Undo whitespace-only changes, to ease review
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9763
diff
changeset
|
323 |
* It is safe to remove more bytes than are present in |
150
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
324 |
* the packet. |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
325 |
* |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
326 |
* \param size number of bytes from remove |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
327 |
*/ |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
328 |
void RemoveAtEnd (uint32_t size); |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
329 |
/** |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
330 |
* Remove size bytes from the start of the current packet. |
9763
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
331 |
* It is safe to remove more bytes than are present in |
150
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
332 |
* the packet. |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
333 |
* |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
334 |
* \param size number of bytes from remove |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
335 |
*/ |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
336 |
void RemoveAtStart (uint32_t size); |
6397
a1608a9a11f3
run check-style.py
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
6132
diff
changeset
|
337 |
|
150
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
338 |
/** |
9763
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
339 |
* \returns a pointer to the internal buffer of the packet. |
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
340 |
* |
150
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
341 |
* If you try to change the content of the buffer |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
342 |
* returned by this method, you will die. |
5751
b50011dc95b1
mark Packet::PeekData deprecated
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
5505
diff
changeset
|
343 |
* Note that this method is now deprecated and will be removed in |
9763
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
344 |
* a future version of ns-3. To get access to the content |
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
345 |
* of the byte buffer of a packet, call CopyData"()" to perform |
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
346 |
* an explicit copy. |
150
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
347 |
* |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
348 |
*/ |
9768
bee4f4bf5044
Undo whitespace-only changes, to ease review
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9763
diff
changeset
|
349 |
uint8_t const *PeekData (void) const NS_DEPRECATED; |
91
8066ef8d9274
add packet uid
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
90
diff
changeset
|
350 |
|
150
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
351 |
/** |
9763
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
352 |
* Copy the packet contents to a byte buffer. |
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
353 |
* |
3764
64f1310350e4
add API to get bytes out of a packet without calling PeekData
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3738
diff
changeset
|
354 |
* \param buffer a pointer to a byte buffer where the packet data |
64f1310350e4
add API to get bytes out of a packet without calling PeekData
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3738
diff
changeset
|
355 |
* should be copied. |
64f1310350e4
add API to get bytes out of a packet without calling PeekData
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3738
diff
changeset
|
356 |
* \param size the size of the byte buffer. |
64f1310350e4
add API to get bytes out of a packet without calling PeekData
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3738
diff
changeset
|
357 |
* \returns the number of bytes read from the packet |
64f1310350e4
add API to get bytes out of a packet without calling PeekData
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3738
diff
changeset
|
358 |
* |
9768
bee4f4bf5044
Undo whitespace-only changes, to ease review
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9763
diff
changeset
|
359 |
* No more than \b size bytes will be copied by this function. |
3764
64f1310350e4
add API to get bytes out of a packet without calling PeekData
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3738
diff
changeset
|
360 |
*/ |
64f1310350e4
add API to get bytes out of a packet without calling PeekData
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3738
diff
changeset
|
361 |
uint32_t CopyData (uint8_t *buffer, uint32_t size) const; |
64f1310350e4
add API to get bytes out of a packet without calling PeekData
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3738
diff
changeset
|
362 |
|
5939
6f9cffdc7ed0
add missing doxygen
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
5751
diff
changeset
|
363 |
/** |
9763
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
364 |
* Copy the packet contents to an output stream. |
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
365 |
* |
5939
6f9cffdc7ed0
add missing doxygen
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
5751
diff
changeset
|
366 |
* \param os pointer to output stream in which we want |
6f9cffdc7ed0
add missing doxygen
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
5751
diff
changeset
|
367 |
* to write the packet data. |
6f9cffdc7ed0
add missing doxygen
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
5751
diff
changeset
|
368 |
* \param size the maximum number of bytes we want to write |
6f9cffdc7ed0
add missing doxygen
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
5751
diff
changeset
|
369 |
* in the output stream. |
6f9cffdc7ed0
add missing doxygen
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
5751
diff
changeset
|
370 |
*/ |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7149
diff
changeset
|
371 |
void CopyData (std::ostream *os, uint32_t size) const; |
4518
31f2881aa214
avoid extra memory allocations when using PcapWriter
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4507
diff
changeset
|
372 |
|
3764
64f1310350e4
add API to get bytes out of a packet without calling PeekData
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3738
diff
changeset
|
373 |
/** |
5939
6f9cffdc7ed0
add missing doxygen
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
5751
diff
changeset
|
374 |
* \returns a COW copy of the packet. |
6f9cffdc7ed0
add missing doxygen
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
5751
diff
changeset
|
375 |
* |
9768
bee4f4bf5044
Undo whitespace-only changes, to ease review
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9763
diff
changeset
|
376 |
* The returns packet will behave like an independent copy of |
5939
6f9cffdc7ed0
add missing doxygen
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
5751
diff
changeset
|
377 |
* the original packet, even though they both share the |
6f9cffdc7ed0
add missing doxygen
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
5751
diff
changeset
|
378 |
* same datasets internally. |
6f9cffdc7ed0
add missing doxygen
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
5751
diff
changeset
|
379 |
*/ |
6f9cffdc7ed0
add missing doxygen
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
5751
diff
changeset
|
380 |
Ptr<Packet> Copy (void) const; |
6f9cffdc7ed0
add missing doxygen
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
5751
diff
changeset
|
381 |
|
6f9cffdc7ed0
add missing doxygen
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
5751
diff
changeset
|
382 |
/** |
150
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
383 |
* A packet is allocated a new uid when it is created |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
384 |
* empty or with zero-filled payload. |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
385 |
* |
1782
444ef6129d2e
Clarify pkt-uid field in doxygen
Tom Henderson <tomh@tomh.org>
parents:
1781
diff
changeset
|
386 |
* Note: This uid is an internal uid and cannot be counted on to |
444ef6129d2e
Clarify pkt-uid field in doxygen
Tom Henderson <tomh@tomh.org>
parents:
1781
diff
changeset
|
387 |
* provide an accurate counter of how many "simulated packets" of a |
444ef6129d2e
Clarify pkt-uid field in doxygen
Tom Henderson <tomh@tomh.org>
parents:
1781
diff
changeset
|
388 |
* particular protocol are in the system. It is not trivial to make |
444ef6129d2e
Clarify pkt-uid field in doxygen
Tom Henderson <tomh@tomh.org>
parents:
1781
diff
changeset
|
389 |
* this uid into such a counter, because of questions such as what |
444ef6129d2e
Clarify pkt-uid field in doxygen
Tom Henderson <tomh@tomh.org>
parents:
1781
diff
changeset
|
390 |
* should the uid be when the packet is sent over broadcast media, or |
444ef6129d2e
Clarify pkt-uid field in doxygen
Tom Henderson <tomh@tomh.org>
parents:
1781
diff
changeset
|
391 |
* when fragmentation occurs. If a user wants to trace actual packet |
444ef6129d2e
Clarify pkt-uid field in doxygen
Tom Henderson <tomh@tomh.org>
parents:
1781
diff
changeset
|
392 |
* counts, he or she should look at e.g. the IP ID field or transport |
444ef6129d2e
Clarify pkt-uid field in doxygen
Tom Henderson <tomh@tomh.org>
parents:
1781
diff
changeset
|
393 |
* sequence numbers, or other packet or frame counters at other |
444ef6129d2e
Clarify pkt-uid field in doxygen
Tom Henderson <tomh@tomh.org>
parents:
1781
diff
changeset
|
394 |
* protocol layers. |
444ef6129d2e
Clarify pkt-uid field in doxygen
Tom Henderson <tomh@tomh.org>
parents:
1781
diff
changeset
|
395 |
* |
150
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
396 |
* \returns an integer identifier which uniquely |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
397 |
* identifies this packet. |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
398 |
*/ |
6113
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
5939
diff
changeset
|
399 |
uint64_t GetUid (void) const; |
463
c2082308e01a
merge Packet API changes needed for Packet pretty printing.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
239
diff
changeset
|
400 |
|
880 | 401 |
/** |
402 |
* \param os output stream in which the data should be printed. |
|
403 |
* |
|
404 |
* Iterate over the headers and trailers present in this packet, |
|
405 |
* from the first header to the last trailer and invoke, for |
|
406 |
* each of them, the user-provided method Header::DoPrint or |
|
407 |
* Trailer::DoPrint methods. |
|
408 |
*/ |
|
463
c2082308e01a
merge Packet API changes needed for Packet pretty printing.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
239
diff
changeset
|
409 |
void Print (std::ostream &os) const; |
2639
588221b7f892
replace PacketPrinter with an iterator
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2632
diff
changeset
|
410 |
|
5939
6f9cffdc7ed0
add missing doxygen
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
5751
diff
changeset
|
411 |
/** |
6f9cffdc7ed0
add missing doxygen
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
5751
diff
changeset
|
412 |
* \returns an iterator which points to the first 'item' |
6f9cffdc7ed0
add missing doxygen
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
5751
diff
changeset
|
413 |
* stored in this buffer. Note that this iterator will point |
6f9cffdc7ed0
add missing doxygen
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
5751
diff
changeset
|
414 |
* to an empty array of items if you don't call EnablePrinting |
6f9cffdc7ed0
add missing doxygen
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
5751
diff
changeset
|
415 |
* or EnableChecking before. |
6f9cffdc7ed0
add missing doxygen
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
5751
diff
changeset
|
416 |
* |
6f9cffdc7ed0
add missing doxygen
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
5751
diff
changeset
|
417 |
* \sa EnablePrinting EnableChecking |
6f9cffdc7ed0
add missing doxygen
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
5751
diff
changeset
|
418 |
*/ |
2639
588221b7f892
replace PacketPrinter with an iterator
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2632
diff
changeset
|
419 |
PacketMetadata::ItemIterator BeginItem (void) const; |
875
4ebee6ceebb5
rename History::Enable to Packet::EnableMetadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
815
diff
changeset
|
420 |
|
880 | 421 |
/** |
422 |
* By default, packets do not keep around enough metadata to |
|
423 |
* perform the operations requested by the Print methods. If you |
|
7600
57ba46094a0d
fix various doxygen errors
Vedran Miletić <rivanvx@gmail.com>
parents:
7256
diff
changeset
|
424 |
* want to be able the Packet::Print method, |
880 | 425 |
* you need to invoke this method at least once during the |
426 |
* simulation setup and before any packet is created. |
|
3553
065488d0420c
bug 279: Packets need metadata support for printing without header checking
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3364
diff
changeset
|
427 |
*/ |
065488d0420c
bug 279: Packets need metadata support for printing without header checking
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3364
diff
changeset
|
428 |
static void EnablePrinting (void); |
065488d0420c
bug 279: Packets need metadata support for printing without header checking
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3364
diff
changeset
|
429 |
/** |
880 | 430 |
* The packet metadata is also used to perform extensive |
431 |
* sanity checks at runtime when performing operations on a |
|
432 |
* Packet. For example, this metadata is used to verify that |
|
433 |
* when you remove a header from a packet, this same header |
|
434 |
* was actually present at the front of the packet. These |
|
435 |
* errors will be detected and will abort the program. |
|
436 |
*/ |
|
3553
065488d0420c
bug 279: Packets need metadata support for printing without header checking
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3364
diff
changeset
|
437 |
static void EnableChecking (void); |
1138
27245d50e5e0
use CreateFullCopy and implement Serialize/Deserialize
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1136
diff
changeset
|
438 |
|
1142
ff8f4a2efc6b
add doxygen documentation, constify
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1138
diff
changeset
|
439 |
/** |
9763
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
440 |
* \returns number of bytes required for packet |
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
441 |
* serialization |
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
442 |
* |
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
443 |
* For packet serialization, the total size is checked |
6113
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
5939
diff
changeset
|
444 |
* in order to determine the size of the buffer |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
5939
diff
changeset
|
445 |
* required for serialization |
1142
ff8f4a2efc6b
add doxygen documentation, constify
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1138
diff
changeset
|
446 |
*/ |
6113
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
5939
diff
changeset
|
447 |
uint32_t GetSerializedSize (void) const; |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
5939
diff
changeset
|
448 |
|
9763
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
449 |
/** |
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
450 |
* Serialize a packet, tags, and metadata into a byte buffer. |
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
451 |
* |
6113
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
5939
diff
changeset
|
452 |
* \param buffer a raw byte buffer to which the packet will be serialized |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
5939
diff
changeset
|
453 |
* \param maxSize the max size of the buffer for bounds checking |
1142
ff8f4a2efc6b
add doxygen documentation, constify
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1138
diff
changeset
|
454 |
* |
9763
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
455 |
* \returns one if all data were serialized, zero if buffer size was too small. |
1142
ff8f4a2efc6b
add doxygen documentation, constify
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1138
diff
changeset
|
456 |
*/ |
6113
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
5939
diff
changeset
|
457 |
uint32_t Serialize (uint8_t* buffer, uint32_t maxSize) const; |
3035
644bfc099992
a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
458 |
|
644bfc099992
a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
459 |
/** |
9763
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
460 |
* Tag each byte included in this packet with a new byte tag. |
3035
644bfc099992
a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
461 |
* |
9763
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
462 |
* \param tag the new tag to add to this packet |
3039
722cf749a9e3
remove now-unused Tags class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3036
diff
changeset
|
463 |
* |
722cf749a9e3
remove now-unused Tags class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3036
diff
changeset
|
464 |
* Note that adding a tag is a const operation which is pretty |
722cf749a9e3
remove now-unused Tags class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3036
diff
changeset
|
465 |
* un-intuitive. The rationale is that the content and behavior of |
722cf749a9e3
remove now-unused Tags class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3036
diff
changeset
|
466 |
* a packet is _not_ changed when a tag is added to a packet: any |
722cf749a9e3
remove now-unused Tags class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3036
diff
changeset
|
467 |
* code which was not aware of the new tag is going to work just |
722cf749a9e3
remove now-unused Tags class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3036
diff
changeset
|
468 |
* the same if the new tag is added. The real reason why adding a |
722cf749a9e3
remove now-unused Tags class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3036
diff
changeset
|
469 |
* tag was made a const operation is to allow a trace sink which gets |
722cf749a9e3
remove now-unused Tags class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3036
diff
changeset
|
470 |
* a packet to tag the packet, even if the packet is const (and most |
722cf749a9e3
remove now-unused Tags class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3036
diff
changeset
|
471 |
* trace sources should use const packets because it would be |
722cf749a9e3
remove now-unused Tags class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3036
diff
changeset
|
472 |
* totally evil to allow a trace sink to modify the content of a |
722cf749a9e3
remove now-unused Tags class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3036
diff
changeset
|
473 |
* packet). |
3035
644bfc099992
a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
474 |
*/ |
4502 | 475 |
void AddByteTag (const Tag &tag) const; |
3035
644bfc099992
a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
476 |
/** |
4502 | 477 |
* \returns an iterator over the set of byte tags included in this packet. |
3035
644bfc099992
a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
478 |
*/ |
4502 | 479 |
ByteTagIterator GetByteTagIterator (void) const; |
3035
644bfc099992
a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
480 |
/** |
9763
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
481 |
* \param tag the byte tag type to search in this packet |
3035
644bfc099992
a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
482 |
* \returns true if the requested tag type was found, false otherwise. |
644bfc099992
a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
483 |
* |
644bfc099992
a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
484 |
* If the requested tag type is found, it is copied in the user's |
644bfc099992
a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
485 |
* provided tag instance. |
644bfc099992
a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
486 |
*/ |
4502 | 487 |
bool FindFirstMatchingByteTag (Tag &tag) const; |
3035
644bfc099992
a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
488 |
|
3039
722cf749a9e3
remove now-unused Tags class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3036
diff
changeset
|
489 |
/** |
9763
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
490 |
* Remove all byte tags stored in this packet. |
3039
722cf749a9e3
remove now-unused Tags class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3036
diff
changeset
|
491 |
*/ |
4502 | 492 |
void RemoveAllByteTags (void); |
493 |
||
494 |
/** |
|
495 |
* \param os output stream in which the data should be printed. |
|
496 |
* |
|
9763
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
497 |
* Iterate over the byte tags present in this packet, and |
4502 | 498 |
* invoke the Print method of each tag stored in the packet. |
499 |
*/ |
|
500 |
void PrintByteTags (std::ostream &os) const; |
|
501 |
||
502 |
/** |
|
9763
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
503 |
* Add a packet tag. |
4502 | 504 |
* |
9763
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
505 |
* \param tag the packet tag type to add. |
4502 | 506 |
* |
507 |
* Note that this method is const, that is, it does not |
|
508 |
* modify the state of this packet, which is fairly |
|
9763
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
509 |
* un-intuitive. See AddByteTag"()" discussion. |
4502 | 510 |
*/ |
511 |
void AddPacketTag (const Tag &tag) const; |
|
512 |
/** |
|
9763
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
513 |
* Remove a packet tag. |
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
514 |
* |
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
515 |
* \param tag the packet tag type to remove from this packet. |
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
516 |
* The tag parameter is set to the value of the tag found. |
4502 | 517 |
* \returns true if the requested tag is found, false |
518 |
* otherwise. |
|
519 |
*/ |
|
520 |
bool RemovePacketTag (Tag &tag); |
|
521 |
/** |
|
9763
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
522 |
* Replace the value of a packet tag. |
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
523 |
* |
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
524 |
* \param tag the packet tag type to replace. To get the old |
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
525 |
* value of the tag, use PeekPacketTag first. |
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
526 |
* \returns true if the requested tag is found, false otherwise. |
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
527 |
* If the tag isn't found, Add is performed instead (so |
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
528 |
* the packet is guaranteed to have the new tag value |
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
529 |
* either way). |
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
530 |
*/ |
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
531 |
bool ReplacePacketTag (Tag & tag); |
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
532 |
/** |
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
533 |
* Search a matching tag and call Tag::Deserialize if it is found. |
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
534 |
* |
4502 | 535 |
* \param tag the tag to search in this packet |
536 |
* \returns true if the requested tag is found, false |
|
537 |
* otherwise. |
|
538 |
*/ |
|
539 |
bool PeekPacketTag (Tag &tag) const; |
|
540 |
/** |
|
541 |
* Remove all packet tags. |
|
542 |
*/ |
|
543 |
void RemoveAllPacketTags (void); |
|
544 |
||
545 |
/** |
|
9763
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
546 |
* Print the list of packet tags. |
4502 | 547 |
* |
9763
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
548 |
* \param os the stream on which to print the tags. |
4502 | 549 |
* |
550 |
* \sa Packet::AddPacketTag, Packet::RemovePacketTag, Packet::PeekPacketTag, |
|
551 |
* Packet::RemoveAllPacketTags |
|
552 |
*/ |
|
553 |
void PrintPacketTags (std::ostream &os) const; |
|
554 |
||
555 |
/** |
|
556 |
* \returns an object which can be used to iterate over the list of |
|
557 |
* packet tags. |
|
558 |
*/ |
|
559 |
PacketTagIterator GetPacketTagIterator (void) const; |
|
3039
722cf749a9e3
remove now-unused Tags class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3036
diff
changeset
|
560 |
|
9763
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
561 |
/** |
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
562 |
* Set the packet nix-vector. |
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
563 |
* |
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
564 |
* Note: This function supports a temporary solution |
5224
06f639d05b8f
Merge NixVector Routing code
Josh Pelkey <jpelkey@gatech.edu>
parents:
5074
diff
changeset
|
565 |
* to a specific problem in this generic class, i.e. |
06f639d05b8f
Merge NixVector Routing code
Josh Pelkey <jpelkey@gatech.edu>
parents:
5074
diff
changeset
|
566 |
* how to associate something specific like nix-vector |
06f639d05b8f
Merge NixVector Routing code
Josh Pelkey <jpelkey@gatech.edu>
parents:
5074
diff
changeset
|
567 |
* with a packet. This design methodology |
06f639d05b8f
Merge NixVector Routing code
Josh Pelkey <jpelkey@gatech.edu>
parents:
5074
diff
changeset
|
568 |
* should _not_ be followed, and is only here as an |
9763
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
569 |
* impetus to fix this general issue. |
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
570 |
*/ |
5224
06f639d05b8f
Merge NixVector Routing code
Josh Pelkey <jpelkey@gatech.edu>
parents:
5074
diff
changeset
|
571 |
void SetNixVector (Ptr<NixVector>); |
9763
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
572 |
/** |
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
573 |
* Get the packet nix-vector. |
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
574 |
* |
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
575 |
* See the comment on SetNixVector |
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
576 |
*/ |
5224
06f639d05b8f
Merge NixVector Routing code
Josh Pelkey <jpelkey@gatech.edu>
parents:
5074
diff
changeset
|
577 |
Ptr<NixVector> GetNixVector (void) const; |
06f639d05b8f
Merge NixVector Routing code
Josh Pelkey <jpelkey@gatech.edu>
parents:
5074
diff
changeset
|
578 |
|
9
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
579 |
private: |
4502 | 580 |
Packet (const Buffer &buffer, const ByteTagList &byteTagList, |
581 |
const PacketTagList &packetTagList, const PacketMetadata &metadata); |
|
6113
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
5939
diff
changeset
|
582 |
|
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
5939
diff
changeset
|
583 |
uint32_t Deserialize (uint8_t const*buffer, uint32_t size); |
6397
a1608a9a11f3
run check-style.py
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
6132
diff
changeset
|
584 |
|
150
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
585 |
Buffer m_buffer; |
4502 | 586 |
ByteTagList m_byteTagList; |
587 |
PacketTagList m_packetTagList; |
|
888
f882ee7eaccf
history -> metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
887
diff
changeset
|
588 |
PacketMetadata m_metadata; |
5224
06f639d05b8f
Merge NixVector Routing code
Josh Pelkey <jpelkey@gatech.edu>
parents:
5074
diff
changeset
|
589 |
|
06f639d05b8f
Merge NixVector Routing code
Josh Pelkey <jpelkey@gatech.edu>
parents:
5074
diff
changeset
|
590 |
/* Please see comments above about nix-vector */ |
06f639d05b8f
Merge NixVector Routing code
Josh Pelkey <jpelkey@gatech.edu>
parents:
5074
diff
changeset
|
591 |
Ptr<NixVector> m_nixVector; |
06f639d05b8f
Merge NixVector Routing code
Josh Pelkey <jpelkey@gatech.edu>
parents:
5074
diff
changeset
|
592 |
|
463
c2082308e01a
merge Packet API changes needed for Packet pretty printing.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
239
diff
changeset
|
593 |
static uint32_t m_globalUid; |
9
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
594 |
}; |
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
595 |
|
1360
7686e996bd1d
add operator << for Packet and TraceContext
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1249
diff
changeset
|
596 |
std::ostream& operator<< (std::ostream& os, const Packet &packet); |
7686e996bd1d
add operator << for Packet and TraceContext
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1249
diff
changeset
|
597 |
|
1136
d5fe8364bcdf
add Tag documentation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1132
diff
changeset
|
598 |
/** |
7149
87514e0d866b
Fix doxygen groups for some new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
6823
diff
changeset
|
599 |
* \ingroup network |
1136
d5fe8364bcdf
add Tag documentation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1132
diff
changeset
|
600 |
* \defgroup packetperf Packet Performance |
d5fe8364bcdf
add Tag documentation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1132
diff
changeset
|
601 |
* The current implementation of the byte buffers and tag list is based |
d5fe8364bcdf
add Tag documentation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1132
diff
changeset
|
602 |
* on COW (Copy On Write. An introduction to COW can be found in Scott |
d5fe8364bcdf
add Tag documentation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1132
diff
changeset
|
603 |
* Meyer's "More Effective C++", items 17 and 29). What this means is that |
d5fe8364bcdf
add Tag documentation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1132
diff
changeset
|
604 |
* copying packets without modifying them is very cheap (in terms of cpu |
d5fe8364bcdf
add Tag documentation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1132
diff
changeset
|
605 |
* and memory usage) and modifying them can be also very cheap. What is |
d5fe8364bcdf
add Tag documentation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1132
diff
changeset
|
606 |
* key for proper COW implementations is being |
d5fe8364bcdf
add Tag documentation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1132
diff
changeset
|
607 |
* able to detect when a given modification of the state of a packet triggers |
d5fe8364bcdf
add Tag documentation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1132
diff
changeset
|
608 |
* a full copy of the data prior to the modification: COW systems need |
d5fe8364bcdf
add Tag documentation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1132
diff
changeset
|
609 |
* to detect when an operation is "dirty". |
d5fe8364bcdf
add Tag documentation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1132
diff
changeset
|
610 |
* |
d5fe8364bcdf
add Tag documentation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1132
diff
changeset
|
611 |
* Dirty operations: |
d5fe8364bcdf
add Tag documentation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1132
diff
changeset
|
612 |
* - ns3::Packet::AddHeader |
d5fe8364bcdf
add Tag documentation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1132
diff
changeset
|
613 |
* - ns3::Packet::AddTrailer |
d5fe8364bcdf
add Tag documentation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1132
diff
changeset
|
614 |
* - both versions of ns3::Packet::AddAtEnd |
4502 | 615 |
* - ns3::Packet::RemovePacketTag |
9763
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
616 |
* - ns3::Packet::ReplacePacketTag |
1136
d5fe8364bcdf
add Tag documentation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1132
diff
changeset
|
617 |
* |
d5fe8364bcdf
add Tag documentation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1132
diff
changeset
|
618 |
* Non-dirty operations: |
4503
d70501bf2b14
update documentation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4502
diff
changeset
|
619 |
* - ns3::Packet::AddPacketTag |
d70501bf2b14
update documentation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4502
diff
changeset
|
620 |
* - ns3::Packet::PeekPacketTag |
4502 | 621 |
* - ns3::Packet::RemoveAllPacketTags |
4503
d70501bf2b14
update documentation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4502
diff
changeset
|
622 |
* - ns3::Packet::AddByteTag |
d70501bf2b14
update documentation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4502
diff
changeset
|
623 |
* - ns3::Packet::FindFirstMatchingByteTag |
d70501bf2b14
update documentation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4502
diff
changeset
|
624 |
* - ns3::Packet::RemoveAllByteTags |
1136
d5fe8364bcdf
add Tag documentation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1132
diff
changeset
|
625 |
* - ns3::Packet::RemoveHeader |
d5fe8364bcdf
add Tag documentation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1132
diff
changeset
|
626 |
* - ns3::Packet::RemoveTrailer |
d5fe8364bcdf
add Tag documentation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1132
diff
changeset
|
627 |
* - ns3::Packet::CreateFragment |
d5fe8364bcdf
add Tag documentation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1132
diff
changeset
|
628 |
* - ns3::Packet::RemoveAtStart |
d5fe8364bcdf
add Tag documentation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1132
diff
changeset
|
629 |
* - ns3::Packet::RemoveAtEnd |
3764
64f1310350e4
add API to get bytes out of a packet without calling PeekData
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3738
diff
changeset
|
630 |
* - ns3::Packet::CopyData |
1136
d5fe8364bcdf
add Tag documentation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1132
diff
changeset
|
631 |
* |
d5fe8364bcdf
add Tag documentation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1132
diff
changeset
|
632 |
* Dirty operations will always be slower than non-dirty operations, |
d5fe8364bcdf
add Tag documentation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1132
diff
changeset
|
633 |
* sometimes by several orders of magnitude. However, even the |
d5fe8364bcdf
add Tag documentation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1132
diff
changeset
|
634 |
* dirty operations have been optimized for common use-cases which |
d5fe8364bcdf
add Tag documentation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1132
diff
changeset
|
635 |
* means that most of the time, these operations will not trigger |
d5fe8364bcdf
add Tag documentation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1132
diff
changeset
|
636 |
* data copies and will thus be still very fast. |
d5fe8364bcdf
add Tag documentation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1132
diff
changeset
|
637 |
*/ |
d5fe8364bcdf
add Tag documentation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1132
diff
changeset
|
638 |
|
d5fe8364bcdf
add Tag documentation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1132
diff
changeset
|
639 |
} // namespace ns3 |
9
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
640 |
|
9763
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
641 |
/**************************************************** |
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
642 |
* Implementation of inline methods for performance |
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
643 |
****************************************************/ |
038d5627c5a9
Trim excess copies from PacketTagList::Remove, add PacketTagList::Replace, documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7600
diff
changeset
|
644 |
|
6132
cd1902faafb9
inline to optimized iperf
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
6113
diff
changeset
|
645 |
namespace ns3 { |
cd1902faafb9
inline to optimized iperf
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
6113
diff
changeset
|
646 |
|
cd1902faafb9
inline to optimized iperf
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
6113
diff
changeset
|
647 |
uint32_t |
cd1902faafb9
inline to optimized iperf
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
6113
diff
changeset
|
648 |
Packet::GetSize (void) const |
cd1902faafb9
inline to optimized iperf
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
6113
diff
changeset
|
649 |
{ |
cd1902faafb9
inline to optimized iperf
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
6113
diff
changeset
|
650 |
return m_buffer.GetSize (); |
cd1902faafb9
inline to optimized iperf
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
6113
diff
changeset
|
651 |
} |
cd1902faafb9
inline to optimized iperf
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
6113
diff
changeset
|
652 |
|
cd1902faafb9
inline to optimized iperf
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
6113
diff
changeset
|
653 |
} // namespace ns3 |
cd1902faafb9
inline to optimized iperf
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
6113
diff
changeset
|
654 |
|
9
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
655 |
#endif /* PACKET_H */ |