shakir01 / LiFi-WiFi-Hybrid-System-in-ns3

GNU General Public License v3.0
9 stars 3 forks source link

The .Set() Relationship in Function LiFiMacHelper::CreateAPMac #4

Open PennyXQZ opened 1 year ago

PennyXQZ commented 1 year ago

Hi Shakir,

Thank you for providing such a good LiFi module. However, I am confused by the following function. Could you please give a short explain about the ".Set()" relationship between the lifiMac, lifiMaclow, lifiChannel, lifiPhy, lifiDevice, and lifiApNode? Or, could you give me some advice to figure out the relationships, why they are required to be set for each other?

I look forward to hearing from you. Thanks a lot!

NetDeviceContainer LiFiMacHelper::CreateAPMac (Ptr<Node> node, ns3::Ptr<LiFiPhy> lifiPhy, Ptr<LiFiChannelHelper> channelHelper,Ptr<NetDevice> ccnetdevice)
{
    NS_LOG_FUNCTION (this);
    Ptr<PointToPointNetDevice> netdevice = ns3::DynamicCast<PointToPointNetDevice> (ccnetdevice);

    Ptr<LiFiApMac> app_mac = CreateObject<LiFiApMac> ();
    app_mac-> SetCCMacAddress (netdevice->GetAddress());
    NetDeviceContainer devices;
    Ptr<LiFiChannel> channel = channelHelper->GetChannel(node->GetId());
    lifiPhy->SetChannel(channel);
    //Ptr<TdmaCentralMac> mac = CreateObject<TdmaCentralMac> ();
    ns3::Ptr<LiFiNetDevice> device = CreateObject<LiFiNetDevice> ();
    app_mac->SetAddress (Mac48Address::Allocate ());
    lifiPhy->SetDevice(device);
    app_mac->SetNode(node);
    Ptr<LiFiMacLow> LiFiMacLow = app_mac->GetMacLow();
    lifiPhy->SetMacLow(LiFiMacLow);
    LiFiMacLow->SetPhy(lifiPhy);
    //device->SetMacHigh (app_mac);
    node->AddDevice (device);
    device->SetMac(app_mac);
    //app_mac->SetMac(mac);
    //app_mac->SetDevice(device);
    //app_mac->SetMacLow(LiFiMacLow);
    //mac->SetLiFiApMac(app_mac);
    m_remoteStationManager->AddMac(app_mac,app_mac->GetAddress());
    app_mac->SetRemoteStationManager(m_remoteStationManager);
    m_lifi_ap_netDevicesMap.insert (std::pair<uint32_t,Ptr<LiFiApMac> >(node->GetId(), app_mac)); 
    return NetDeviceContainer(device);
}