use packet socket to receive broadcast messages

1,248 views
Skip to first unread message

yan zhang

unread,
Feb 23, 2009, 4:44:11 PM2/23/09
to ns-3-...@googlegroups.com
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

Gustavo Carneiro

unread,
Feb 23, 2009, 5:14:04 PM2/23/09
to ns-3-...@googlegroups.com


2009/2/23 yan zhang <yan.zh...@gmail.com>

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

I think you need to pass a PacketSocketAddress value as argument to Bind.  I have no idea idea why Bind () with no argument is even allowed...

In the PacketSocketAddress you should call SetXxx methods to set the appropriate attributes, but I'm sure you'll figure it out easily.
 

  socket->SetRecvCallback (MakeCallback (&AgentImpl::RecvPacket, this));
}
Ptr<socket>
AgentImpl::RecvPacket
{...}

Thank you in advance.
Yan





--
Gustavo J. A. M. Carneiro
INESC Porto, Telecommunications and Multimedia Unit
"The universe is always one step beyond logic." -- Frank Herbert

yan zhang

unread,
Feb 23, 2009, 5:32:48 PM2/23/09
to ns-3-...@googlegroups.com
Hello Gustavo,

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());
//  ad.SetProtocol (1);

  socket->Bind (Address (ad));

 and for sending,

  PacketSocketAddress addr;
  addr.SetSingleDevice(m_device->GetIfIndex ());
  addr.SetPhysicalAddress (m_device->GetBroadcast());
//  addr.SetProtocol (1);

  socket->Bind (Address (ad));
  socket->Connect (Address (addr));

