A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ns3::BleSensorApplication Class Reference

Implementation of senssor application. More...

#include "ble-sensor-application.h"

+ Inheritance diagram for ns3::BleSensorApplication:
+ Collaboration diagram for ns3::BleSensorApplication:

Public Types

enum  BleApplicationState {
  CONNECTION_SLAVE, CONNECTION_MASTER, ADVERTISE, SCANNING,
  IDLE
}
 

Public Member Functions

 BleSensorApplication (void)
 Default Constructor. More...
 
virtual ~BleSensorApplication (void)
 
void AnalyseResponsePacket (Ptr< Packet > p)
 Analyse Response Packet and send ACK. More...
 
void AnalyseScanResponsePacket (Ptr< Packet > p)
 Analyse Scan Response Packet. More...
 
void ChangeState (BleApplicationState s)
 Change state of application. More...
 
Ptr< BleLinkLayerGetLinkLayer (void) const
 Get LinkLayer. More...
 
Ptr< NodeGetNode () const
 
void RxFromLinkLayer (Ptr< Packet > p, uint8_t int1, uint8_t int2)
 Received packet from LinkLayer. More...
 
void SendAdvPacket (void)
 Create and Send AdvPacket. More...
 
void SendRequestPacket (bool b)
 Send request packet to LinkLayer. More...
 
void SendResponsePacket (Ptr< Packet > p)
 Send Response Packet to LinkLayer. More...
 
void SendScanResponse (Ptr< Packet > p)
 Create and Send Scan Request. More...
 
void SensingEvent (void)
 Called at every 1 hr. 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< NodeGetNode () 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...
 
