signetlabdei / lorawan

An ns-3 module for simulation of LoRaWAN networks
GNU General Public License v2.0
190 stars 132 forks source link

A question about the ReceiveWindow #72

Closed QiuYukang closed 4 years ago

QiuYukang commented 4 years ago

Hello, I run the example/network-server-example.cc, through logs i see this:

log image This means the ED received an ACK after closing the first receive window(the second receive window has not been opened at this time). Finally the second receive window was not opened either. why this is happening? From the source code lorawan/model/class-a-end-device-lorawan-mac.cc it seems that the second receive window will still should be opened, I didn't find where you called m_secondReceiveWindow .Cancel():

void
ClassAEndDeviceLorawanMac::TxFinished (Ptr<const Packet> packet)
{
  NS_LOG_FUNCTION_NOARGS ();

  // Schedule the opening of the first receive window
  Simulator::Schedule (m_receiveDelay1,
                       &ClassAEndDeviceLorawanMac::OpenFirstReceiveWindow, this);

  // Schedule the opening of the second receive window
  m_secondReceiveWindow = Simulator::Schedule (m_receiveDelay2,
                                               &ClassAEndDeviceLorawanMac::OpenSecondReceiveWindow,
                                               this);
  // // Schedule the opening of the first receive window
  // Simulator::Schedule (m_receiveDelay1,
  //                      &ClassAEndDeviceLorawanMac::OpenFirstReceiveWindow, this);
  //
  // // Schedule the opening of the second receive window
  // m_secondReceiveWindow = Simulator::Schedule (m_receiveDelay2,
  //                                              &ClassAEndDeviceLorawanMac::OpenSecondReceiveWindow,
  //                                              this);

  // Switch the PHY to sleep
  m_phy->GetObject<EndDeviceLoraPhy> ()->SwitchToSleep ();
}

Can you please guide me on this.

Thanks and Regards

DvdMgr commented 4 years ago

Hi! If the first window is successful, the second receive window is not opened (this behavior is defined in the standard). The call to cancel is in the ClassAEndDeviceLorawanMac::Receive method, and it will only be invoked if the received message is intended for the device. You can find it at line 176 of the class-a-end-device-lorawan-mac.cc!

QiuYukang commented 4 years ago

I found it with your help, Thank you very much!