But I still cannot receive any message when the nodes within the radio range of each other. :-( Any possible reasons?

Gustavo Carneiro

unread,
Feb 23, 2009, 6:05:47 PM2/23/09
to ns-3-...@googlegroups.com


2009/2/23 yan zhang <yan.zh...@gmail.com>
Hello Gustavo,


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

Shouldn't it be GetBroadcas() here, instead of in addr below?

If problem persists someone needs to activate PacketSocket logging and look at the source code to understand what is failing.

As last resource you could also use Node::RegisterProtocolListener, instead of packet socket.  But I think packet socket should also work...
 

Mihai Oprea

unread,
Feb 23, 2009, 6:15:20 PM2/23/09
to ns-3-...@googlegroups.com
From my experience so far: If two nodes try to send and receive at the same time over an adhoc network then a collision occurs and the packets just disappear. I would try to enable the WifiPhy layer debugging in order to rule out this possibility and catch any possible errors.

Mihai
--
Mihai Oprea

School of Engineering and Applied Science
University of Pennsylvania '09
US: +1 (970) 412 1909
RO: +40 (72) 000 2704

yan zhang

unread,
Feb 23, 2009, 6:30:45 PM2/23/09
to ns-3-...@googlegroups.com
I also try bind

  PacketSocketAddress ad;
  ad.SetSingleDevice(m_device->GetIfIndex ());
  ad.SetPhysicalAddress (m_device->GetBroadcast());
  socket->bind (Address (ad));
for receiving socket. it still doesn't work. I also try to look through packet socket source code but i still cannot get answer.

yan zhang

unread,
Feb 23, 2009, 6:36:05 PM2/23/09
to ns-3-...@googlegroups.com
Hello Mihai,

Thanks for answer. The two nodes in my simulation now can broadcast messages normally but neighbor of them can receive messages from the other. Could you explain how to enable the wifiphy layer debugging to rule out this possibility? Thanks

Mihai Oprea

unread,
Feb 23, 2009, 7:44:40 PM2/23/09
to ns-3-...@googlegroups.com
try this in your shell before starting up the ./waf --run command:
export NS_LOG=WifiPhy:log_all

Again, if both of them broadcast exactly at the same time then you will most likely have a collision.

Mihai

Mathieu Lacage

unread,
Feb 24, 2009, 3:24:57 AM2/24/09
to ns-3-...@googlegroups.com
A complete testcase we can run would help a lot to debug this.

yan zhang

unread,
Feb 24, 2009, 9:42:57 AM2/24/09
to ns-3-...@googlegroups.com
I add a jitter when I broadcast messages and now I get following result (two node and each broadcasts one message)

0ns WifiPhy:WifiPhy(0x8069688)
0ns WifiPhy:SetEdThreshold(0x8069688, -140)
0ns WifiPhy:SetTxGain(0x8069688, 1)
0ns WifiPhy:SetRxGain(0x8069688, 1)
0ns WifiPhy:SetTxPowerEnd(0x8069688, 7)
0ns WifiPhy:SetTxPowerStart(0x8069688, 7)
0ns WifiPhy:SetRxNoise(0x8069688, 7)
0ns WifiPhy:SetStandard(0x8069688, 0)
0ns WifiPhy:Configure80211a(0x8069688)
0ns WifiPhy:Configure80211aParameters(0x8069688)
0ns WifiPhy:WifiPhy(0x806a2a0)
0ns WifiPhy:SetEdThreshold(0x806a2a0, -140)
0ns WifiPhy:SetTxGain(0x806a2a0, 1)
0ns WifiPhy:SetRxGain(0x806a2a0, 1)
0ns WifiPhy:SetTxPowerEnd(0x806a2a0, 7)
0ns WifiPhy:SetTxPowerStart(0x806a2a0, 7)
0ns WifiPhy:SetRxNoise(0x806a2a0, 7)
0ns WifiPhy:SetStandard(0x806a2a0, 0)
0ns WifiPhy:Configure80211a(0x806a2a0)
0ns WifiPhy:Configure80211aParameters(0x806a2a0)
Created orwar::AgentImpl
Starting ORWAR on node 0
ORWAR-INFORMATION on node 0 started
Created orwar::AgentImpl
Starting ORWAR on node 1
ORWAR-INFORMATION on node 1 started
ORWAR node 0 sending a Information message
ORWAR node 0 sending a ORWAR packet
1365251914ns WifiPhy:SendPacket(0x8069688, 0x806d9d8, wifia-6mbs, 0, 0)
1365251940ns WifiPhy:StartReceivePacket(0x806a2a0, 0x8072588, -65.6524, wifia-6mbs, 0)
1365251940ns WifiPhy:StartReceivePacket(): sync (power=3.42577e-10W)
1365411940ns WifiPhy:EndSync(0x806a2a0, 0x8072588, 0x80725c0)
1365411940ns WifiPhy:GetBpskBer(): bpsk snr=853.802 ber=0
1365411940ns WifiPhy:GetBpskBer(): bpsk snr=853.802 ber=0
1365411940ns WifiPhy:EndSync(): 1365411940ns WifiPhy:GetBpskBer(): bpsk snr=853.802 ber=0
mode=6000000, ber=0, snr=853.802, per=0, size=100
ORWAR node 1 sending a Information message
ORWAR node 1 sending a ORWAR packet
1430142806ns WifiPhy:SendPacket(0x806a2a0, 0x806d9d8, wifia-6mbs, 0, 0)
1430142833ns WifiPhy:StartReceivePacket(0x8069688, 0x80728c0, -66.3931, wifia-6mbs, 0)
1430142833ns WifiPhy:StartReceivePacket(): sync (power=2.8886e-10W)
1430302833ns WifiPhy:EndSync(0x8069688, 0x80728c0, 0x806e100)
1430302833ns WifiPhy:GetBpskBer(): bpsk snr=719.924 ber=0
1430302833ns WifiPhy:GetBpskBer(): bpsk snr=719.924 ber=0
1430302833ns WifiPhy:EndSync(): 1430302833ns WifiPhy:GetBpskBer(): bpsk snr=719.924 ber=0
mode=6000000, ber=0, snr=719.924, per=0, size=100
WifiPhy:DoDispose(0x8069688)
WifiPhy:DoDispose(0x806a2a0)
WifiPhy:~WifiPhy(0x8069688)
WifiPhy:~WifiPhy(0x806a2a0)

Does this mean my wifiphy has already successfully received message? from .tr and pcap traces it seems that nodes receive these messages, but for my packetsocket , parts of code following
void
AgentImpl::Start ()  
{
  NS_LOG_DEBUG ("Starting ORWAR on node " << m_nodeId);
  m_packetSocket = Socket::CreateSocket (GetObject<Node> (), PacketSocketFactory::GetTypeId());

  PacketSocketAddress addr;
  addr.SetSingleDevice(m_device->GetIfIndex ());
  addr.SetPhysicalAddress (m_device->GetAddress());
//  addr.SetProtocol (1);
  if (m_packetSocket->Bind (Address (addr)))
    {
      NS_FATAL_ERROR ("Failed to bind() ORWAR receive socket");
    }
  m_packetSocket->SetRecvCallback (MakeCallback(&AgentImpl::RecvORWAR, this));

  Simulator::Schedule (Seconds (1)  + JITTER, &AgentImpl::InformationTimerExpire, this);

  NS_LOG_DEBUG ("ORWAR-INFORMATION on node " << m_nodeId << " started");
}

RecvORWAR() function seems not be implemented in simulation. Is there something wrong with my code when I want to use packet socket to receive messages?

Thanks a lot in advance.

PS. It's a little difficult for me to provide a test case. I am working on a routing and forwarding procotol. There are lots of code... 

yan zhang

unread,
Feb 24, 2009, 9:46:34 AM2/24/09
to ns-3-...@googlegroups.com
And one more question, I do the simulation with setting

  WifiHelper wifi;
  wifi.SetMac ("ns3::AdhocWifiMac");
  wifi.SetPhy ("ns3::WifiPhy",    
               "EnergyDetectionThreshold", DoubleValue (-140),
               "TxGain", DoubleValue (1),
               "RxGain", DoubleValue (1),              
               "TxPowerLevels", UintegerValue (1),
               "TxPowerEnd", DoubleValue (7),
               "TxPowerStart", DoubleValue (7));
  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
                                "DataMode", StringValue ("wifia-54mbs"));

