A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
cid-factory.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2007,2008,2009 INRIA, UDcast
3
*
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 2 as
6
* published by the Free Software Foundation;
7
*
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
12
*
13
* You should have received a copy of the GNU General Public License
14
* along with this program; if not, write to the Free Software
15
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
*
17
* Authors: Jahanzeb Farooq <jahanzeb.farooq@sophia.inria.fr>
18
* Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
19
* <amine.ismail@UDcast.com>
20
*/
21
22
#include "
cid-factory.h
"
23
24
#include "ns3/uinteger.h"
25
26
#include <stdint.h>
27
28
namespace
ns3
29
{
30
31
CidFactory::CidFactory
()
32
: m_m(0x5500),
33
// this is an arbitrary default
34
m_basicIdentifier(1),
35
m_primaryIdentifier(m_m + 1),
36
m_transportOrSecondaryIdentifier(2 * m_m + 1),
37
m_multicastPollingIdentifier(0xff00)
38
{
39
}
40
41
Cid
42
CidFactory::AllocateBasic
()
43
{
44
NS_ASSERT
(
m_basicIdentifier
<
m_m
);
45
m_basicIdentifier
++;
46
return
Cid
(
m_basicIdentifier
);
47
}
48
49
Cid
50
CidFactory::AllocatePrimary
()
51
{
52
NS_ASSERT
(
m_primaryIdentifier
< 2 *
m_m
);
53
m_primaryIdentifier
++;
54
return
Cid
(
m_primaryIdentifier
);
55
}
56
57
Cid
58
CidFactory::AllocateTransportOrSecondary
()
59
{
60
NS_ASSERT
(
m_transportOrSecondaryIdentifier
< 0xfefe);
61
m_transportOrSecondaryIdentifier
++;
62
return
Cid
(
m_transportOrSecondaryIdentifier
);
63
}
64
65
Cid
66
CidFactory::AllocateMulticast
()
67
{
68
NS_ASSERT
(
m_multicastPollingIdentifier
< 0xfffd);
69
m_multicastPollingIdentifier
++;
70
return
Cid
(
m_multicastPollingIdentifier
);
71
}
72
73
Cid
74
CidFactory::Allocate
(
Cid::Type
type
)
75
{
76
switch
(
type
)
77
{
78
case
Cid::BROADCAST
:
79
return
Cid::Broadcast
();
80
case
Cid::INITIAL_RANGING
:
81
return
Cid::InitialRanging
();
82
case
Cid::BASIC
:
83
return
AllocateBasic
();
84
case
Cid::PRIMARY
:
85
return
AllocatePrimary
();
86
case
Cid::TRANSPORT
:
87
return
AllocateTransportOrSecondary
();
88
case
Cid::MULTICAST
:
89
return
AllocateMulticast
();
90
case
Cid::PADDING
:
91
return
Cid::Padding
();
92
default
:
93
NS_FATAL_ERROR
(
"Cannot be reached"
);
94
return
0;
// quiet compiler
95
}
96
}
97
98
bool
99
CidFactory::IsTransport
(
Cid
cid)
const
100
{
101
int
id
= cid.
m_identifier
;
102
return
(
id
- 2 *
m_m
> 0) && (
id
<= 0xfefe);
103
}
104
105
bool
106
CidFactory::IsPrimary
(
Cid
cid)
const
107
{
108
int
id
= cid.
m_identifier
;
109
return
(
id
-
m_m
> 0) && (
id
<= 2 *
m_m
);
110
}
111
112
bool
113
CidFactory::IsBasic
(
Cid
cid)
const
114
{
115
uint16_t
id
= cid.
m_identifier
;
116
return
id
>= 1 &&
id
<=
m_m
;
117
}
118
119
void
120
CidFactory::FreeCid
(
Cid
cid)
121
{
123
NS_FATAL_ERROR
(
124
"TODO: Update the cid bitmap properly here-- please implement and contribute a patch"
);
125
}
126
127
}
// namespace ns3
cid-factory.h
ns3::CidFactory::m_m
uint16_t m_m
m
Definition:
cid-factory.h:106
ns3::CidFactory::Allocate
Cid Allocate(Cid::Type type)
This function returns the next CID for the specified type.
Definition:
cid-factory.cc:74
ns3::CidFactory::m_basicIdentifier
uint16_t m_basicIdentifier
basic identifier
Definition:
cid-factory.h:108
ns3::CidFactory::IsBasic
bool IsBasic(Cid cid) const
This function determines if the CID is basic.
Definition:
cid-factory.cc:113
ns3::CidFactory::m_transportOrSecondaryIdentifier
uint16_t m_transportOrSecondaryIdentifier
transport or secondary identifier
Definition:
cid-factory.h:110
ns3::CidFactory::AllocatePrimary
Cid AllocatePrimary()
This function returns the next primary basic CID.
Definition:
cid-factory.cc:50
ns3::CidFactory::AllocateTransportOrSecondary
Cid AllocateTransportOrSecondary()
This function returns the next Transport (or Secondary) CID.
Definition:
cid-factory.cc:58
ns3::CidFactory::m_multicastPollingIdentifier
uint16_t m_multicastPollingIdentifier
multicast polling identifier
Definition:
cid-factory.h:111
ns3::CidFactory::IsPrimary
bool IsPrimary(Cid cid) const
This function determines if the CID is primary.
Definition:
cid-factory.cc:106
ns3::CidFactory::AllocateBasic
Cid AllocateBasic()
This function returns the next basic CID.
Definition:
cid-factory.cc:42
ns3::CidFactory::IsTransport
bool IsTransport(Cid cid) const
This function determines if the CID is a transport.
Definition:
cid-factory.cc:99
ns3::CidFactory::m_primaryIdentifier
uint16_t m_primaryIdentifier
primary identifier
Definition:
cid-factory.h:109
ns3::CidFactory::AllocateMulticast
Cid AllocateMulticast()
This function returns the next Multicast CID.
Definition:
cid-factory.cc:66
ns3::CidFactory::CidFactory
CidFactory()
Create a cid factory with a default value for m of 0x5500.
Definition:
cid-factory.cc:31
ns3::CidFactory::FreeCid
void FreeCid(Cid cid)
Notify the factory that the connection associated to this cid has been killed and that this cid can b...
Definition:
cid-factory.cc:120
ns3::Cid
Cid class.
Definition:
cid.h:37
ns3::Cid::Type
Type
Type enumeration.
Definition:
cid.h:41
ns3::Cid::PRIMARY
@ PRIMARY
Definition:
cid.h:45
ns3::Cid::BROADCAST
@ BROADCAST
Definition:
cid.h:42
ns3::Cid::TRANSPORT
@ TRANSPORT
Definition:
cid.h:46
ns3::Cid::MULTICAST
@ MULTICAST
Definition:
cid.h:47
ns3::Cid::BASIC
@ BASIC
Definition:
cid.h:44
ns3::Cid::PADDING
@ PADDING
Definition:
cid.h:48
ns3::Cid::INITIAL_RANGING
@ INITIAL_RANGING
Definition:
cid.h:43
ns3::Cid::InitialRanging
static Cid InitialRanging()
Definition:
cid.cc:87
ns3::Cid::Padding
static Cid Padding()
Definition:
cid.cc:81
ns3::Cid::Broadcast
static Cid Broadcast()
Definition:
cid.cc:75
ns3::Cid::m_identifier
uint16_t m_identifier
identiifier
Definition:
cid.h:98
NS_ASSERT
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition:
assert.h:66
NS_FATAL_ERROR
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition:
fatal-error.h:179
check-style-clang-format.type
type
Definition:
check-style-clang-format.py:704
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
wimax
model
cid-factory.cc
Generated on Sun Mar 3 2024 17:11:13 for ns-3 by
1.9.1