epcHelper->AddUe(staDevices.Get(u), 310150123450000+u);
sgwpgwapp->SetUeAddress(310150123450000+u, staNode->GetObject<Ipv4>()->GetAddress(1,0).GetLocal(),ueNodes.Get(0)->GetObject<Ipv4>()->GetAddress(1,0).GetLocal());
...
Ptr<Node> n = ... ; // this is the node with two devices
Ptr<NetDevice> dev0 = n->GetDevice(0); // let's say this is the Wifi
dev0->SetReceiveCallback ( Makecallback (&WifiRecvHandler) ); //You'll write what you want to do in WifiRecvHandler
Ptr<NetDevice> dev1 = n->GetDevice(1); // let's say this is LteEnbNetDevice
dev1->SetReceiveCallback ( Makecallback (&LteRecvHandler) ); //SetReceiveCallback is defined in LteNetDevice, baseclass for LteUeNetDevice & LteEnbNetDevice
...
//Handle packets received by Wifi
bool WifiRecvHandler ( Ptr<NetDevice> dev, Ptr<NetDevice>, Ptr<const Packet> packet, uint16_t ether, const Address & from)
{
Ptr<Node> n = dev->GetNode();
Ptr<NetDevice> n1 = n->GetDevice(1); //Get the other net device, the lte
Ptr<LteEnbNetDevice> lteEnbDev = DynamicCast<LteEnbNetDevice>(n1);
if ( /* some condition */ )
{
//send packet 'p' using LTE to 'destAddr'
lteEnbDev->Send (p , destAddr, protocol);
}
...
return true;
}
//Handle packets received from Lte.
bool LteRecvHandler ( Ptr<NetDevice> dev, Ptr<NetDevice>, Ptr<const Packet> p, uint16_t ether, const Address & from)
{
Ptr<Node> n = dev->GetNode();
Ptr<NetDevice> n1 = n->GetDevice(0); //get the WifiNetDevice device
Ptr<WifiNetDevice> wifiDev = DynamicCast<WifiNetDevice>(n1);
if ( /* some condition */ )
{
//send packet 'p' using wifi.
wifiDev->Send (p , destAddr, protocol);
}
...
return true;
}