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
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
cognitive-packet-tags.cc
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2005,2006,2007 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: Abdulla Al-Ali <al-ali.a@husky.neu.edu>
19
*/
20
21
#include "cognitive-packet-tags.h"
22
23
namespace
ns3 {
24
25
PacketTypePacketTag::PacketTypePacketTag (PacketType t) :
26
m_type (t)
27
{
28
}
29
30
TypeId
31
PacketTypePacketTag::GetTypeId (
void
)
32
{
33
static
TypeId tid = TypeId (
"ns3::PacketTypePacketTag"
)
34
.SetParent<Tag> ()
35
.AddConstructor<PacketTypePacketTag> ()
36
;
37
return
tid;
38
}
39
TypeId
40
PacketTypePacketTag::GetInstanceTypeId
(
void
)
const
41
{
42
return
GetTypeId ();
43
}
44
45
uint32_t
46
PacketTypePacketTag::GetSerializedSize
(
void
)
const
47
{
48
return
1;
49
}
50
void
51
PacketTypePacketTag::Serialize
(
TagBuffer
i)
const
52
{
53
i.
WriteU8
(m_type);
54
}
55
void
56
PacketTypePacketTag::Deserialize
(
TagBuffer
i)
57
{
58
m_type = (PacketType) i.
ReadU8
();
59
}
60
61
void
62
PacketTypePacketTag::Print
(std::ostream &os)
const
63
{
64
switch
(m_type)
65
{
66
case
CTRL_PACKET:
67
{
68
os <<
"ctrl_packet"
;
69
break
;
70
}
71
case
DATA_PACKET:
72
{
73
os <<
"data_packet"
;
74
break
;
75
}
76
default
:
77
os <<
"UNKNOWN_TYPE"
;
78
break
;
79
}
80
}
81
82
PacketChannelPacketTag::PacketChannelPacketTag (uint16_t t) :
83
m_channel (t)
84
{
85
}
86
87
TypeId
88
PacketChannelPacketTag::GetTypeId (
void
)
89
{
90
static
TypeId tid = TypeId (
"ns3::PacketChannelPacketTag"
)
91
.SetParent<Tag> ()
92
.AddConstructor<PacketChannelPacketTag> ()
93
;
94
return
tid;
95
}
96
TypeId
97
PacketChannelPacketTag::GetInstanceTypeId
(
void
)
const
98
{
99
return
GetTypeId ();
100
}
101
102
uint32_t
103
PacketChannelPacketTag::GetSerializedSize
(
void
)
const
104
{
105
return
2;
106
}
107
void
108
PacketChannelPacketTag::Serialize
(
TagBuffer
i)
const
109
{
110
i.
WriteU16
(m_channel);
111
}
112
void
113
PacketChannelPacketTag::Deserialize
(
TagBuffer
i)
114
{
115
m_channel = i.
ReadU16
();
116
}
117
118
void
119
PacketChannelPacketTag::Print
(std::ostream &os)
const
120
{
121
os <<
"packet channel: "
<< m_channel;
122
}
123
124
}
ns3::PacketChannelPacketTag::Deserialize
virtual void Deserialize(TagBuffer i)
Definition:
cognitive-packet-tags.cc:113
ns3::PacketTypePacketTag::GetSerializedSize
virtual uint32_t GetSerializedSize(void) const
Definition:
cognitive-packet-tags.cc:46
ns3::TagBuffer::ReadU8
TAG_BUFFER_INLINE uint8_t ReadU8(void)
Definition:
tag-buffer.h:179
ns3::PacketTypePacketTag::Deserialize
virtual void Deserialize(TagBuffer i)
Definition:
cognitive-packet-tags.cc:56
ns3::PacketChannelPacketTag::GetInstanceTypeId
virtual TypeId GetInstanceTypeId(void) const
Definition:
cognitive-packet-tags.cc:97
ns3::PacketChannelPacketTag::GetSerializedSize
virtual uint32_t GetSerializedSize(void) const
Definition:
cognitive-packet-tags.cc:103
ns3::TagBuffer::WriteU16
TAG_BUFFER_INLINE void WriteU16(uint16_t v)
Definition:
tag-buffer.h:164
ns3::PacketChannelPacketTag::Print
void Print(std::ostream &os) const
Definition:
cognitive-packet-tags.cc:119
ns3::TagBuffer::WriteU8
TAG_BUFFER_INLINE void WriteU8(uint8_t v)
Definition:
tag-buffer.h:156
ns3::TagBuffer
read and write tag data
Definition:
tag-buffer.h:51
ns3::PacketTypePacketTag::Serialize
virtual void Serialize(TagBuffer i) const
Definition:
cognitive-packet-tags.cc:51
ns3::TagBuffer::ReadU16
TAG_BUFFER_INLINE uint16_t ReadU16(void)
Definition:
tag-buffer.h:189
ns3::PacketTypePacketTag::GetInstanceTypeId
virtual TypeId GetInstanceTypeId(void) const
Definition:
cognitive-packet-tags.cc:40
ns3::PacketChannelPacketTag::Serialize
virtual void Serialize(TagBuffer i) const
Definition:
cognitive-packet-tags.cc:108
ns3::PacketTypePacketTag::Print
void Print(std::ostream &os) const
Definition:
cognitive-packet-tags.cc:62
src
cognitive
model
cognitive-packet-tags.cc
Generated on Sun Mar 16 2014 11:25:01 for ns-3 by
1.8.6