And when I find the Log says
 
mode=6000000, ber=0, snr=853.802, per=0, size=100
ORWAR node 1 sending a Information message
ORWAR node 1 sending a ORWAR packet
1430142806ns WifiPhy:SendPacket(0x806a2a0, 0x806d9d8, wifia-6mbs, 0, 0)
1430142833ns WifiPhy:StartReceivePacket(
0x8069688, 0x80728c0, -66.3931, wifia-6mbs, 0)

I change the datamode value, but every time gets same result. Why?

Thanks a lot.

Best wishes,
Yan

Mathieu Lacage

unread,
Feb 24, 2009, 9:52:40 AM2/24/09
to ns-3-...@googlegroups.com
On Tue, 2009-02-24 at 15:46 +0100, yan zhang wrote:
> And one more question, I do the simulation with setting
>
> WifiHelper wifi;
> wifi.SetMac ("ns3::AdhocWifiMac");
> wifi.SetPhy ("ns3::WifiPhy",
> "EnergyDetectionThreshold", DoubleValue (-140),
> "TxGain", DoubleValue (1),
> "RxGain", DoubleValue (1),
> "TxPowerLevels", UintegerValue (1),
> "TxPowerEnd", DoubleValue (7),
> "TxPowerStart", DoubleValue (7));
> wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
> "DataMode", StringValue
> ("wifia-54mbs"));
>
> And when I find the Log says
>
> mode=6000000, ber=0, snr=853.802, per=0, size=100
> ORWAR node 1 sending a Information message
> ORWAR node 1 sending a ORWAR packet
> 1430142806ns WifiPhy:SendPacket(0x806a2a0, 0x806d9d8, wifia-6mbs, 0,
> 0)
> 1430142833ns WifiPhy:StartReceivePacket(
> 0x8069688, 0x80728c0, -66.3931, wifia-6mbs, 0)
>
> I change the datamode value, but every time gets same result. Why?

Probably because there is a bug in another part of the scenario topology
description. You need to provide more code and context.

Mathieu


Mathieu Lacage

unread,
Feb 24, 2009, 9:53:36 AM2/24/09
to ns-3-...@googlegroups.com
What is the output when you set NS_LOG=PacketSocket ?

Timo Bingmann

