Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to integrate a new model #162

Open
Vidushi0001 opened this issue Apr 16, 2024 · 2 comments
Open

How to integrate a new model #162

Vidushi0001 opened this issue Apr 16, 2024 · 2 comments

Comments

@Vidushi0001
Copy link

I have worked on drafting a code for classBEndDeviceLorawanMac and an example script to test that, but I need certain instructions on how to integrate it with the module and run it, can someone please guide?

Specifications

  • ns-3 version:
  • lorawan module version:
  • Platform:
  • Compiler:
@non-det-alle
Copy link
Collaborator

From the top of my head, here are some of the things you will probably need to do:

  • Extend ClassALorawanEndDevice with your new class B model, and introduce therein the logic for scheduling periodic beacon and ping slots
  • Add class B MAC commands by extending the MacCommand class
  • Modify/extend the NetworkServer to manage class B devices
  • ...

Please be more specific with your question.

@Vidushi0001
Copy link
Author

Vidushi0001 commented May 4, 2024

@non-det-alle I plan to extend the functionality of this module to classBLorawanEndDevice also, for the same I need to know the steps and places where I need to make changes to integrate the classBLorawanEndDevice class in the module.

The steps I think of using are:

adding the file for class-b-lorawan-end-device.cc and .h file in models folder
adding the files to the CMakeLists.txt file
specifying the build rule for implementation:

 cmake_minimum_required(VERSION 3.10)

set(CLASSB_END_DEVICE_SRCS
  class-b-end-device.cc
)

set(CLASSB_END_DEVICE_HEADERS
  class-b-end-device.h
)

ns3module_add_to_build(ClassBEndDevice
  ${CLASSB_END_DEVICE_SRCS}
  ${CLASSB_END_DEVICE_HEADERS}
)

target_include_directories(ClassBEndDevice
  PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
)

Modify lorawan-mac-helper.h and .cc file to include classBLorawanEndDevice using

void Install(LoraPhyHelper& phyHelper, NodeContainer& nodes, const ClassBEndDeviceLorawanMacParameters& parameters = ClassBEndDeviceLorawanMacParameters());

Implementing a new install method in lorawan-mac-helper.cc

void
LorawanMacHelper::Install(LoraPhyHelper& phyHelper, NodeContainer& nodes, const ClassBEndDeviceLorawanMacParameters& parameters)
{
  for (NodeContainer::Iterator i = nodes.Begin(); i != nodes.End(); ++i)
    {
      Ptr<Node> node = *i;
      Ptr<LoraDeviceMac> mac = CreateObject<ClassBEndDeviceLorawanMac> (parameters);
      phyHelper.SetDeviceType(LoraPhyHelper::ED);
      phyHelper.Install(mac, node);
    }
}

Add a line to lorawan-phy-helper.h for supporting the new class

void SetDeviceType(LoraPhyHelper::DeviceType deviceType, Ptr<LoraDeviceMac> mac);

implement new setDeviceType in lorawan-phy-helper.cc

void
LoraPhyHelper::SetDeviceType(DeviceType deviceType, Ptr<LoraDeviceMac> mac)
{
  if (deviceType == DeviceType::ED)
    {
      m_deviceType = DeviceType::ED;
      m_phy->SetDeviceType(LoraPhy::ED, mac);
    }
  else if (deviceType == DeviceType::GW)
    {
      m_deviceType = DeviceType::GW;
      m_phy->SetDeviceType(LoraPhy::GW, mac);
    }
  else
    {
      NS_ABORT_MSG("Invaliddevice type.");
    }
}

build the project
and run the simulation scenario created for testing the new class.

Please help me and correct the steps which you feel are wrong and where you feel I am doing it incorreclty and suggest the correct way

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants