A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
src
internet
model
udp-header.h
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2005 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
21
#ifndef UDP_HEADER_H
22
#define UDP_HEADER_H
23
24
#include <stdint.h>
25
#include <string>
26
#include "ns3/header.h"
27
#include "ns3/ipv4-address.h"
28
#include "ns3/ipv6-address.h"
29
30
namespace
ns3
{
39
class
UdpHeader
:
public
Header
40
{
41
public
:
42
48
UdpHeader
();
49
~UdpHeader
();
50
54
void
EnableChecksums
(
void
);
58
void
SetDestinationPort
(uint16_t
port
);
62
void
SetSourcePort
(uint16_t
port
);
66
uint16_t
GetSourcePort
(
void
)
const
;
70
uint16_t
GetDestinationPort
(
void
)
const
;
71
83
void
InitializeChecksum
(
Address
source,
84
Address
destination,
85
uint8_t protocol);
86
98
void
InitializeChecksum
(
Ipv4Address
source,
99
Ipv4Address
destination,
100
uint8_t protocol);
101
113
void
InitializeChecksum
(
Ipv6Address
source,
114
Ipv6Address
destination,
115
uint8_t protocol);
116
121
static
TypeId
GetTypeId
(
void
);
122
virtual
TypeId
GetInstanceTypeId
(
void
)
const
;
123
virtual
void
Print
(std::ostream &os)
const
;
124
virtual
uint32_t
GetSerializedSize
(
void
)
const
;
125
virtual
void
Serialize
(
Buffer::Iterator
start
)
const
;
126
virtual
uint32_t
Deserialize
(
Buffer::Iterator
start
);
127
132
bool
IsChecksumOk
(
void
)
const
;
133
151
void
ForceChecksum
(uint16_t checksum);
152
161
void
ForcePayloadSize
(uint16_t payloadSize);
162
167
uint16_t
GetChecksum
();
168
169
private
:
175
uint16_t
CalculateHeaderChecksum
(uint16_t size)
const
;
176
uint16_t
m_sourcePort
;
177
uint16_t
m_destinationPort
;
178
uint16_t
m_payloadSize
;
179
180
Address
m_source
;
181
Address
m_destination
;
182
uint8_t
m_protocol
;
183
uint16_t
m_checksum
;
184
bool
m_calcChecksum
;
185
bool
m_goodChecksum
;
186
};
187
188
}
// namespace ns3
189
190
#endif
/* UDP_HEADER */
ns3::Header
Protocol header serialization and deserialization.
Definition:
header.h:42
ns3::UdpHeader::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition:
udp-header.cc:154
ns3::UdpHeader::InitializeChecksum
void InitializeChecksum(Address source, Address destination, uint8_t protocol)
Definition:
udp-header.cc:75
ns3::UdpHeader::m_goodChecksum
bool m_goodChecksum
Flag to indicate that checksum is correct.
Definition:
udp-header.h:185
ns3::UdpHeader::m_source
Address m_source
Source IP address.
Definition:
udp-header.h:180
ns3::UdpHeader::GetInstanceTypeId
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
Definition:
udp-header.cc:164
visualizer.core.start
def start()
Definition:
core.py:1844
ns3::UdpHeader::SetDestinationPort
void SetDestinationPort(uint16_t port)
Definition:
udp-header.cc:55
ns3::UdpHeader::m_checksum
uint16_t m_checksum
Forced Checksum value.
Definition:
udp-header.h:183
ns3::UdpHeader::SetSourcePort
void SetSourcePort(uint16_t port)
Definition:
udp-header.cc:60
port
uint16_t port
Definition:
dsdv-manet.cc:45
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition:
buffer.h:98
ns3::Address
a polymophic address class
Definition:
address.h:90
ns3::UdpHeader::ForceChecksum
void ForceChecksum(uint16_t checksum)
Force the UDP checksum to a given value.
Definition:
udp-header.cc:142
ns3::UdpHeader::Serialize
virtual void Serialize(Buffer::Iterator start) const
Definition:
udp-header.cc:184
ns3::UdpHeader::EnableChecksums
void EnableChecksums(void)
Enable checksum calculation for UDP.
Definition:
udp-header.cc:49
ns3::UdpHeader::GetDestinationPort
uint16_t GetDestinationPort(void) const
Definition:
udp-header.cc:70
ns3::UdpHeader::ForcePayloadSize
void ForcePayloadSize(uint16_t payloadSize)
Force the UDP payload length to a given value.
Definition:
udp-header.cc:148
ns3::UdpHeader::~UdpHeader
~UdpHeader()
Definition:
udp-header.cc:41
ns3::UdpHeader::Print
virtual void Print(std::ostream &os) const
Definition:
udp-header.cc:169
ns3::UdpHeader::UdpHeader
UdpHeader()
Constructor.
Definition:
udp-header.cc:32
ns3::UdpHeader::GetChecksum
uint16_t GetChecksum()
Return the checksum (only known after a Deserialize)
Definition:
udp-header.cc:241
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::UdpHeader::GetSerializedSize
virtual uint32_t GetSerializedSize(void) const
Definition:
udp-header.cc:178
ns3::UdpHeader
Packet header for UDP packets.
Definition:
udp-header.h:39
ns3::UdpHeader::m_payloadSize
uint16_t m_payloadSize
Payload size.
Definition:
udp-header.h:178
ns3::UdpHeader::m_calcChecksum
bool m_calcChecksum
Flag to calculate checksum.
Definition:
udp-header.h:184
ns3::Ipv6Address
Describes an IPv6 address.
Definition:
ipv6-address.h:49
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition:
ipv4-address.h:40
ns3::UdpHeader::Deserialize
virtual uint32_t Deserialize(Buffer::Iterator start)
Definition:
udp-header.cc:220
ns3::UdpHeader::m_sourcePort
uint16_t m_sourcePort
Source port.
Definition:
udp-header.h:176
ns3::UdpHeader::m_destination
Address m_destination
Destination IP address.
Definition:
udp-header.h:181
ns3::UdpHeader::CalculateHeaderChecksum
uint16_t CalculateHeaderChecksum(uint16_t size) const
Calculate the header checksum.
Definition:
udp-header.cc:102
ns3::UdpHeader::m_protocol
uint8_t m_protocol
Protocol number.
Definition:
udp-header.h:182
ns3::UdpHeader::GetSourcePort
uint16_t GetSourcePort(void) const
Definition:
udp-header.cc:65
ns3::UdpHeader::m_destinationPort
uint16_t m_destinationPort
Destination port.
Definition:
udp-header.h:177
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:58
ns3::UdpHeader::IsChecksumOk
bool IsChecksumOk(void) const
Is the UDP checksum correct ?
Definition:
udp-header.cc:136
Generated on Wed Nov 7 2018 10:01:57 for ns-3 by
1.8.14