A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
header.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2005 INRIA
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
7
*/
8
9
#ifndef HEADER_H
10
#define HEADER_H
11
12
#include "
buffer.h
"
13
#include "
chunk.h
"
14
15
#include <stdint.h>
16
17
namespace
ns3
18
{
19
20
/**
21
* @ingroup packet
22
*
23
* @brief Protocol header serialization and deserialization.
24
*
25
* Every Protocol header which needs to be inserted or removed
26
* from a Packet instance must derive from this base class and
27
* implement the pure virtual methods defined here.
28
*
29
* Sample code which shows how to create a new type of Header, and how to use it,
30
* is shown in the sample file samples/main-packet-header.cc
31
*
32
* Inheritance graph was not generated because of its size.
33
* @hideinheritancegraph
34
*/
35
class
Header
:
public
Chunk
36
{
37
public
:
38
/**
39
* @brief Get the type ID.
40
* @return the object TypeId
41
*/
42
static
TypeId
GetTypeId
();
43
~Header
()
override
;
44
45
using
Chunk::Deserialize
;
46
/**
47
* @returns the expected size of the header.
48
*
49
* This method is used by Packet::AddHeader
50
* to store a header into the byte buffer of a packet. This method
51
* should return the number of bytes which are needed to store
52
* the full header data by Serialize.
53
*/
54
virtual
uint32_t
GetSerializedSize
()
const
= 0;
55
/**
56
* @param start an iterator which points to where the header should
57
* be written.
58
*
59
* This method is used by Packet::AddHeader to
60
* store a header into the byte buffer of a packet.
61
* The data written
62
* is expected to match bit-for-bit the representation of this
63
* header in a real network.
64
*/
65
virtual
void
Serialize
(
Buffer::Iterator
start)
const
= 0;
66
/**
67
* @param start an iterator which points to where the header should
68
* read from.
69
* @returns the number of bytes read.
70
*
71
* This method is used by Packet::RemoveHeader to
72
* re-create a header from the byte buffer of a packet.
73
* The data read is expected to
74
* match bit-for-bit the representation of this header in real
75
* networks.
76
*
77
* Note that data is not actually removed from the buffer to
78
* which the iterator points. Both Packet::RemoveHeader() and
79
* Packet::PeekHeader() call Deserialize(), but only the RemoveHeader()
80
* has additional statements to remove the header bytes from the
81
* underlying buffer and associated metadata.
82
*/
83
uint32_t
Deserialize
(
Buffer::Iterator
start)
override
= 0;
84
/**
85
* @param os output stream
86
* This method is used by Packet::Print to print the
87
* content of a header as ascii data to a c++ output stream.
88
* Although the header is free to format its output as it
89
* wishes, it is recommended to follow a few rules to integrate
90
* with the packet pretty printer: start with flags, small field
91
* values located between a pair of parens. Values should be separated
92
* by whitespace. Follow the parens with the important fields,
93
* separated by whitespace.
94
* i.e.: (field1 val1 field2 val2 field3 val3) field4 val4 field5 val5
95
*/
96
void
Print
(std::ostream& os)
const override
= 0;
97
};
98
99
/**
100
* @brief Stream insertion operator.
101
*
102
* @param os the stream
103
* @param header the header
104
* @returns a reference to the stream
105
*/
106
std::ostream&
operator<<
(std::ostream& os,
const
Header
& header);
107
108
}
// namespace ns3
109
110
#endif
/* HEADER_H */
buffer.h
chunk.h
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition
buffer.h:89
ns3::Chunk
abstract base class for ns3::Header and ns3::Trailer
Definition
chunk.h:25
ns3::Chunk::Deserialize
virtual uint32_t Deserialize(Buffer::Iterator start)=0
Deserialize the object from a buffer iterator.
ns3::Header
Protocol header serialization and deserialization.
Definition
header.h:36
ns3::Header::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
header.cc:26
ns3::Header::~Header
~Header() override
Definition
header.cc:20
ns3::Header::GetSerializedSize
virtual uint32_t GetSerializedSize() const =0
ns3::Header::Print
void Print(std::ostream &os) const override=0
ns3::Header::Deserialize
uint32_t Deserialize(Buffer::Iterator start) override=0
ns3::Header::Serialize
virtual void Serialize(Buffer::Iterator start) const =0
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:49
uint32_t
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::operator<<
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition
angles.cc:148
src
network
model
header.h
Generated on
for ns-3 by
1.15.0