A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
packet.h
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2005,2006 INRIA
4
*
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 2 as
7
* published by the Free Software Foundation;
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*
18
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19
*/
20
#ifndef PACKET_H
21
#define PACKET_H
22
23
#include <stdint.h>
24
#include "
buffer.h
"
25
#include "
header.h
"
26
#include "
trailer.h
"
27
#include "
packet-metadata.h
"
28
#include "
tag.h
"
29
#include "
byte-tag-list.h
"
30
#include "
packet-tag-list.h
"
31
#include "
nix-vector.h
"
32
#include "ns3/callback.h"
33
#include "ns3/assert.h"
34
#include "ns3/ptr.h"
35
#include "ns3/deprecated.h"
36
37
namespace
ns3 {
38
50
class
ByteTagIterator
51
{
52
public
:
57
class
Item
58
{
59
public
:
63
TypeId
GetTypeId
(
void
)
const
;
69
uint32_t
GetStart
(
void
)
const
;
75
uint32_t
GetEnd
(
void
)
const
;
84
void
GetTag
(
Tag
&tag)
const
;
85
private
:
86
friend
class
ByteTagIterator
;
87
Item
(
TypeId
tid, uint32_t
start
, uint32_t end,
TagBuffer
buffer);
88
TypeId
m_tid
;
89
uint32_t
m_start
;
90
uint32_t
m_end
;
91
TagBuffer
m_buffer
;
92
};
96
bool
HasNext
(
void
)
const
;
100
Item
Next
(
void
);
101
private
:
102
friend
class
Packet
;
103
ByteTagIterator
(
ByteTagList::Iterator
i);
104
ByteTagList::Iterator
m_current
;
105
};
106
113
class
PacketTagIterator
114
{
115
public
:
119
class
Item
120
{
121
public
:
125
TypeId
GetTypeId
(
void
)
const
;
134
void
GetTag
(
Tag
&tag)
const
;
135
private
:
136
friend
class
PacketTagIterator
;
137
Item
(
const
struct
PacketTagList::TagData
*
data
);
138
const
struct
PacketTagList::TagData
*
m_data
;
139
};
143
bool
HasNext
(
void
)
const
;
147
Item
Next
(
void
);
148
private
:
149
friend
class
Packet
;
150
PacketTagIterator
(
const
struct
PacketTagList::TagData
*head);
151
const
struct
PacketTagList::TagData
*
m_current
;
152
};
153
203
class
Packet
:
public
SimpleRefCount
<Packet>
204
{
205
public
:
206
211
Packet
();
212
Packet
(
const
Packet
&o);
213
Packet
&
operator =
(
const
Packet
&o);
224
Packet
(uint32_t size);
235
Packet
(uint8_t
const
*buffer, uint32_t size,
bool
magic);
244
Packet
(uint8_t
const
*buffer, uint32_t size);
253
Ptr<Packet>
CreateFragment
(uint32_t
start
, uint32_t length)
const
;
258
inline
uint32_t
GetSize
(
void
)
const
;
267
void
AddHeader
(
const
Header
& header);
275
uint32_t
RemoveHeader
(
Header
&header);
283
uint32_t
PeekHeader
(
Header
&header)
const
;
292
void
AddTrailer
(
const
Trailer
&trailer);
300
uint32_t
RemoveTrailer
(
Trailer
&trailer);
308
uint32_t
PeekTrailer
(
Trailer
&trailer);
309
316
void
AddAtEnd
(
Ptr<const Packet>
packet);
320
void
AddPaddingAtEnd
(uint32_t size);
328
void
RemoveAtEnd
(uint32_t size);
336
void
RemoveAtStart
(uint32_t size);
337
351
uint8_t
const
*
PeekData
(
void
)
const
NS_DEPRECATED
;
352
363
uint32_t
CopyData
(uint8_t *buffer, uint32_t size)
const
;
364
373
void
CopyData
(std::ostream *os, uint32_t size)
const
;
374
382
Ptr<Packet>
Copy
(
void
)
const
;
383
401
uint64_t
GetUid
(
void
)
const
;
402
411
void
Print
(std::ostream &os)
const
;
412
421
PacketMetadata::ItemIterator
BeginItem
(
void
)
const
;
422
430
static
void
EnablePrinting
(
void
);
439
static
void
EnableChecking
(
void
);
440
449
uint32_t
GetSerializedSize
(
void
)
const
;
450
459
uint32_t
Serialize
(uint8_t* buffer, uint32_t maxSize)
const
;
460
477
void
AddByteTag
(
const
Tag
&tag)
const
;
481
ByteTagIterator
GetByteTagIterator
(
void
)
const
;
489
bool
FindFirstMatchingByteTag
(
Tag
&tag)
const
;
490
494
void
RemoveAllByteTags
(
void
);
495
502
void
PrintByteTags
(std::ostream &os)
const
;
503
513
void
AddPacketTag
(
const
Tag
&tag)
const
;
522
bool
RemovePacketTag
(
Tag
&tag);
533
bool
ReplacePacketTag
(
Tag
& tag);
541
bool
PeekPacketTag
(
Tag
&tag)
const
;
545
void
RemoveAllPacketTags
(
void
);
546
555
void
PrintPacketTags
(std::ostream &os)
const
;
556
561
PacketTagIterator
GetPacketTagIterator
(
void
)
const
;
562
573
void
SetNixVector
(
Ptr<NixVector>
);
579
Ptr<NixVector>
GetNixVector
(
void
)
const
;
580
581
private
:
582
Packet
(
const
Buffer
&buffer,
const
ByteTagList
&byteTagList,
583
const
PacketTagList
&packetTagList,
const
PacketMetadata
&metadata);
584
585
uint32_t
Deserialize
(uint8_t
const
*buffer, uint32_t size);
586
587
Buffer
m_buffer
;
588
ByteTagList
m_byteTagList
;
589
PacketTagList
m_packetTagList
;
590
PacketMetadata
m_metadata
;
591
592
/* Please see comments above about nix-vector */
593
Ptr<NixVector>
m_nixVector
;
594
595
static
uint32_t
m_globalUid
;
596
};
597
598
std::ostream&
operator<<
(std::ostream& os,
const
Packet
&packet);
599
641
}
// namespace ns3
642
643
/****************************************************
644
* Implementation of inline methods for performance
645
****************************************************/
646
647
namespace
ns3 {
648
649
uint32_t
650
Packet::GetSize
(
void
)
const
651
{
652
return
m_buffer
.
GetSize
();
653
}
654
655
}
// namespace ns3
656
657
#endif
/* PACKET_H */
src
network
model
packet.h
Generated on Fri Aug 30 2013 01:42:59 for ns-3 by
1.8.1.2