Hello everybody,
Is there any one can give me some information or show me an example of how to set up a packet socket to receive broadcast messages within its network (ad hoc)? Is it the same way to set up the packet socket as it receive the unicast messages? I look though the examples of csma-packet-socket, wifi-adhoc and others and set up the socket to receive messages but it cannot receive any broadcast message from other nodes in my simulation.
My code likes following
void
AgentImpl::SetUpReceive (Ptr<node> node)
{
Ptr<Socket> socket = Socket::CreateSocket (node, PacketSocketFactory::GetTypeId());
socket->Bind ();
socket->SetRecvCallback (MakeCallback (&AgentImpl::RecvPacket, this));
}
Ptr<socket>
AgentImpl::RecvPacket
{...}
Thank you in advance.
Yan
Thanks for your answering. I also try to provide a PacketSocketAddress to bind for this socket for sending and also receiving messages. But it still cannot receive messages. For receiving, PacketSocketAddress value likes following:
PacketSocketAddress ad;
ad.SetSingleDevice(m_device->GetIfIndex ());
ad.SetPhysicalAddress (m_device->GetAddress());
0x8069688, 0x80728c0, -66.3931, wifia-6mbs, 0)
Probably because there is a bug in another part of the scenario topology
description. You need to provide more code and context.
Mathieu
Yes, and the same with multicast packets.
> I don't exactly know why, I guess the rate manager cannot assume
> everyone to be able to receive all rates.
Exactly. This is a generic problem with every wireless network:
broadcast packets are usually sent with the most wasteful transmission
mode to ensure _everyone_ gets it.
Mathieu
... and nothing happens after this...
Which means that either the packet does not reach the receiving packet
socket itself.
try NS_LOG=PacketSocket:AdhocWifiMac:WifiPhy:YansWifiPhy
Mathieu
AdhocWifiMac:WifiPhy:YansWifiPhy0ns WifiPhy:WifiPhy(0x8069668)
Yes, I think so. Now would be time for you to run the code in a debugger
and trace packets from the phy layer.
Mathieu
> 1452961424ns PacketSocket:Connect()
> 1452961424ns PacketSocket:Send()
> 1452961424ns PacketSocket:SendTo()
packet sent
> 1452961424ns AdhocWifiMac:Enqueue(72, ff:ff:ff:ff:ff:ff)
> 1452961424ns WifiPhy:SendPacket(0x806a280, 0x806d9b8, wifia-6mbs, 0,
> 0)
> 1452961469ns WifiPhy:StartReceivePacket(0x8069668, 0x80728a0,
> -72.6166, wifia-6mbs, 0)
> 1452961469ns WifiPhy:StartReceivePacket(): sync (power=6.89188e-11W)
> 1453121469ns WifiPhy:EndSync(0x8069668, 0x80728a0, 0x806e0e0)
> 1453121469ns WifiPhy:GetBpskBer(): bpsk snr=171.765 ber=7.82059e-127
> 1453121469ns WifiPhy:GetBpskBer(): bpsk snr=171.765 ber=7.82059e-127
> 1453121469ns WifiPhy:EndSync(): 1453121469ns WifiPhy:GetBpskBer():
> bpsk snr=171.765 ber=7.82059e-127
> mode=6000000, ber=0, snr=171.765, per=0, size=100
received at phy layer
> 1453121469ns AdhocWifiMac:ForwardUp(): received size=72,
received at mac layer
... nothing else ...
put a breakpoint in AdhocWifiMac::ForwardUp and see where it is going.
Mathieu
http://www.nsnam.org/wiki/index.php/User_FAQ#How_to_run_programs_with_gdb
Mathieu