Connection LTE - Wifi NetDevices on same node

150 views
Skip to first unread message

Giacomo Segala

unread,
May 7, 2019, 9:31:00 AM5/7/19
to ns-3-users
Hello everyone,
I have a node with two NetDevices, LTE and Wifi. Indeed, the node is connected to an eNB (and EPC) and at the same time it provides AP functionalities to some Wifi users which connect to it. I have to send UDP packets from EPC to one of these Wifi users but the system doesn't work. I'm pretty sure the problem is inside the node with two NetDevices: the packets which come from EPC don't arrive to Wifi NetDevice through the LTE NetDevice. I read that bridge can not be implemented between two Netdevices if one of them is of LTE type. So, can anyone know how to solve my problem? Any suggestions? Thanks a lot, it's quite important for me!
Message has been deleted

Gabriel Ferreira

unread,
May 8, 2019, 2:45:01 PM5/8/19
to ns-3-users
You probably need a NAT at the AP. Or, if you like ugly hacks, register the STAs on the EPC and configure the EPC to forward the STAs packets through a specific UE. 
If you're looking for the ugly hack version, you can check the code in here, but comments of the simulation part are in portuguese. You will need both the loop configuring the STAs in the simulation file, plus the changes to the epc-pgw-sgw-application. 

Giacomo Segala

unread,
May 8, 2019, 2:52:38 PM5/8/19
to ns-3-users
Hello,
thanks a lot for the answer. I was pretty sure I need a NAT at the AP. Could you give me some suggestions about how to implement NAT? 
For the other possbility with ugly hacks, sorry but the link you put in your answer doesn't work!

Gabriel Ferreira

unread,
May 8, 2019, 3:22:02 PM5/8/19
to ns-3-users
Oh, my bad, my commit was in a private repo. Try this one.
The implementation of a NAT is pretty straightforward in the real world, but in the ns-3 is more complicated. You need to map the source ports and IP to a new port, rewrite the packet header with your address and port instead of the STA ones, and then do the inverse when the packet is received. How would you do that in the ns-3 network layer is a good question.

Giacomo Segala

unread,
May 9, 2019, 5:01:10 AM5/9/19
to ns-3-users
But, in practice, can EPC transmit packets only to NetDevices which are UE? If so, my problem wouldn't the lack of connectivity between LTE NetDevice and Wifi NetDevice but the fact that it's not possible to send packets from EPC to a NetDevice which is not a UE.

Gabriel Ferreira

unread,
May 9, 2019, 8:15:45 AM5/9/19
to ns-3-users
That's what you would expect from an EPC. The ugly hack was registering the WiFi STA as UEs and forwarding their packets through one of the UEs with the WiFi AP interface, that would forward those packets through the WiFi interface. It basically create new forwarding rules with the end result you wanted, but accomplished in a pretty ugly way. If you implemented the NAT, it would solve your problem and would look nicer.

Giacomo Segala

unread,
May 9, 2019, 8:57:59 AM5/9/19
to ns-3-users
I've understood what you say. However, also if I implement NAT, for EPC the destination is always a Wifi NetDevice and not a UE. So EPC couldn't still transmit packets because the destination would not be a UE. Or my logic is wrong?

Gabriel Ferreira

unread,
May 9, 2019, 10:44:27 AM5/9/19
to ns-3-users
If you implement a NAT in the UE-AP node, all packets with IPs from the WiFi STAs will be replaced by the UE IP. 
The UE-AP node will forward the packets to the EPC via LTE-Uu. 
The remote server will receive the UE address from the UE-AP node, and will send packets to it. 
The EPC will correctly forward the remove server packets to the UE-AP node. 
The UE-AP node will have to check the packet target port on the NAT, replace the address and port fields with the ones from the associated STA, and then it will forward it to the WiFi interface.

Giacomo Segala

unread,
Jun 13, 2019, 5:29:24 AM6/13/19
to ns-3-users
Hello Gabriel,
I'm writing you again because I think there is a problem somewhere with your "ugly hack". 
Sometimes, the error cur->tid != tag.GetInstanceTypeId (), "Error: cannot add the same kind of tag twice." comes out. I strongly believe that the error comes out with the following lines of codes:

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());

So the problem is in the code you've modified in epc-sgw-pgw-application. Have you got any idea about how to solve this error? 
Thanks again.

Adil Alsuhaim

unread,
Jun 16, 2019, 4:56:55 AM6/16/19
to ns-3-users
You should try running your simulation with a debugger like gdb to pinpoint the line where the error happen. As I told you, this is the result of AddPacketTag call somewhere in there.

By the way, all ns3 NetDevice objects have a SetReceiveCallback function that you can use to determine what you do when the device receives a packet.

I haven't worked with LTE in ns3 in years, but something like this should work:

...
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;
}

Reply all
Reply to author
Forward
0 new messages