SimpleRefCountoperator= (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

void PauseApplication (void)
 Call to pause the application. More...
 
virtual void StartApplication (void)
 Call to start application by starting an 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...
 
BleTimeStamp TimetoTimeStamp (Time t)
 Time to TimeStamp Converter. More...
 

Private Attributes

bool isMoreData
 MoreData remaining? More...
 
std::queue< std::pair
< BleTimeStamp, bool > > 
m_data
 ConnData. More...
 
bool m_isOpen
 Open/Close. More...
 
Ptr< BleLinkLayerm_linkLayer
 LinkLayer connected to this application. More...
 
Ptr< Nodem_node
 The node that this application is installed on. More...
 
Ptr< UniformRandomVariablem_random
 Random stream for sensing event – Number of sensing events per day. More...
 
uint64_t m_senseCount
 Sensing count. 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< Nodem_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...
 

Detailed Description

Implementation of senssor application.

Definition at line 45 of file ble-sensor-application.h.

Member Enumeration Documentation

Enumerator
CONNECTION_SLAVE 
CONNECTION_MASTER 
ADVERTISE 
SCANNING 
IDLE 

Definition at line 49 of file ble-sensor-application.h.

Constructor & Destructor Documentation

ns3::BleSensorApplication::BleSensorApplication ( void  )

Default Constructor.

Definition at line 43 of file ble-sensor-application.cc.

References IDLE, m_isOpen, m_random, m_state, NS_LOG_FUNCTION, ns3::Simulator::Schedule(), ns3::Seconds(), and SensingEvent().

+ Here is the call graph for this function:

ns3::BleSensorApplication::~BleSensorApplication ( void  )
virtual

Definition at line 52 of file ble-sensor-application.cc.

References m_senseCount, NS_LOG_DEBUG, and NS_LOG_FUNCTION.

Member Function Documentation

void ns3::BleSensorApplication::AnalyseResponsePacket ( Ptr< Packet p)

Analyse Response Packet and send ACK.

Parameters
pRecevied Response Packet

Definition at line 269 of file ble-sensor-application.cc.

References ns3::Packet::CopyData(), ns3::Packet::CreateFragment(), data, ns3::Packet::GetSize(), m_linkLayer, NS_LOG_DEBUG, NS_LOG_FUNCTION, NS_LOG_INFO, ns3::Simulator::ScheduleNow(), and ns3::BleLinkLayer::TxToPhy().

Referenced by RxFromLinkLayer().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::BleSensorApplication::AnalyseScanResponsePacket ( Ptr< Packet p)

Analyse Scan Response Packet.

Parameters
pRecevied Scan Response Packet

Definition at line 215 of file ble-sensor-application.cc.

References ns3::Packet::CopyData(), data, ns3::Packet::GetSize(), NS_LOG_DEBUG, NS_LOG_FUNCTION, and NS_LOG_INFO.

Referenced by RxFromLinkLayer().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::BleSensorApplication::ChangeState ( BleSensorApplication::BleApplicationState  newVal)

Change state of application.

Parameters
snew state of application

Definition at line 74 of file ble-sensor-application.cc.

References ADVERTISE, m_data, m_state, NS_LOG_FUNCTION, and SendAdvPacket().

Referenced by SensingEvent().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::BleSensorApplication::DoDispose ( void  )
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 366 of file ble-sensor-application.cc.

References ns3::EventId::Cancel(), ns3::Object::DoDispose(), m_linkLayer, m_node, m_startEvent, m_stopEvent, and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

void ns3::BleSensorApplication::DoInitialize ( void  )
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 358 of file ble-sensor-application.cc.

References ns3::Object::DoInitialize(), m_startEvent, m_startTime, NS_LOG_FUNCTION, ns3::Simulator::Schedule(), and StartApplication().

+ Here is the call graph for this function:

Ptr< BleLinkLayer > ns3::BleSensorApplication::GetLinkLayer ( void  ) const

Get LinkLayer.

Returns
Pointer to BleLinkLayer

Definition at line 67 of file ble-sensor-application.cc.

References m_linkLayer, and NS_LOG_FUNCTION.

Ptr<Node> ns3::BleSensorApplication::GetNode ( ) const
TypeId ns3::BleSensorApplication::GetTypeId ( void  )
static

Get the type ID.

Returns
the object TypeId

Definition at line 30 of file ble-sensor-application.cc.

References m_startTime, ns3::MakeTimeAccessor(), ns3::MakeTimeChecker(), ns3::Seconds(), and ns3::TypeId::SetParent().

+ Here is the call graph for this function:

void ns3::BleSensorApplication::PauseApplication ( void  )
protected

Call to pause the application.

Note
it will not stop the sensing. Sensing will be ongoing
void ns3::BleSensorApplication::RxFromLinkLayer ( Ptr< Packet p,
uint8_t  int1,
uint8_t  int2 
)

Received packet from LinkLayer.

Parameters
pReceived packet
int1Integer parameter 1
int2Integer 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 94 of file ble-sensor-application.cc.

References ADVERTISE, AnalyseResponsePacket(), AnalyseScanResponsePacket(), ns3::BleLinkLayer::BleLLChangeState(), ns3::BleLinkLayer::CONN_REQ, ns3::BleLinkLayer::CONN_SLAVE, CONNECTION_MASTER, CONNECTION_SLAVE, ns3::BleLinkLayer::CreateConnection(), ns3::Packet::GetUid(), IDLE, ns3::BleLinkLayer::LL_ADV_RX_ON, ns3::BleLinkLayer::LL_CONN_RX_ON, m_data, m_linkLayer, m_state, ns3::Simulator::Now(), NS_LOG_FUNCTION, NS_LOG_INFO, SCANNING, ns3::Simulator::Schedule(), ns3::Simulator::ScheduleNow(), SendRequestPacket(), SendResponsePacket(), and SendScanResponse().

Referenced by SetLinkLayer().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::BleSensorApplication::SendAdvPacket ( void  )

Create and Send AdvPacket.

Definition at line 318 of file ble-sensor-application.cc.

References ns3::BleLinkLayer::ADVERTISER, data, IDLE, m_data, m_linkLayer, m_state, NS_LOG_FUNCTION, ns3::Simulator::ScheduleNow(), and ns3::BleLinkLayer::TxToPhy().

Referenced by ChangeState(), and StartApplication().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::BleSensorApplication::SendRequestPacket ( bool  b)

Send request packet to LinkLayer.

Parameters
bWhether it is first request of connection

Definition at line 377 of file ble-sensor-application.cc.

References CONNECTION_MASTER, data, m_linkLayer, m_state, NS_ASSERT, NS_LOG_FUNCTION, ns3::Simulator::ScheduleNow(), and ns3::BleLinkLayer::TxToPhy().

Referenced by RxFromLinkLayer().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::BleSensorApplication::SendResponsePacket ( Ptr< Packet p)

Send Response Packet to LinkLayer.

Parameters
pRequest packet

Definition at line 237 of file ble-sensor-application.cc.

References ns3::Packet::CopyData(), data, ns3::BleTimeStamp::day, ns3::BleTimeStamp::hours, m_data, m_linkLayer, ns3::BleTimeStamp::minute, ns3::BleTimeStamp::month, NS_LOG_FUNCTION, ns3::Simulator::ScheduleNow(), ns3::BleTimeStamp::second, ns3::BleLinkLayer::TxToPhy(), and ns3::BleTimeStamp::year.

Referenced by RxFromLinkLayer().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::BleSensorApplication::SendScanResponse ( Ptr< Packet p)
void ns3::BleSensorApplication::SensingEvent ( void  )

Called at every 1 hr.

If sensed then record time.

Definition at line 394 of file ble-sensor-application.cc.

References ADVERTISE, ChangeState(), CONNECTION_SLAVE, ns3::UniformRandomVariable::GetValue(), IDLE, m_data, m_isOpen, m_random, m_senseCount, m_state, ns3::Minutes(), ns3::Simulator::Now(), NS_LOG_FUNCTION, SCANNING, ns3::Simulator::Schedule(), and TimetoTimeStamp().

Referenced by BleSensorApplication().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::BleSensorApplication::SetLinkLayer ( Ptr< BleLinkLayer ll)

Set LinkLayer.

Parameters
llPointer to BleLinkLayer

Definition at line 59 of file ble-sensor-application.cc.

References m_linkLayer, ns3::MakeCallback(), NS_LOG_FUNCTION, and RxFromLinkLayer().

+ Here is the call graph for this function:

void ns3::BleSensorApplication::SetNode ( Ptr< Node node)
void ns3::BleSensorApplication::SetStartTime ( Time  start)

Definition at line 86 of file ble-sensor-application.cc.

References m_startEvent, m_startTime, NS_LOG_FUNCTION, ns3::Simulator::Schedule(), visualizer.core::start(), and StartApplication().

+ Here is the call graph for this function:

void ns3::BleSensorApplication::StartApplication ( void  )
protectedvirtual

Call to start application by starting an advertisement.

Reimplemented from ns3::Application.

Definition at line 304 of file ble-sensor-application.cc.

References ADVERTISE, ns3::BleLinkLayer::LL_ADV_RX_ON, m_linkLayer, m_state, NS_LOG_FUNCTION, SCANNING, and SendAdvPacket().

Referenced by DoInitialize(), and SetStartTime().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

BleTimeStamp ns3::BleSensorApplication::TimetoTimeStamp ( Time  t)
private

Member Data Documentation

bool ns3::BleSensorApplication::isMoreData
private

MoreData remaining?

Definition at line 172 of file ble-sensor-application.h.

std::queue<std::pair<BleTimeStamp, bool> > ns3::BleSensorApplication::m_data
private
bool ns3::BleSensorApplication::m_isOpen
private

Open/Close.

Definition at line 188 of file ble-sensor-application.h.

Referenced by BleSensorApplication(), and SensingEvent().

Ptr<BleLinkLayer> ns3::BleSensorApplication::m_linkLayer
private
Ptr<Node> ns3::BleSensorApplication::m_node
private

The node that this application is installed on.

Definition at line 197 of file ble-sensor-application.h.

Referenced by DoDispose().

Ptr<UniformRandomVariable> ns3::BleSensorApplication::m_random
private

Random stream for sensing event – Number of sensing events per day.

Definition at line 184 of file ble-sensor-application.h.

Referenced by BleSensorApplication(), and SensingEvent().

uint64_t ns3::BleSensorApplication::m_senseCount
private

Sensing count.

Definition at line 192 of file ble-sensor-application.h.

Referenced by SensingEvent(), and ~BleSensorApplication().

EventId ns3::BleSensorApplication::m_startEvent
private

The event that will fire at m_startTime to start the application.

Definition at line 200 of file ble-sensor-application.h.

Referenced by DoDispose(), DoInitialize(), and SetStartTime().

Time ns3::BleSensorApplication::m_startTime
private

The simulation time that the application will start.

Definition at line 198 of file ble-sensor-application.h.

Referenced by DoInitialize(), GetTypeId(), and SetStartTime().

BleApplicationState ns3::BleSensorApplication::m_state
private
EventId ns3::BleSensorApplication::m_stopEvent
private

The event that will fire at m_stopTime to end the application.

Definition at line 201 of file ble-sensor-application.h.

Referenced by DoDispose().

Time ns3::BleSensorApplication::m_stopTime
private

The simulation time that the application will end.

Definition at line 199 of file ble-sensor-application.h.


The documentation for this class was generated from the following files: