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

Packet Size of Reply Packet #61

Closed
Prapi123 opened this issue Dec 9, 2019 · 5 comments
Closed

Packet Size of Reply Packet #61

Prapi123 opened this issue Dec 9, 2019 · 5 comments

Comments

@Prapi123
Copy link

Prapi123 commented Dec 9, 2019

Hello,

When I set MType :: Confirmed Data,
I want to send packets to end devices with a particular packet size.

It would be helpful for me if you suggest how can I achieve this.

Thanks and Regards

@DvdMgr
Copy link
Member

DvdMgr commented Dec 11, 2019

If you want a fixed packet size, you can directly change the code in EndDeviceStatus::GetCompleteReplyPacket to create a packet with a set payload size!

@DvdMgr DvdMgr closed this as completed Dec 13, 2019
@Prapi123
Copy link
Author

Prapi123 commented Dec 15, 2019

Hello @DvdMgr

I have been modifying EndDeviceStatus.cc file for my convenience and I am facing some issue in it.

  1. I have used a code to modify replypaylaod size as given below
 for (NodeContainer::Iterator j = endDevices.Begin ();
       j != endDevices.End (); ++j)
  {
    Ptr<Node> node = *j;
    uint32_t senderID = node->GetId ();
    std::cout << "senderID: " << senderID << std::endl;
    Ptr<LoraNetDevice> loraNetDevice = node->GetDevice(0)->GetObject<LoraNetDevice> ();
    Ptr<LoraPhy> phy = loraNetDevice->GetPhy ();

    Ptr<LoraMac> mac = loraNetDevice->GetMac ();
    Ptr<EndDeviceLoraMac> edLoraMac = mac->GetObject<EndDeviceLoraMac> ();
    LoraDeviceAddress Address = edLoraMac->GetDeviceAddress();
    Ptr<EndDeviceStatus> edStatusP3 = CreateObject<EndDeviceStatus> (Address, edLoraMac);

    Ptr <Packet> replypayload = Create<Packet> (126);
    edStatusP3->SetReplyPayload (replypayload);

    LoraFrameHeader d = edStatusP3->GetReplyFrameHeader();
    std::cout<< d << std::endl;
  }

Above I am changing the attaching the payload with Setreplypayload() but still I can see output as below
image

It is creating an empty packet instead of creating a packet with size I have already stated.

My idea is to emulate handshake between NS and end device and so I want to create reply packet according to the size of uplink packet.
for example if uplink packet size is 30 byte then downlink packet should be 23
if uplink packet size is 50 byte then downlink packet should be 15

Thanks and Regards
@Prapi123

@DvdMgr
Copy link
Member

DvdMgr commented Dec 16, 2019

In that case, you have two ways to go about it:

  1. Undo your changes to end-device-status.cc, and create a new NetworkControllerComponent object - this will need to implement a BeforeSendingReply method, which is a callback called by the NetworkController before sending a reply, and is where you will have the chance to modify the EndDeviceStatus's reply payload by calling the SetReplyPayload method. You can use the components defined in network-controller-components.cc file to draw some inspiration about the structure and functionality. Don't forget to add it to the InstallComponents method of the NetworkServerHelper to activate it!
  2. Define all the needed logic directly inside the GetCompleteReplyPacket method: you can remove the if/else that either uses the m_reply.payload or creates a new packet from scratch, and make it so that it always creates a packet with the needed size. If you want to always send a packet with a payload of 50, for instance, you simply use replyPacket = Create<Packet> (50);.

The code you mentioned above does not work because you are creating new EndDeviceStatus objects, instead of acting upon the ones that already exist and are used in the simulation!

@DvdMgr DvdMgr reopened this Dec 16, 2019
@Prapi123
Copy link
Author

Hello,

Thanks for responding to this issue.
I could emulate TLS handshake with above recommended process.

I am trying to solve minor error, I want to create a packet replyPacket = Create (1200);
if gives an error "large integer implicitly truncated to unsigned type [-Woverflow] "

I suppose this is due to range of Unsigned integer which is 0-255 so tried to change data-type in source file. Still no luck.

@DvdMgr
Copy link
Member

DvdMgr commented Dec 19, 2019 via email

@DvdMgr DvdMgr closed this as completed Jan 9, 2020
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