Implementation of basic application layer This is used to check basic LinkLayer scheduling procedures. More...
#include "ble-application.h"
Public Types | |
enum | BleApplicationState { CONNECTION_SLAVE, CONNECTION_MASTER, ADVERTISE, SCANNING } |
Public Member Functions | |
BleApplication (void) | |
Default Constructor. More... | |
virtual | ~BleApplication (void) |
void | ChangeState (BleApplicationState s) |
Change state of application. More... | |
Ptr< Packet > | CreateResponsePacket (Ptr< Packet > p) |
Create response packet to LinkLayer. More... | |
Ptr< BleLinkLayer > | GetLinkLayer (void) const |
Get LinkLayer. More... | |
Ptr< Node > | GetNode () const |
void | RxFromLinkLayer (Ptr< Packet > p, uint8_t int1, uint8_t int2) |
Received packet from LinkLayer. More... | |
void | SendRequestPacket (bool b) |
Send request packet to LinkLayer. More... | |
void | SetAdvString (char data[31]) |
Set Advertising data. More... | |
void | SetConnString (char data[100]) |
Set Connection data. More... | |
void | SetLinkLayer (Ptr< BleLinkLayer > ll) |
Set LinkLayer. More... | |
void | SetNode (Ptr< Node > node) |
void | SetStartTime (Time start) |
Public Member Functions inherited from ns3::Application | |
Application () | |
virtual | ~Application () |
Ptr< Node > | GetNode () const |
void | SetNode (Ptr< Node > node) |
void | SetStartTime (Time start) |
Specify application start time. More... | |
void | SetStopTime (Time stop) |
Specify application stop time. More... | |
Public Member Functions inherited from ns3::Object | |
Object () | |
Constructor. More... | |
virtual | ~Object () |
Destructor. More... | |
void | AggregateObject (Ptr< Object > other) |
Aggregate two Objects together. More... | |
void | Dispose (void) |
Dispose of this Object. More... | |
AggregateIterator | GetAggregateIterator (void) const |
Get an iterator to the Objects aggregated to this one. More... | |
virtual TypeId | GetInstanceTypeId (void) const |
Implement the GetInstanceTypeId method defined in ObjectBase. More... | |
template<typename T > | |
Ptr< T > | GetObject (void) const |
Get a pointer to the requested aggregated Object. More... | |
template<typename T > | |
Ptr< T > | GetObject (TypeId tid) const |
Get a pointer to the requested aggregated Object by TypeId. More... | |
void | Initialize (void) |
Invoke DoInitialize on all Objects aggregated to this one. More... | |
Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter > | |
SimpleRefCount () | |
Constructor. More... | |
SimpleRefCount (const SimpleRefCount &o) | |
Copy constructor. More... | |
uint32_t | GetReferenceCount (void) const |
Get the reference count of the object. More... | |
SimpleRefCount & | operator= (const SimpleRefCount &o) |
Assignment. More... | |
void | Ref (void) const |
Increment the reference count. More... | |
void | Unref (void) const |
Decrement the reference count. More... | |
Public Member Functions inherited from ns3::ObjectBase | |
virtual | ~ObjectBase () |
Virtual destructor. More... | |
void | GetAttribute (std::string name, AttributeValue &value) const |
Get the value of an attribute, raising fatal errors if unsuccessful. More... | |
bool | GetAttributeFailSafe (std::string name, AttributeValue &value) const |
Get the value of an attribute without raising erros. More... | |
void | SetAttribute (std::string name, const AttributeValue &value) |
Set a single attribute, raising fatal errors if unsuccessful. More... | |
bool | SetAttributeFailSafe (std::string name, const AttributeValue &value) |
Set a single attribute without raising errors. More... | |
bool | TraceConnect (std::string name, std::string context, const CallbackBase &cb) |
Connect a TraceSource to a Callback with a context. More... | |
bool | TraceConnectWithoutContext (std::string name, const CallbackBase &cb) |
Connect a TraceSource to a Callback without a context. More... | |
bool | TraceDisconnect (std::string name, std::string context, const CallbackBase &cb) |
Disconnect from a TraceSource a Callback previously connected with a context. More... | |
bool | TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb) |
Disconnect from a TraceSource a Callback previously connected without a context. More... | |
Static Public Member Functions | |
static TypeId | GetTypeId (void) |
Get the type ID. More... | |
Static Public Member Functions inherited from ns3::Application | |
static TypeId | GetTypeId (void) |
Get the type ID. More... | |
Static Public Member Functions inherited from ns3::Object | |
static TypeId | GetTypeId (void) |
Register this type. More... | |
Static Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter > | |
static void | Cleanup (void) |
Noop. More... | |
Static Public Member Functions inherited from ns3::ObjectBase | |
static TypeId | GetTypeId (void) |
Get the type ID. More... | |
Protected Member Functions | |
virtual void | StartApplication (void) |
Call to start application by starting a advertisement. More... | |
Protected Member Functions inherited from ns3::Object | |
Object (const Object &o) | |
Copy an Object. More... | |
virtual void | NotifyNewAggregate (void) |
Notify all Objects aggregated to this one of a new Object being aggregated. More... | |
Protected Member Functions inherited from ns3::ObjectBase | |
void | ConstructSelf (const AttributeConstructionList &attributes) |
Complete construction of ObjectBase; invoked by derived classes. More... | |
virtual void | NotifyConstructionCompleted (void) |
Notifier called once the ObjectBase is fully constructed. More... | |
Private Member Functions | |
virtual void | DoDispose (void) |
Destructor implementation. More... | |
virtual void | DoInitialize (void) |
Initialize() implementation. More... | |
Private Attributes | |
uint8_t | m_advData [31] |
Advertising data to be sent during advertisement. More... | |
uint8_t | m_connData [100] |
Connection data to be sent during connections. More... | |
Ptr< BleLinkLayer > | m_linkLayer |
LinkLayer connected to this application. More... | |
Ptr< Node > | m_node |
The node that this application is installed on. More... | |
Ptr< Packet > | m_pkt |
Packet to be sent or received. More... | |
EventId | m_startEvent |
The event that will fire at m_startTime to start the application. More... | |
Time | m_startTime |
The simulation time that the application will start. More... | |
BleApplicationState | m_state |
Current state of Application. More... | |
EventId | m_stopEvent |
The event that will fire at m_stopTime to end the application. More... | |
Time | m_stopTime |
The simulation time that the application will end. More... | |
Additional Inherited Members | |
Protected Attributes inherited from ns3::Application | |
Ptr< Node > | m_node |
The node that this application is installed on. More... | |
EventId | m_startEvent |
The event that will fire at m_startTime to start the application. More... | |
Time | m_startTime |
The simulation time that the application will start. More... | |
EventId | m_stopEvent |
The event that will fire at m_stopTime to end the application. More... | |
Time | m_stopTime |
The simulation time that the application will end. More... | |
Related Functions inherited from ns3::ObjectBase | |
static TypeId | GetObjectIid (void) |
Ensure the TypeId for ObjectBase gets fully configured to anchor the inheritance tree properly. More... | |
Implementation of basic application layer This is used to check basic LinkLayer scheduling procedures.
Definition at line 37 of file ble-application.h.
Enumerator | |
---|---|
CONNECTION_SLAVE | |
CONNECTION_MASTER | |
ADVERTISE | |
SCANNING |
Definition at line 41 of file ble-application.h.
ns3::BleApplication::BleApplication | ( | void | ) |
|
virtual |
Definition at line 48 of file ble-application.cc.
References NS_LOG_FUNCTION.
void ns3::BleApplication::ChangeState | ( | BleApplicationState | s | ) |
Change state of application.
s | new state of application |
Definition at line 85 of file ble-application.cc.
References m_state, and NS_LOG_FUNCTION.
Create response packet to LinkLayer.
p | input packet to create response |
This particular method will shift string packet p towards right.
Definition at line 225 of file ble-application.cc.
References ns3::Packet::CopyData(), data, ns3::Packet::GetSize(), and NS_LOG_FUNCTION.
Referenced by RxFromLinkLayer().
|
privatevirtual |
Destructor implementation.
This method is called by Dispose() or by the Object's destructor, whichever comes first.
Subclasses are expected to implement their real destruction code in an overriden version of this method and chain up to their parent's implementation once they are done. i.e, for simplicity, the destructor of every subclass should be empty and its content should be moved to the associated DoDispose() method.
It is safe to call GetObject() from within this method.
Reimplemented from ns3::Application.
Definition at line 270 of file ble-application.cc.
References ns3::EventId::Cancel(), ns3::Object::DoDispose(), m_linkLayer, m_node, m_startEvent, m_stopEvent, and NS_LOG_FUNCTION.
|
privatevirtual |
Initialize() implementation.
This method is called only once by Initialize(). If the user calls Initialize() multiple times, DoInitialize() is called only the first time.
Subclasses are expected to override this method and chain up to their parent's implementation once they are done. It is safe to call GetObject() and AggregateObject() from within this method.
Reimplemented from ns3::Application.
Definition at line 262 of file ble-application.cc.
References ns3::Object::DoInitialize(), m_startEvent, m_startTime, NS_LOG_FUNCTION, ns3::Simulator::Schedule(), and StartApplication().
Ptr< BleLinkLayer > ns3::BleApplication::GetLinkLayer | ( | void | ) | const |
Get LinkLayer.
Definition at line 78 of file ble-application.cc.
References m_linkLayer, and NS_LOG_FUNCTION.
|
static |
Get the type ID.
Definition at line 30 of file ble-application.cc.
References m_startTime, ns3::MakeTimeAccessor(), ns3::MakeTimeChecker(), ns3::Seconds(), and ns3::TypeId::SetParent().
Received packet from LinkLayer.
p | Received packet |
int1 | Integer parameter 1 |
int2 | Integer parameter 2 |
When Application is in SCANNING mode, int1 = 0 => Connection request not Allowed int1 = 1 => Conenction request allowed int1 = 2 => Only Connection request is allowed
int2 = 0 => Scan Request not allowed int2 = 1 => Scan Request allowed
When Application is in ADVERTISE mode, int2 = 0 => Received packet is Connection Request int2 = 1 => Received packet is Scan Request
When Application is in CONNECTION_SLAVE mode, int1 = int2 = 1 => Connection is closed. Change state to Advertise
When Application is in CONNECTION_MASTER mode, int1 = int2 = 1 => Connection closed int1 = 1 and int2 = 0 => ConnectionEvent restart
Definition at line 100 of file ble-application.cc.
References ADVERTISE, ns3::BleLinkLayer::BleLLChangeState(), ns3::BleLinkLayer::CONN_REQ, ns3::BleLinkLayer::CONN_SLAVE, CONNECTION_MASTER, CONNECTION_SLAVE, ns3::Packet::CopyData(), ns3::BleLinkLayer::CreateConnection(), CreateResponsePacket(), data, ns3::Packet::GetSize(), ns3::Packet::GetUid(), ns3::BleLinkLayer::LL_ADV_RX_ON, ns3::BleLinkLayer::LL_CONN_RX_ON, m_advData, m_linkLayer, m_state, ns3::Simulator::Now(), NS_LOG_DEBUG, NS_LOG_FUNCTION, ns3::BleLinkLayer::SCANNER_REQ, ns3::BleLinkLayer::SCANNER_RESP, SCANNING, ns3::Simulator::Schedule(), ns3::Simulator::ScheduleNow(), SendRequestPacket(), and ns3::BleLinkLayer::TxToPhy().
Referenced by SetLinkLayer().
void ns3::BleApplication::SendRequestPacket | ( | bool | b | ) |
Send request packet to LinkLayer.
b | Whether it is first request of connection |
Definition at line 210 of file ble-application.cc.
References CONNECTION_MASTER, m_connData, m_linkLayer, m_pkt, m_state, NS_ASSERT, NS_LOG_FUNCTION, ns3::Simulator::ScheduleNow(), and ns3::BleLinkLayer::TxToPhy().
Referenced by RxFromLinkLayer().
void ns3::BleApplication::SetAdvString | ( | char | data[31] | ) |
Set Advertising data.
data | Data to transmit in each ADV packets |
Definition at line 62 of file ble-application.cc.
References m_advData, and NS_LOG_FUNCTION.
void ns3::BleApplication::SetConnString | ( | char | data[100] | ) |
Set Connection data.
data | 100 byte data to transmit during connection |
Definition at line 54 of file ble-application.cc.
References m_connData, and NS_LOG_FUNCTION.
void ns3::BleApplication::SetLinkLayer | ( | Ptr< BleLinkLayer > | ll | ) |
Set LinkLayer.
ll | Pointer to BleLinkLayer |
Definition at line 70 of file ble-application.cc.
References m_linkLayer, ns3::MakeCallback(), NS_LOG_FUNCTION, RxFromLinkLayer(), and ns3::ObjectBase::TraceConnectWithoutContext().
void ns3::BleApplication::SetStartTime | ( | Time | start | ) |
Definition at line 92 of file ble-application.cc.
References m_startEvent, m_startTime, NS_LOG_FUNCTION, ns3::Simulator::Schedule(), visualizer.core::start(), and StartApplication().
|
protectedvirtual |
Call to start application by starting a advertisement.
Reimplemented from ns3::Application.
Definition at line 245 of file ble-application.cc.
References ADVERTISE, ns3::BleLinkLayer::ADVERTISER, ns3::BleLinkLayer::LL_ADV_RX_ON, m_advData, m_linkLayer, m_pkt, m_state, NS_LOG_FUNCTION, SCANNING, ns3::Simulator::ScheduleNow(), and ns3::BleLinkLayer::TxToPhy().
Referenced by DoInitialize(), and SetStartTime().
|
private |
Advertising data to be sent during advertisement.
Definition at line 156 of file ble-application.h.
Referenced by RxFromLinkLayer(), SetAdvString(), and StartApplication().
|
private |
Connection data to be sent during connections.
Definition at line 152 of file ble-application.h.
Referenced by SendRequestPacket(), and SetConnString().
|
private |
LinkLayer connected to this application.
Definition at line 148 of file ble-application.h.
Referenced by DoDispose(), GetLinkLayer(), RxFromLinkLayer(), SendRequestPacket(), SetLinkLayer(), and StartApplication().
The node that this application is installed on.
Definition at line 162 of file ble-application.h.
Referenced by DoDispose().
Packet to be sent or received.
Definition at line 140 of file ble-application.h.
Referenced by SendRequestPacket(), and StartApplication().
|
private |
The event that will fire at m_startTime to start the application.
Definition at line 165 of file ble-application.h.
Referenced by DoDispose(), DoInitialize(), and SetStartTime().
|
private |
The simulation time that the application will start.
Definition at line 163 of file ble-application.h.
Referenced by DoInitialize(), GetTypeId(), and SetStartTime().
|
private |
Current state of Application.
Definition at line 144 of file ble-application.h.
Referenced by ChangeState(), RxFromLinkLayer(), SendRequestPacket(), and StartApplication().
|
private |
The event that will fire at m_stopTime to end the application.
Definition at line 166 of file ble-application.h.
Referenced by DoDispose().
|
private |
The simulation time that the application will end.
Definition at line 164 of file ble-application.h.