unread,
Feb 24, 2009, 10:06:24 AM2/24/09
to ns-3-...@googlegroups.com
Broadcast packets are always sent with the 6mbps base rate.
I don't exactly know why, I guess the rate manager cannot assume everyone to be able to receive all rates.
Greetings
Timo

yan zhang

unread,
Feb 24, 2009, 10:02:51 AM2/24/09
to ns-3-...@googlegroups.com
Thanks for responding.

Here is the outpout when I set NS_LOG=PacketSocket.


Created orwar::AgentImpl
Starting ORWAR on node 0
0ns PacketSocket:PacketSocket()
0ns PacketSocket:SetNode()
0ns PacketSocket:Bind()
0ns PacketSocket:DoBind()

ORWAR-INFORMATION on node 0 started
Created orwar::AgentImpl
Starting ORWAR on node 1
0ns PacketSocket:PacketSocket()
0ns PacketSocket:SetNode()
0ns PacketSocket:Bind()
0ns PacketSocket:DoBind()

ORWAR-INFORMATION on node 1 started
ORWAR node 0 sending a Information message
ORWAR node 0 sending a ORWAR packet
1078374257ns PacketSocket:Connect()
1078374257ns PacketSocket:Send()
1078374257ns PacketSocket:SendTo()

ORWAR node 1 sending a Information message
ORWAR node 1 sending a ORWAR packet
1276069933ns PacketSocket:Connect()
1276069933ns PacketSocket:Send()
1276069933ns PacketSocket:SendTo()
PacketSocket:DoDispose()
PacketSocket:~PacketSocket()
PacketSocket:DoDispose()
PacketSocket:~PacketSocket()

yan zhang

unread,
Feb 24, 2009, 10:05:18 AM2/24/09
to ns-3-...@googlegroups.com
my scenario:

using namespace std;
using namespace ns3;
NS_LOG_COMPONENT_DEFINE ("Simulation");

int main (int argc, char *argv[])
{
  LogComponentEnable ("OrwarAgentImplemention", LOG_LEVEL_INFO);
  LogComponentEnable ("PacketSocket", LOG_LEVEL_INFO);

  NodeContainer nodes;
  nodes.Create (2);


  WifiHelper wifi;
  wifi.SetMac ("ns3::AdhocWifiMac");
  wifi.SetPhy ("ns3::WifiPhy",    
               "EnergyDetectionThreshold", DoubleValue (-140),
               "TxGain", DoubleValue (1),
               "RxGain", DoubleValue (1),              
               "TxPowerLevels", UintegerValue (1),
               "TxPowerEnd", DoubleValue (7),
               "TxPowerStart", DoubleValue (7));
  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
                                "DataMode", StringValue ("wifia-54mbs"));

  NetDeviceContainer devices;
  devices = wifi.Install (nodes);

  MobilityHelper mobility; 
  mobility.SetPositionAllocator ("ns3::RandomRectanglePositionAllocator",
  "X", RandomVariableValue(UniformVariable (0, 10)),
  "Y", RandomVariableValue(UniformVariable (0, 10)));
  mobility.SetMobilityModel ("ns3::RandomDirection2dMobilityModel",
                             "Bounds", RectangleValue (Rectangle (0, 100, 0, 100)),
                             "Speed", RandomVariableValue (UniformVariable (3, 10)),
                             "Pause", RandomVariableValue (ConstantVariable (0.2)));

  mobility.Install (nodes); 


  PacketSocketHelper packetSocket;
  packetSocket.Install (nodes); 

  OrwarHelper orwar;
  orwar.Install (nodes);

  std::ofstream ascii;
  ascii.open ("simple-orwar.tr");
  WifiHelper::EnablePcapAll ("simple-orwar");
  WifiHelper::EnableAsciiAll (ascii);
  Simulator::Stop (Seconds (5));

  NS_LOG_INFO ("Run Simulation.");
  Simulator::Run ();
  Simulator::Destroy ();
  NS_LOG_INFO ("Done.");

  return 0;

Mathieu Lacage

