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
cid-factory.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2007,2008,2009 INRIA, UDcast
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Authors: Jahanzeb Farooq <jahanzeb.farooq@sophia.inria.fr>
7
* Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
8
* <amine.ismail@UDcast.com>
9
*/
10
11
#include "
cid-factory.h
"
12
13
#include "ns3/uinteger.h"
14
15
#include <stdint.h>
16
17
namespace
ns3
18
{
19
20
CidFactory::CidFactory
()
21
: m_m(0x5500),
22
// this is an arbitrary default
23
m_basicIdentifier(1),
24
m_primaryIdentifier(m_m + 1),
25
m_transportOrSecondaryIdentifier(2 * m_m + 1),
26
m_multicastPollingIdentifier(0xff00)
27
{
28
}
29
30
Cid
31
CidFactory::AllocateBasic
()
32
{
33
NS_ASSERT
(
m_basicIdentifier
<
m_m
);
34
m_basicIdentifier
++;
35
return
Cid
(
m_basicIdentifier
);
36
}
37
38
Cid
39
CidFactory::AllocatePrimary
()
40
{
41
NS_ASSERT
(
m_primaryIdentifier
< 2 *
m_m
);
42
m_primaryIdentifier
++;
43
return
Cid
(
m_primaryIdentifier
);
44
}
45
46
Cid
47
CidFactory::AllocateTransportOrSecondary
()
48
{
49
NS_ASSERT
(
m_transportOrSecondaryIdentifier
< 0xfefe);
50
m_transportOrSecondaryIdentifier
++;
51
return
Cid
(
m_transportOrSecondaryIdentifier
);
52
}
53
54
Cid
55
CidFactory::AllocateMulticast
()
56
{
57
NS_ASSERT
(
m_multicastPollingIdentifier
< 0xfffd);
58
m_multicastPollingIdentifier
++;
59
return
Cid
(
m_multicastPollingIdentifier
);
60
}
61
62
Cid
63
CidFactory::Allocate
(
Cid::Type
type)
64
{
65
switch
(type)
66
{
67
case
Cid::BROADCAST
:
68
return
Cid::Broadcast
();
69
case
Cid::INITIAL_RANGING
:
70
return
Cid::InitialRanging
();
71
case
Cid::BASIC
:
72
return
AllocateBasic
();
73
case
Cid::PRIMARY
:
74
return
AllocatePrimary
();
75
case
Cid::TRANSPORT
:
76
return
AllocateTransportOrSecondary
();
77
case
Cid::MULTICAST
:
78
return
AllocateMulticast
();
79
case
Cid::PADDING
:
80
return
Cid::Padding
();
81
default
:
82
NS_FATAL_ERROR
(
"Cannot be reached"
);
83
return
0;
// quiet compiler
84
}
85
}
86
87
bool
88
CidFactory::IsTransport
(
Cid
cid)
const
89
{
90
int
id
= cid.
m_identifier
;
91
return
(
id
- 2 *
m_m
> 0) && (
id
<= 0xfefe);
92
}
93
94
bool
95
CidFactory::IsPrimary
(
Cid
cid)
const
96
{
97
int
id
= cid.
m_identifier
;
98
return
(
id
-
m_m
> 0) && (
id
<= 2 *
m_m
);
99
}
100
101
bool
102
CidFactory::IsBasic
(
Cid
cid)
const
103
{
104
uint16_t
id
= cid.
m_identifier
;
105
return
id
>= 1 &&
id
<=
m_m
;
106
}
107
108
void
109
CidFactory::FreeCid
(
Cid
cid)
110
{
111
/// \todo We need to update the cid bitmap properly here.
112
NS_FATAL_ERROR
(
113
"TODO: Update the cid bitmap properly here-- please implement and contribute a patch"
);
114
}
115
116
}
// namespace ns3
cid-factory.h
ns3::CidFactory::m_m
uint16_t m_m
m
Definition
cid-factory.h:95
ns3::CidFactory::Allocate
Cid Allocate(Cid::Type type)
This function returns the next CID for the specified type.
Definition
cid-factory.cc:63
ns3::CidFactory::m_basicIdentifier
uint16_t m_basicIdentifier
basic identifier
Definition
cid-factory.h:97
ns3::CidFactory::IsBasic
bool IsBasic(Cid cid) const
This function determines if the CID is basic.
Definition
cid-factory.cc:102
ns3::CidFactory::m_transportOrSecondaryIdentifier
uint16_t m_transportOrSecondaryIdentifier
transport or secondary identifier
Definition
cid-factory.h:99
ns3::CidFactory::AllocatePrimary
Cid AllocatePrimary()
This function returns the next primary basic CID.
Definition
cid-factory.cc:39
ns3::CidFactory::AllocateTransportOrSecondary
Cid AllocateTransportOrSecondary()
This function returns the next Transport (or Secondary) CID.
Definition
cid-factory.cc:47
ns3::CidFactory::m_multicastPollingIdentifier
uint16_t m_multicastPollingIdentifier
multicast polling identifier
Definition
cid-factory.h:100
ns3::CidFactory::IsPrimary
bool IsPrimary(Cid cid) const
This function determines if the CID is primary.
Definition
cid-factory.cc:95
ns3::CidFactory::AllocateBasic
Cid AllocateBasic()
This function returns the next basic CID.
Definition
cid-factory.cc:31
ns3::CidFactory::IsTransport
bool IsTransport(Cid cid) const
This function determines if the CID is a transport.
Definition
cid-factory.cc:88
ns3::CidFactory::m_primaryIdentifier
uint16_t m_primaryIdentifier
primary identifier
Definition
cid-factory.h:98
ns3::CidFactory::AllocateMulticast
Cid AllocateMulticast()
This function returns the next Multicast CID.
Definition
cid-factory.cc:55
ns3::CidFactory::CidFactory
CidFactory()
Create a cid factory with a default value for m of 0x5500.
Definition
cid-factory.cc:20
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:109
ns3::Cid
Cid class.
Definition
cid.h:26
ns3::Cid::Type
Type
Type enumeration.
Definition
cid.h:30
ns3::Cid::PRIMARY
@ PRIMARY
Definition
cid.h:34
ns3::Cid::BROADCAST
@ BROADCAST
Definition
cid.h:31
ns3::Cid::TRANSPORT
@ TRANSPORT
Definition
cid.h:35
ns3::Cid::MULTICAST
@ MULTICAST
Definition
cid.h:36
ns3::Cid::BASIC
@ BASIC
Definition
cid.h:33
ns3::Cid::PADDING
@ PADDING
Definition
cid.h:37
ns3::Cid::INITIAL_RANGING
@ INITIAL_RANGING
Definition
cid.h:32
ns3::Cid::InitialRanging
static Cid InitialRanging()
Definition
cid.cc:76
ns3::Cid::Padding
static Cid Padding()
Definition
cid.cc:70
ns3::Cid::Broadcast
static Cid Broadcast()
Definition
cid.cc:64
ns3::Cid::m_identifier
uint16_t m_identifier
identiifier
Definition
cid.h:87
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:55
NS_FATAL_ERROR
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition
fatal-error.h:168
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
wimax
model
cid-factory.cc
Generated on Mon Nov 4 2024 19:38:11 for ns-3 by
1.11.0