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
seq-ts-header.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2009 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
#include "ns3/assert.h"
22
#include "ns3/log.h"
23
#include "ns3/header.h"
24
#include "ns3/simulator.h"
25
#include "
seq-ts-header.h
"
26
27
NS_LOG_COMPONENT_DEFINE
(
"SeqTsHeader"
);
28
29
namespace
ns3 {
30
31
NS_OBJECT_ENSURE_REGISTERED
(SeqTsHeader);
32
33
SeqTsHeader::SeqTsHeader
()
34
: m_seq (0),
35
m_ts (
Simulator
::
Now
().GetTimeStep ())
36
{
37
NS_LOG_FUNCTION
(
this
);
38
}
39
40
void
41
SeqTsHeader::SetSeq
(uint32_t seq)
42
{
43
NS_LOG_FUNCTION
(
this
<< seq);
44
m_seq
= seq;
45
}
46
uint32_t
47
SeqTsHeader::GetSeq
(
void
)
const
48
{
49
NS_LOG_FUNCTION
(
this
);
50
return
m_seq
;
51
}
52
53
Time
54
SeqTsHeader::GetTs
(
void
)
const
55
{
56
NS_LOG_FUNCTION
(
this
);
57
return
TimeStep
(
m_ts
);
58
}
59
60
TypeId
61
SeqTsHeader::GetTypeId
(
void
)
62
{
63
static
TypeId
tid =
TypeId
(
"ns3::SeqTsHeader"
)
64
.
SetParent
<
Header
> ()
65
.AddConstructor<SeqTsHeader> ()
66
;
67
return
tid;
68
}
69
TypeId
70
SeqTsHeader::GetInstanceTypeId
(
void
)
const
71
{
72
return
GetTypeId
();
73
}
74
void
75
SeqTsHeader::Print
(std::ostream &os)
const
76
{
77
NS_LOG_FUNCTION
(
this
<< &os);
78
os <<
"(seq="
<<
m_seq
<<
" time="
<<
TimeStep
(
m_ts
).
GetSeconds
() <<
")"
;
79
}
80
uint32_t
81
SeqTsHeader::GetSerializedSize
(
void
)
const
82
{
83
NS_LOG_FUNCTION
(
this
);
84
return
4+8;
85
}
86
87
void
88
SeqTsHeader::Serialize
(
Buffer::Iterator
start
)
const
89
{
90
NS_LOG_FUNCTION
(
this
<< &start);
91
Buffer::Iterator
i =
start
;
92
i.
WriteHtonU32
(
m_seq
);
93
i.
WriteHtonU64
(
m_ts
);
94
}
95
uint32_t
96
SeqTsHeader::Deserialize
(
Buffer::Iterator
start
)
97
{
98
NS_LOG_FUNCTION
(
this
<< &start);
99
Buffer::Iterator
i =
start
;
100
m_seq
= i.
ReadNtohU32
();
101
m_ts
= i.
ReadNtohU64
();
102
return
GetSerializedSize
();
103
}
104
105
}
// namespace ns3
src
applications
model
seq-ts-header.cc
Generated on Tue May 14 2013 11:08:16 for ns-3 by
1.8.1.2