unread,
Feb 24, 2009, 10:12:51 AM2/24/09
to ns-3-...@googlegroups.com
On Tue, 2009-02-24 at 16:06 +0100, Timo Bingmann wrote:
> Broadcast packets are always sent with the 6mbps base rate.

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

yan zhang

unread,
Feb 24, 2009, 10:13:35 AM2/24/09
to ns-3-...@googlegroups.com
Thanks.

As I did the simulation (wifi-adhoc), data mode also affects the transmission range of nodes. when I set data mode value of remote station manager as 54 bmps,  I get one transmission range value from simulation.  When it broadcast messages, what value is my transmission range? set by 54mbps or 6mbps?

Mathieu Lacage

unread,
Feb 24, 2009, 10:16:02 AM2/24/09
to ns-3-...@googlegroups.com

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

yan zhang

unread,
Feb 24, 2009, 10:23:41 AM2/24/09
to ns-3-...@googlegroups.com
yes, no packet reaches the socket. and my .tr trace records following

+ 1078374257ns /NodeList/0/DeviceList/0/$ns3::WifiNetDevice/Phy/Tx ns3::WifiMacHeader (DATA ToDS=#, FromDS=#, MoreFrag=#, Retry=#, MoreData=# Duration/ID=0usDA=ff:ff:ff:ff:ff:ff, SA=00:00:00:00:00:01, BSSID=00:00:00:00:00:01, FragNumber=#, SeqNumber=0) ns3::LlcSnapHeader (type 0x1) ns3::orwar::PacketHeader () ns3::orwar::MessageHeader () ns3::WifiMacTrailer ()
r 1078534265ns /NodeList/1/DeviceList/0/$ns3::WifiNetDevice/Phy/RxOk ns3::WifiMacHeader (DATA ToDS=#, FromDS=#, MoreFrag=#, Retry=#, MoreData=# Duration/ID=0usDA=ff:ff:ff:ff:ff:ff, SA=00:00:00:00:00:01, BSSID=00:00:00:00:00:01, FragNumber=#, SeqNumber=0) ns3::LlcSnapHeader (type 0x1) ns3::orwar::PacketHeader () ns3::orwar::MessageHeader () ns3::WifiMacTrailer ()
+ 1276069933ns /NodeList/1/DeviceList/0/$ns3::WifiNetDevice/Phy/Tx ns3::WifiMacHeader (DATA ToDS=#, FromDS=#, MoreFrag=#, Retry=#, MoreData=# Duration/ID=0usDA=ff:ff:ff:ff:ff:ff, SA=00:00:00:00:00:02, BSSID=00:00:00:00:00:02, FragNumber=#, SeqNumber=0) ns3::LlcSnapHeader (type 0x1) ns3::orwar::PacketHeader () ns3::orwar::MessageHeader () ns3::WifiMacTrailer ()
r 1276229946ns /NodeList/0/DeviceList/0/$ns3::WifiNetDevice/Phy/RxOk ns3::WifiMacHeader (DATA ToDS=#, FromDS=#, MoreFrag=#, Retry=#, MoreData=# Duration/ID=0usDA=ff:ff:ff:ff:ff:ff, SA=00:00:00:00:00:02, BSSID=00:00:00:00:00:02, FragNumber=#, SeqNumber=0) ns3::LlcSnapHeader (type 0x1) ns3::orwar::PacketHeader () ns3::orwar::MessageHeader () ns3::WifiMacTrailer ()

It seems that wifiphy receives message from the other node. Same result can read from pcap trace. Both node sends and receives one message separately. Does this mean phy receive message but socket doesn't?

Thanks a lot.

Yan

yan zhang

unread,
Feb 24, 2009, 10:29:13 AM2/24/09
to ns-3-...@googlegroups.com
The result after trying NS_LOG=PacketSocket:
AdhocWifiMac:WifiPhy:YansWifiPhy

0ns WifiPhy:WifiPhy(0x8069668)
0ns WifiPhy:SetEdThreshold(0x8069668, -140)
0ns WifiPhy:SetTxGain(0x8069668, 1)
0ns WifiPhy:SetRxGain(0x8069668, 1)
0ns WifiPhy:SetTxPowerEnd(0x8069668, 7)
0ns WifiPhy:SetTxPowerStart(0x8069668, 7)
0ns WifiPhy:SetRxNoise(0x8069668, 7)
0ns WifiPhy:SetStandard(0x8069668, 0)
0ns WifiPhy:Configure80211a(0x8069668)
0ns WifiPhy:Configure80211aParameters(0x8069668)
0ns WifiPhy:WifiPhy(0x806a280)
0ns WifiPhy:SetEdThreshold(0x806a280, -140)
0ns WifiPhy:SetTxGain(0x806a280, 1)
0ns WifiPhy:SetRxGain(0x806a280, 1)
0ns WifiPhy:SetTxPowerEnd(0x806a280, 7)
0ns WifiPhy:SetTxPowerStart(0x806a280, 7)
0ns WifiPhy:SetRxNoise(0x806a280, 7)
0ns WifiPhy:SetStandard(0x806a280, 0)
0ns WifiPhy:Configure80211a(0x806a280)
0ns WifiPhy:Configure80211aParameters(0x806a280)

Created orwar::AgentImpl
Starting ORWAR on node 0
0ns PacketSocket:PacketSocket()
0ns PacketSocket:SetNode()
0ns PacketSocket:Bind()
0ns PacketSocket:DoBind()
ORWAR-INFORMATION on node 0 started
Created orwar::AgentImpl
Starting ORWAR on node 1
0ns PacketSocket:PacketSocket()
0ns PacketSocket:SetNode()
0ns PacketSocket:Bind()
0ns PacketSocket:DoBind()
ORWAR-INFORMATION on node 1 started
ORWAR node 0 sending a Information message
ORWAR node 0 sending a ORWAR packet
1346670682ns PacketSocket:Connect()
1346670682ns PacketSocket:Send()
1346670682ns PacketSocket:SendTo()
1346670682ns AdhocWifiMac:Enqueue(72, ff:ff:ff:ff:ff:ff)
1346670682ns WifiPhy:SendPacket(0x8069668, 0x806d9b8, wifia-6mbs, 0, 0)
1346670725ns WifiPhy:StartReceivePacket(0x806a280, 0x8072568, -72.2701, wifia-6mbs, 0)
1346670725ns WifiPhy:StartReceivePacket(): sync (power=7.46425e-11W)
1346830725ns WifiPhy:EndSync(0x806a280, 0x8072568, 0x80725a0)
1346830725ns WifiPhy:GetBpskBer(): bpsk snr=186.031 ber=3.55173e-137
1346830725ns WifiPhy:GetBpskBer(): bpsk snr=186.031 ber=3.55173e-137
1346830725ns WifiPhy:EndSync(): 1346830725ns WifiPhy:GetBpskBer(): bpsk snr=186.031 ber=3.55173e-137
mode=6000000, ber=0, snr=186.031, per=0, size=100
1346830725ns AdhocWifiMac:ForwardUp(): received size=72, from=00:00:00:00:00:01

ORWAR node 1 sending a Information message
ORWAR node 1 sending a ORWAR packet
1452961424ns PacketSocket:Connect()
1452961424ns PacketSocket:Send()
1452961424ns PacketSocket:SendTo()
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
1453121469ns AdhocWifiMac:ForwardUp(): received size=72, from=00:00:00:00:00:02
WifiPhy:DoDispose(0x8069668)
PacketSocket:DoDispose()
PacketSocket:~PacketSocket()
WifiPhy:DoDispose(0x806a280)
WifiPhy:~WifiPhy(0x8069668)
WifiPhy:~WifiPhy(0x806a280)
PacketSocket:DoDispose()
PacketSocket:~PacketSocket()

Thanks,
Yan

Mathieu Lacage

unread,
Feb 24, 2009, 10:34:44 AM2/24/09
to ns-3-...@googlegroups.com

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

Mathieu Lacage

unread,
Feb 24, 2009, 10:36:42 AM2/24/09
to ns-3-...@googlegroups.com
On Tue, 2009-02-24 at 16:29 +0100, yan zhang wrote:

> 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

yan zhang

unread,
Feb 24, 2009, 9:47:39 PM2/24/09
to ns-3-...@googlegroups.com
Could you please explain how to run the code in gdb debugger when use waf? Is there order like "g++ -g ..." in waf when I want to compile the source code into .o file?

Many thanks,
Yan

Mathieu Lacage

unread,
Feb 25, 2009, 2:03:03 AM2/25/09
to ns-3-...@googlegroups.com
On Wed, 2009-02-25 at 03:47 +0100, yan zhang wrote:
> Could you please explain how to run the code in gdb debugger when use
> waf? Is there order like "g++ -g ..." in waf when I want to compile
> the source code into .o file?

http://www.nsnam.org/wiki/index.php/User_FAQ#How_to_run_programs_with_gdb


Mathieu

yan zhang

unread,
Feb 25, 2009, 9:23:03 AM2/25/09
to ns-3-...@googlegroups.com
Here is what I get when I set a break point on AdhocWifiMac::ForwardUp. Could you please help me to analyze why the messages cannot be received by socket?

Thank you very much!

Yan

Starting program: /media/Data/software/ns-3.2/repos/ns-3-dev/build/debug/scratch/example
[Thread debugging using libthread_db enabled]

Created orwar::AgentImpl
Starting ORWAR on node 0
ORWAR-INFORMATION on node 0 started
Created orwar::AgentImpl
Starting ORWAR on node 1
ORWAR-INFORMATION on node 1 started
ORWAR node 1 sending a Information message
ORWAR node 1 sending a ORWAR packet
[New Thread 0xb6b868d0 (LWP 10724)]
[Switching to Thread 0xb6b868d0 (LWP 10724)]

Breakpoint 1, ns3::AdhocWifiMac::ForwardUp (this=0x8068880, packet=@0xbf8595cc, hdr=0xbf8598f0) at ../src/devices/wifi/adhoc-wifi-mac.cc:238
238    AdhocWifiMac::ForwardUp (Ptr<Packet> packet, WifiMacHeader const *hdr)
(gdb) n
240      NS_LOG_DEBUG ("received size="<<packet->GetSize ()<<", from="<<hdr->GetAddr2 ());
(gdb)
241      m_upCallback (packet, hdr->GetAddr2 (), hdr->GetAddr1 ());
(gdb)
242    }
(gdb)
ns3::MacRxMiddle::Receive (this=0x8068910, packet=@0xbf85976c, hdr=0xbf8598f0) at ../src/devices/wifi/mac-rx-middle.cc:313
313    }
(gdb)
ns3::MacLow::ReceiveOk (this=0x8068948, packet=@0xbf859b6c, rxSnr=170.65115654744514, txMode={m_uid = 2}, preamble=ns3::WIFI_PREAMBLE_LONG) at ../src/devices/wifi/mac-low.cc:636
636      return;
(gdb)
637    }
(gdb)
ns3::WifiPhy::EndSync (this=0x80696b0, packet=@0xbf859d8c, event=@0xbf859d88) at ../src/devices/wifi/wifi-phy.cc:1385
1385        }
(gdb)
1386    }
(gdb)
ns3::EventImpl::Invoke (this=0x8070488) at ../src/simulator/event-impl.cc:41
41    }
(gdb)
ns3::DefaultSimulatorImpl::ProcessOneEvent (this=0x8068230) at ../src/simulator/default-simulator-impl.cc:122
122      next.impl->Unref ();
(gdb)
123    }
(gdb)
ns3::DefaultSimulatorImpl::Run (this=0x8068230) at ../src/simulator/default-simulator-impl.cc:149
149      while (!m_events->IsEmpty () && !m_stop &&
(gdb)
152          ProcessOneEvent ();
(gdb)
ORWAR node 0 sending a Information message
ORWAR node 0 sending a ORWAR packet
149      while (!m_events->IsEmpty () && !m_stop &&
(gdb)
152          ProcessOneEvent ();
(gdb)
149      while (!m_events->IsEmpty () && !m_stop &&
(gdb)
152          ProcessOneEvent ();
(gdb)
149      while (!m_events->IsEmpty () && !m_stop &&
(gdb)
152          ProcessOneEvent ();
(gdb)

Breakpoint 1, ns3::AdhocWifiMac::ForwardUp (this=0x8069a40, packet=@0xbf8595cc, hdr=0xbf8598f0) at ../src/devices/wifi/adhoc-wifi-mac.cc:238
238    AdhocWifiMac::ForwardUp (Ptr<Packet> packet, WifiMacHeader const *hdr)
(gdb)
240      NS_LOG_DEBUG ("received size="<<packet->GetSize ()<<", from="<<hdr->GetAddr2 ());
(gdb)
241      m_upCallback (packet, hdr->GetAddr2 (), hdr->GetAddr1 ());
(gdb)
242    }
(gdb)
ns3::MacRxMiddle::Receive (this=0x8069ad0, packet=@0xbf85976c, hdr=0xbf8598f0) at ../src/devices/wifi/mac-rx-middle.cc:313
313    }
(gdb)
ns3::MacLow::ReceiveOk (this=0x8069b20, packet=@0xbf859b6c, rxSnr=162.5707272609591, txMode={m_uid = 2}, preamble=ns3::WIFI_PREAMBLE_LONG) at ../src/devices/wifi/mac-low.cc:636
636      return;
(gdb)
637    }
(gdb)
ns3::WifiPhy::EndSync (this=0x806a2c8, packet=@0xbf859d8c, event=@0xbf859d88) at ../src/devices/wifi/wifi-phy.cc:1385
1385        }
(gdb)
1386    }
(gdb)
ns3::EventImpl::Invoke (this=0x806af50) at ../src/simulator/event-impl.cc:41
41    }
(gdb)
ns3::DefaultSimulatorImpl::ProcessOneEvent (this=0x8068230) at ../src/simulator/default-simulator-impl.cc:122
122      next.impl->Unref ();
(gdb)
123    }
(gdb)
ns3::DefaultSimulatorImpl::Run (this=0x8068230) at ../src/simulator/default-simulator-impl.cc:149
149      while (!m_events->IsEmpty () && !m_stop &&
(gdb)
157      NS_ASSERT(!m_events->IsEmpty () || m_unscheduledEvents == 0);
(gdb)
158    }
(gdb)
ns3::Simulator::Run () at ../src/simulator/simulator.cc:152
152    }
(gdb)
main (argc=Cannot access memory at address 0x1
) at ../scratch/example.cc:98
98      Simulator::Destroy ();
(gdb)
99      NS_LOG_INFO ("Done.");
(gdb)
101      return 0;
(gdb)
103    }
(gdb)
0xb6e66450 in __libc_start_main () from /lib/tls/i686/cmov/libc.so.6
(gdb)
Single stepping until exit from function __libc_start_main,
which has no line number information.

Program exited normally.

yan zhang

unread,
Feb 25, 2009, 2:43:21 PM2/25/09
to ns-3-...@googlegroups.com
Thanks a lot for everybody!

I didn't find mistakes when I use debugger to analyze code. And I run the code again. It gets through...

but when I add NS_LOG=PacketSocket before I run my example, the result didn't show any information about socket(following). Strange!


Created orwar::AgentImpl
Starting ORWAR on node 0
ORWAR-INFORMATION on node 0 started
Created orwar::AgentImpl
Starting ORWAR on node 1
ORWAR-INFORMATION on node 1 started
ORWAR node 0 sending a Information message
ORWAR node 0 sending a ORWAR packet
ORWAR node 1 received packet from 03-0f-01:00:00:00:00:00:01:02:06:00:00:00:00:00:01 to 02-06-00:00:00:00:00:02 at time 1198677648ns
ORWAR Message received with type 1

ORWAR node 1 sending a Information message
ORWAR node 1 sending a ORWAR packet
ORWAR node 0 received packet from 03-0f-01:00:00:00:00:00:01:02:06:00:00:00:00:00:02 to 02-06-00:00:00:00:00:01 at time 1258243564ns
ORWAR Message received with type 1

 Anyway, I am happy for the code get through. :-)

Best wishes,
Yan
Reply all
Reply to author
Forward
0 new messages