SNR Tag

3,332 views
Skip to first unread message

Networks Geek

unread,
Feb 23, 2012, 10:53:28 AM2/23/12
to ns-3-users
Hi,

I am somehow new to ns3 and the thing is, I would like to fetch the
snr Value when I receive a packet in a wireless station. I wonder how
to do that using SNR tags ?

Thank you in advance,
Adel.

Konstantinos

unread,
Feb 23, 2012, 11:29:07 AM2/23/12
to ns-3-...@googlegroups.com
Dear Adel,

first of all have a look at the ns-3 documentation regarding Packet Tags.
http://www.nsnam.org/docs/release/3.13/models/singlehtml/index.html#adding-and-removing-tags

Then, specifically for SnrTag, in my opinion, you have to add it to packets at the PHY layer because that's where SNR value is calculated. Right after a correct receive of a packet, add this packet tag with the value of the corresponding snr.
Then, you can read this tag at upper layers (MAC, Network, Application)

However, since SnrTag is declared in mal-low.cc (falsely in my opinion) you have to add this file in every other script/file you want to use this Tag.
Otherwise, you could easily cut the declaration of the SnrTag from mac-low.cc into a separate header file, and add that file.

Regards,
Konstantinos.

Networks Geek

unread,
Feb 23, 2012, 11:33:20 AM2/23/12
to ns-3-users
Dear Konstantinos,

First of all thank you so much for your quick reply :). For the SNR
Declaration in mac-low.cc, you are correct I have been trying to use
that for a while and haven't worked out. So I added the tag at the mac-
low.h and now it is working :).

Thanks again.
Best regards,
Adel.

On Feb 23, 5:29 pm, Konstantinos <dinos.katsa...@gmail.com> wrote:
> Dear Adel,
>
> first of all have a look at the ns-3 documentation regarding Packet Tags.http://www.nsnam.org/docs/release/3.13/models/singlehtml/index.html#a...

Konstantinos

unread,
Feb 23, 2012, 11:54:45 AM2/23/12
to ns-3-...@googlegroups.com
Dear Adel,

since I use the SnrTag myself, here is how I have done it:

Add this code in yans-wifi-phy.cc

      double signalDbm = RatioToDb (event->GetRxPowerW ()) + 30;
      double noiseDbm = RatioToDb (event->GetRxPowerW () / snrPer.snr) - GetRxNoiseFigure () + 30;
      NotifyMonitorSniffRx (packet, (uint16_t)GetChannelFrequencyMhz (), GetChannelNumber (), dataRate500KbpsUnits, isShortPreamble, signalDbm, noiseDbm);
      // **********  SNR TAG  *********** //
      SnrTag tag;
      tag.Set(signalDbm - noiseDbm);
      if (! packet->PeekPacketTag (tag))
        {
          packet->AddPacketTag (tag);
          NS_LOG_DEBUG("Add SNR Tag with value :" << tag.Get());
        }
      // *********  SNR TAG  *********** //

So, right after you notify that a packet is received and you have the signal and noise (plus interference) values in dBm, the sinr value (in dB) is just just (signal-noise)

Then, when you have to read it, you can use this code (where temp_snr is a variable that you can work with):

  Ptr<Packet> packet = receivedPacket;

  // ***** SNR **** //
  SnrTag tag;
  if (packet->PeekPacketTag(tag)){
      NS_LOG_DEBUG ("Received Packet with SRN = " << tag.Get());
      temp_snr = tag.Get();
  }
  // ***** SNR **** //

Regards,
Konstantinos

Networks Geek

unread,
Feb 23, 2012, 12:25:44 PM2/23/12
to ns-3-users

Now that sounds logical, because before when I used the SNR values
from the mac-low I had very large SNR Values, now I am having
reasonable values.

Thanks again,
Best regards,
Adel.

Jeremy Mack

unread,
Mar 4, 2013, 2:20:06 PM3/4/13
to ns-3-...@googlegroups.com
Hello Konstantinos,

Thank you for your help on the forums, your replies have helped me a lot these last few months while trying to learn ns-3. 

I am trying to determine the received power of each received packet so this example really helps. The only thing I am confused about is  when/how to read it. Currently I am use an On Off Application to generate traffic,so where exact do I put the code you gave  that reads the packets? Do I have to put it into the On Off application file or would it go my file?

Thanks,

Jeremy

Konstantinos

unread,
Mar 4, 2013, 2:36:28 PM3/4/13
to ns-3-...@googlegroups.com
Dear Jeremy,

The OnOff Application is for generating the packets. 
If you are using wifi, just add the first code snippet in yans-wifi-phy.cc which will add the SNR tag to the packets when received.

Now to read it you have to either modify the PacketSink or any other sink application that you use to "receive" the packets.

The easiest way to do it without modifications to existing code, is with the use of callback. Use the Config::Connect to connect a callback on the sink application which will triggered each time a packet is received (at the application layer). Then you can print the SNR with the second code snippet.

Jeremy Mack

unread,
Mar 4, 2013, 2:59:41 PM3/4/13
to ns-3-...@googlegroups.com
Hello Konstantinos,

I put the your code into the yans-wifi-phy.cc file, but am having an error when trying to build the file. It says the SnrTag was not declared in the scope. I tried adding #include "ns3/tag.h" but it still give me the same error.

Thanks again for the fast reply !

Jeremy

Jeremy Mack

unread,
Mar 4, 2013, 3:21:17 PM3/4/13
to ns-3-...@googlegroups.com
Hello Konstantinos,

I realized that there is SnrTag class, so I added (#include "ns3/snr-tag.h")   it works! One more questions, since I currently do not want the SNR can I still use the SnrTag class? I would just put tag.Set(signalDbm)?

Thanks,

Jeremy

On Monday, 4 March 2013 14:36:28 UTC-5, Konstantinos wrote:

Konstantinos

unread,
Mar 4, 2013, 4:48:58 PM3/4/13
to ns-3-...@googlegroups.com
You can create your own PacketTag, declare it with as many as 8 (if I remember correctly) different values/attributes and use it.
You don't have to use SnrTag which is designed to hold the snr value.

Alessandro Russo

unread,
Mar 5, 2013, 7:00:19 AM3/5/13
to ns-3-...@googlegroups.com
Hi,
look at this topic "Signal Power Detected At Receiving Node"
in the mailing list.

 Alessandro  R.


--
You received this message because you are subscribed to the Google Groups "ns-3-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ns-3-users+...@googlegroups.com.
To post to this group, send email to ns-3-...@googlegroups.com.
Visit this group at http://groups.google.com/group/ns-3-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Jeremy Mack

unread,
Mar 7, 2013, 7:54:59 PM3/7/13
to ns-3-...@googlegroups.com
Hello,

I have two more questions and I am sorry if they are dumb, I am new to c++ and ns-3.

1) I looked into the "Tag" function and it does not have a ".set" or ".get" call like the SnrTag does, thus the code provided above does not work. Do I have to create my own function and implement .set and .get or is there another function I should use? I just need to get the received power, not the SNR.

2) Once I have the packets tagged I understand I need to connect a callback to my sink application, but how do I do that exactly? I have not found an example similar enough to get as a base. I want to get the receive power from the packet, determine which access point it was sent from (not sure how to get this information from packet either) and store the set of information in a matrix.

Thanks

Jeremy

Alessandro Russo

unread,
Mar 8, 2013, 3:08:54 AM3/8/13
to ns-3-...@googlegroups.com
HI,
please find my comments in line
 Alessandro  R.


On Fri, Mar 8, 2013 at 1:54 AM, Jeremy Mack <jeremy...@gmail.com> wrote:
Hello,

I have two more questions and I am sorry if they are dumb, I am new to c++ and ns-3.

1) I looked into the "Tag" function and it does not have a ".set" or ".get" call like the SnrTag does, thus the code provided above does not work. Do I have to create my own function and implement .set and .get or is there another function I should use? I just need to get the received power, not the SNR.
Yes, you should implement the Tag class.
The SNR and received power are supposed to be
the same value in different measuring unit,
please have a look at YansWifiPhy::EndReceive
 

2) Once I have the packets tagged I understand I need to connect a callback to my sink application, but how do I do that exactly? I have not found an example similar enough to get as a base. I want to get the receive power from the packet, determine which access point it was sent from (not sure how to get this information from packet either) and store the set of information in a matrix.

Perhaps, I didn't get the question, but there are several examples
that show how to connect a callback to a sink application
to handle received packets, e.g., wifi-adhoc.cc
The information about the AP that has sent the packet are Level-2 information,
such information are usually not available at the application level.
You can add them through PacketTag,
thus, whenever an AP sends a packet, it add such a Tag including its MAC address,
or any other suitable information
 

Thanks

Jeremy
--

Jeremy Mack

unread,
Mar 8, 2013, 12:33:32 PM3/8/13
to ns-3-...@googlegroups.com

Hello,

 

This is what I have and I am stuck.

 

In yans-wifi-phy.cc I have the following:

 

dataRate500KbpsUnits, isShortPreamble, signalDbm, noiseDbm);
      // **********  SNR TAG  *********** //
      SnrTag tag;
      tag.Set(signalDbm - noiseDbm);
      if (! packet->PeekPacketTag (tag))
        {
          packet->AddPacketTag (tag);
          NS_LOG_DEBUG("Add SNR Tag with value :" << tag.Get());
        }
      // *********  SNR TAG  *********** //

 

In my file I have the following:

void RecvPacket (Ptr<Packet> thepacket)

  {    SnrTag tag;

     if (thepacket->PeekPacketTag(tag)){

                NS_LOG_DEBUG ("Received Packet with SRN = " << tag.Get());

               snrValue = tag.Get();


     }

  }

………

ApplicationContainer Sinks = sinkHelper2.Install (ClientNode.Get(1));

Sinks->SetRecvCallback (MakeCallback (&RecvPacket, packet));

Sinks.Start (Seconds (6.0));

Sinks.Stop (Seconds (11.0));

I get the following errors:

error: base operand of ‘->’ has non-pointer type ‘ns3::ApplicationContainer’

error: ‘packet’ was not declared in this scope

Thanks for the help


Alessandro Russo

unread,
Mar 9, 2013, 7:44:49 AM3/9/13
to ns-3-...@googlegroups.com
Hi,

in
Sinks->SetRecvCallback (MakeCallback (&RecvPacket, packet));
you are defining the callback improperly

Look at the following file examples/wireless/wifi-simple-adhoc.cc
It should be
Sinks->SetRecvCallback (MakeCallback (&RecvPacket));

 Alessandro  R.


Jeremy Mack

unread,
Mar 14, 2013, 2:55:42 PM3/14/13
to ns-3-...@googlegroups.com
Hello Alessandro,

Thanks for the help. The example in Wifi-simple-adhoc.cc was helpful, however I am using the PacketSinkHelper to create my sink. When I try and use the code from the example I get the following error:

error: base operand of ‘->’ has non-pointer type ‘ns3::PacketSinkHelper’

Is there another method that works with the PacketSinkHelper? Or do you think I should I make my sinks like they did in the example you suggested?

Here is the lines of code that is giving me the problems:
PacketSinkHelper sinkHelper2 ("ns3::TcpSocketFactory", (InetSocketAddress (Ipv4Address ("10.1.1.2"), port)));

ApplicationContainer Sinks2 = sinkHelper2.Install (ClientNode.Get(0));

sinkHelper2->SetRecvCallback (MakeCallback (&RecvPacket));

Thanks,

Jeremy

Jeremy Mack

unread,
Mar 15, 2013, 1:14:55 PM3/15/13
to ns-3-...@googlegroups.com
Hello Konstantinos,

I tried attaching a trace to the sink and it doesn't seem to be working. FlowMonitor shows that packets are being sent but I am not seeing any output in my terminal.

PacketSinkHelper sinkHelper2 ("ns3::TcpSocketFactory", (InetSocketAddress (Ipv4Address ("10.1.1.2"), port)));
ApplicationContainer Sinks2 = sinkHelper2.Install (ClientNode.Get(0));
Sinks2.Start (Seconds (6.0));
Sinks2.Stop (Seconds (7.0));

Config::Connect ("/NodeList/*/$ns3::PacketSink/Rx",MakeCallback (&RecvPacket));

void RecvPacket (Ptr<Socket> recievedPacket){
  std::cout<<"Received one packet!"<< std::endl;
  }

Thanks,

Jeremy

On Monday, 4 March 2013 14:36:28 UTC-5, Konstantinos wrote:

Konstantinos

unread,
Mar 15, 2013, 2:00:22 PM3/15/13
to ns-3-...@googlegroups.com
You say that FlowMonitor shows packets SENT, are these packets also received??

Also your callback is wrong and I'm wondering why isn't this shown in the compiler/linker. I guess it should, but anyway the trace source for packet sink needs a pointer to the packet and a reference to address not a pointer to a socket as you have it.

for the packet-sink.h file
111  TracedCallback<Ptr<const Packet>, const Address &> m_rxTrace;

this:

void RecvPacket (Ptr<Socket> recievedPacket)

should be:
void RecvPacket (Ptr<const Packet> recievedPacket, const Address & address)

Jeremy Mack

unread,
Mar 15, 2013, 4:25:48 PM3/15/13
to ns-3-...@googlegroups.com
Hello Konstantinous,

Flow Monitor shows that the packets are both sent and received. And I get no error when I compile the file, however even with the change you suggested I see no output in the terminal.
I have attached my code. I have one access point and one clients in a infrastructure Wifi network and am trying to send from the access point to the client. I want to set up the call back so I can get the SNR value from the packet. 

Thanks a lot,
Jeremy
InterferenceTestGoogle.cc

Konstantinos

unread,
Mar 15, 2013, 6:07:35 PM3/15/13
to ns-3-...@googlegroups.com
Your callback is wrong. Basically the path to the callback.

If you see from the documentation

Config Paths

ns3::PacketSink is accessible through the following paths with Config::Set and Config::Connect:

  • /NodeList/[i]/ApplicationList/[i]/$ns3::PacketSink
So you missed the ApplicationList before the actual trace source. Similar for the OnOffApplication

Jeremy Mack

unread,
Mar 20, 2013, 10:45:01 AM3/20/13
to ns-3-...@googlegroups.com
Hello Konstantinos,

I tried using that path before but it never worked. I used the following:

std::ostringstream oss;
oss << "/NodeList/" << ClientNode.Get (0)->GetId () << "/ApplicationList/0/$ns3::PacketSink/Rx";
Config::Connect (oss.str (), MakeCallback (&RecvPacket));

and it gives me this error:

msg="Incompatible types. (feed to "c++filt -t" if needed)
got=ns3::FunctorCallbackImpl<void (*)(ns3::Ptr<ns3::Packet const>, ns3::Address const&), void, ns3::Ptr<ns3::Packet const>, ns3::Address const&, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>
expected=ns3::CallbackImpl<void, std::string, ns3::Ptr<ns3::Packet const>, ns3::Address const&, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>*", file=./ns3/callback.h, line=470
terminate called without an active exception

If I change the 0 to 1 in the application list (It means it should be looking at the source since I only have 2 applications, each with one node). It runs but again does not output anything to the terminal. I tried the same code for the onoffapplication and it gives me the same errors. It also does not output anything when I set the application to 1.

Konstantinos

unread,
Mar 20, 2013, 11:11:27 AM3/20/13
to ns-3-...@googlegroups.com
First of all, the index on the Application refers to the applications installed on each node.
So if one node_0 you only have a PacketSink application, it should be indexed as 0. If in general you only have one sink application, then there is no need to do the sting "stuff" there, just put * (star) on the node and the application and it will work. However that has nothing to do with the error. If the path is not correct, it just wont fire the callback.

The problem comes for the use of Connect instead of ConnectWithoutContext

http://www.nsnam.org/doxygen/namespacens3_1_1_config.html
The Connect will attempt to find all trace sources which match the input path and will then connect the input callback to them in such a way that the callback will receive an extra context string upon trace event notification.
Message has been deleted

Jeremy Mack

unread,
Mar 20, 2013, 12:26:37 PM3/20/13
to ns-3-...@googlegroups.com
Hello Konstantinos,

It worked and I figured out my error for my deleted post. I have one final question then I will be out of your hair haha. Above where you explain how to grab the SNR from the packet by using 
  
Ptr<Packet> packet = receivedPacket;

  // ***** SNR **** //
  SnrTag tag;
  if (packet->PeekPacketTag(tag)){
      NS_LOG_DEBUG ("Received Packet with SRN = " << tag.Get());
      temp_snr = tag.Get();
  }
  // ***** SNR **** //

Where is receivedPacket coming from? Currently I use the following and am getting an SNR =0 for all packets

RecvPacket (Ptr<const Packet> packet, const Address & address)

  { SnrTag tag;
  if (packet->PeekPacketTag(tag)){
      NS_LOG_DEBUG ("Received Packet with SRN = " << tag.Get());
      temp_snr = tag.Get();
      }
std::cout<<"SNR = "<< temp_snr << std::endl;
}

Konstantinos

unread,
Mar 20, 2013, 12:47:36 PM3/20/13
to ns-3-...@googlegroups.com
It depends where you want to call this method.
It is just a pointer to the received packet. If you use a callback to the PacketSink/Rx you can get a pointer to a received packet at the packet sink.
This code snipped should be added at any point in your code where you have access to a packet.

Jeremy Mack

unread,
Mar 20, 2013, 2:09:00 PM3/20/13
to ns-3-...@googlegroups.com
Alright, How can I set up a pointer for the packet at the sink? (I don't have much coding experience  I looked into the packetsink class and can't see anything that outputs the packet. 

Konstantinos

unread,
Mar 20, 2013, 3:09:13 PM3/20/13
to ns-3-...@googlegroups.com

Put this inside your script assuming that you have installed the PacketSink application on the sink

  Config::ConnectWithoutContext("/NodeList/*/ApplicationList/*/$ns3::PacketSink/Rx",MakeCallback (&ReceivePacket));

and this

void ReceivePacket(Ptr<const Packet> packet, const Address &)
{
  NS_LOG_DEBUG ("Received one packet!");
}

Now you have a function that has access to a received packet. Put the code snippet to print the SNR tag in this method.
If you don't understand it, then study the ns-3 tutorial on tracing and callbacks.

Jeremy Mack

unread,
Mar 20, 2013, 3:45:37 PM3/20/13
to ns-3-...@googlegroups.com
Thank you, 

I promise this is the last question. When I do not have any propagation loss models implemented the SNR for all the packets is 0. When I turn on the friss propagation model, it just stops outputting any SNR values. Any suggestion on where I could read to help figure this out?

Thanks for all your help

Konstantinos

unread,
Mar 20, 2013, 6:17:46 PM3/20/13
to ns-3-...@googlegroups.com
Have you added the parts of code that adds the SNR tag in the PHY ??

I think that you haven't and in the first scenario with no propagation you receive packets but you don't have any tag, so you print 0 and in the second, you don't receive packets because of distance between nodes perhaps thus, you don't see anything.

I would suggest you to go first over the example codes for WiFi to familiarize with NS3

Larissa Marinho Eglem de Oliveira

unread,
Mar 20, 2013, 8:12:28 PM3/20/13
to ns-3-...@googlegroups.com
Hi, I've been following this post regarding tags and I  would really appreciate some help with a custom tag that I am using.

I have created a new module that receives the packets from Ipv4L3protocol::SendRealOut and stores then in a FIFO queue.  In this new class DispatchModule, the packets are forwarded  through multiple interfaces and  a tag is added sinalizing which interface the packet was sent from. I'd like to retrieve this tag in the method MacTxMiddle:;GetNextSequenceNumberfor but when i try to retrieve the tag, the values stored aren't the correct ones.

In dispatch-module.h  I created this tag:

class SeqTag : public Tag
{

public:

  static TypeId GetTypeId (void);
  virtual TypeId GetInstanceTypeId (void) const;

  virtual uint32_t GetSerializedSize (void) const;
  virtual void Serialize (TagBuffer i) const;
  virtual void Deserialize (TagBuffer i);
  virtual void Print (std::ostream &os) const;

  void Set (uint16_t seq);
  uint16_t Get (void) const;
  void SetFlag (uint16_t seq);
    uint16_t GetFlag (void) const;

private:
  uint16_t m_seq;
  uint16_t m_flag;
};

And in dispatch-module.cc:

void DispatchModule::Send (void) //interface1
{
   ...
    SeqTag tag;
    tag.SetFlag(0);

    packet->AddPacketTag(tag);
...
}

void DispatchModule::CognitiveSend (uint16_t seq) //interface2
{
  ...

 SeqTag tag;
 tag.Set(seq);
 tag.SetFlag(1);

 packet->AddPacketTag(tag);

}


And in mac-tx-middle.cc i added this:

MacTxMiddle::GetNextSequenceNumberfor (const WifiMacHeader *hdr, Ptr<const Packet> packet)
{
  ...
 else
    {
 uint16_t flag;
 SeqTag tag;
 if(packet->PeekPacketTag(tag)){
 flag = tag.GetFlag();
 if(flag == 1)
 {
     retval = tag.Get();
 }
else
{
     retval = m_sequence;
}
 }
      m_sequence++;
      m_sequence %= 4096;
    }
  return retval;
}

in mac-tx-middle.h :   uint16_t GetNextSequenceNumberfor (const WifiMacHeader *hdr, Ptr<const Packet> packet);

And finally in dca-txop.cc:

DcaTxop::NotifyAccessGranted (void)
{
 ...
m_currentPacket = m_queue->Dequeue (&m_currentHdr);
NS_ASSERT (m_currentPacket != 0);
uint16_t sequence = m_txMiddle->GetNextSequenceNumberfor (&m_currentHdr, m_currentPacket);
...
}


I really don't understand why it doesn't work. While debbuging it, when the packet leaves the method ns3::DispatchModule::DoCognitiveSend, it has both tags , e.g  flag=1 and seq = 2, but when I retrieve the tag ( retval = tag.Get();/flag = tag.GetFlag();) this values are never the ones I stored, and the debugger acusses an error while trying to read the variable.

What am I doing wrong? I have included the dispatch-module header in mac-tx-middle.cc.

I would really appreciate any help. I really need to get this information.

Thank you.

Best regards,
Larissa Eglem. 


2013/3/20 Konstantinos <dinos.k...@gmail.com>
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted

Jeremy Mack

unread,
Mar 21, 2013, 3:22:38 PM3/21/13
to ns-3-...@googlegroups.com

Hello,

I looked at a lot of resource and am not sure how to fix the problem.

When I use the sink callback, the packet I received does not have a tag. I know this, because packet->PeekPacketTag(tag) is always 0.

For the callback I used exactly as you said:

Config::ConnectWithoutContext ("/NodeList/*/ApplicationList/*/$ns3::PacketSink/Rx",MakeCallback (&RecvPacket));

And I placed the two pieces of code you gave earlier in the posts. I also checked to make sure the tags were being placed on the packets and confirmed they are by outputting the values of the tag and getting non-zero numbers.

Jeremy



Konstantinos

unread,
Mar 21, 2013, 5:18:17 PM3/21/13
to ns-3-...@googlegroups.com
Have you added the packet tag at the PHY layer (yans-wifi-phy) ?
You are using wifi right?

I have submitted this as a patch to NS-3 (https://groups.google.com/d/msg/ns-3-reviews/fTvQWDGXtgY/Z8Q3UfzkpZsJ) and I have tested/used it a lot.
So probably you are missing some steps.

Jeremy Mack

unread,
Mar 22, 2013, 4:16:19 PM3/22/13
to ns-3-...@googlegroups.com
Hello Konstantinos,

I figure out the problem. The SNR tag does not work with the TCP internet protocol. Once I changed my sink from tcp to udp it worked great.

Jeremy

Nitish Rajoria

unread,
Apr 8, 2013, 5:12:14 AM4/8/13
to ns-3-...@googlegroups.com
can you tell me how to get sinr value in lte for enb..??


On Thursday, February 23, 2012 10:24:45 PM UTC+5:30, Konstantinos wrote:
Dear Adel,

since I use the SnrTag myself, here is how I have done it:

Add this code in yans-wifi-phy.cc

      double signalDbm = RatioToDb (event->GetRxPowerW ()) + 30;
      double noiseDbm = RatioToDb (event->GetRxPowerW () / snrPer.snr) - GetRxNoiseFigure () + 30;
      NotifyMonitorSniffRx (packet, (uint16_t)GetChannelFrequencyMhz (), GetChannelNumber (), dataRate500KbpsUnits, isShortPreamble, signalDbm, noiseDbm);
      // **********  SNR TAG  *********** //
      SnrTag tag;
      tag.Set(signalDbm - noiseDbm);
      if (! packet->PeekPacketTag (tag))
        {
          packet->AddPacketTag (tag);
          NS_LOG_DEBUG("Add SNR Tag with value :" << tag.Get());
        }
      // *********  SNR TAG  *********** //

So, right after you notify that a packet is received and you have the signal and noise (plus interference) values in dBm, the sinr value (in dB) is just just (signal-noise)

Then, when you have to read it, you can use this code (where temp_snr is a variable that you can work with):

  Ptr<Packet> packet = receivedPacket;

  // ***** SNR **** //
  SnrTag tag;
  if (packet->PeekPacketTag(tag)){
      NS_LOG_DEBUG ("Received Packet with SRN = " << tag.Get());
      temp_snr = tag.Get();
  }
  // ***** SNR **** //

Regards,
Konstantinos
Message has been deleted

Kurt Ricci

unread,
Apr 30, 2013, 3:13:17 AM4/30/13
to ns-3-...@googlegroups.com
Hi, 

I deleted my old message cause I think I've managed to make it work. Though I'm still a bit sceptical. For a distance of 50m I'm getting an SNR of around 26. Does this make sense? I've attached the new code. If anyone can take a look at it, it would be great. Thanks :)


On Thursday, February 23, 2012 4:53:28 PM UTC+1, Networks Geek wrote:
Hi,

I am somehow new to ns3 and the thing is, I would like to fetch the
snr Value when I receive a packet in a wireless station. I wonder how
to do that using SNR tags ?

Thank you in advance,
Adel.
wifi-simple-adhoc-grid1.cc
snr-tag.h

Konstantinos

unread,
Apr 30, 2013, 6:06:35 AM4/30/13
to ns-3-...@googlegroups.com
SNR depends on the Propagation model that you use, and the configuration of your PHY (Tx/Rx Gains, Tx Power etc).
In the documentation you can find the default values (for those that you haven't modified) and the formulas used to calculate the loss (e.g. for Friss)

Then you can do your calculation on the paper and verify if the results you get from NS-3 are correct or not.

Kurt Ricci

unread,
Apr 30, 2013, 6:24:11 AM4/30/13
to ns-3-...@googlegroups.com
Yes thanks...I couldnt find them in the documentation but i found them in PHY and they seem to be correct from the calculations.

Thanks once again :)

Prosper

unread,
Sep 18, 2013, 9:45:01 PM9/18/13
to ns-3-...@googlegroups.com
Konstantinos,

My question might be basic to you and the forum. I am desperately stuck anyway. What I want to do is add a SNR tag on every successfully received packet at PHY and later make decisions at MAC layer.
I have been trying to follow all the instructions on this thread on how to add the SNR tag at PHY layer. However, STILL the code does not compile. I get this error message over and over again:

*****************************************************************************************************************************

Waf: Entering directory `/home/mafole/tarballs/ns-allinone-3.16/ns-3.16/build'
[ 716/1515] cxx: scratch/lowTraffic-ec-wifi-model-opt.cc -> build/scratch/lowTraffic-ec-wifi-model-opt.cc.3.o
[ 774/1515] cxx: src/wifi/model/yans-wifi-phy.cc -> build/src/wifi/model/yans-wifi-phy.cc.1.o
../src/wifi/model/yans-wifi-phy.cc:21:25: fatal error: ns3/snr-tag.h: No such file or directory
compilation terminated.
../scratch/lowTraffic-ec-wifi-model-opt.cc:42:25: fatal error: ns3/snr-tag.h: No such file or directory
compilation terminated.
Waf: Leaving directory `/home/mafole/tarballs/ns-allinone-3.16/ns-3.16/build'
Build failed

********************************************************************************************************************************

Here is what I did:

1. I added the  snr-tag.h  and  snr-tag.cc  files  in the ~src/wifi/model/ directory(The same place where yans-wifi-phy.cc and yans-wifi-phy.h reside)
2. I have inserted the line #include "ns3/snr-tag.h" in the yans-wifi-phy.cc file and my script file.
3. My script file resides in ~/scratch/ directory.
4. I use ns3-16.

However, every time i compile the code I keep getting the error message above. Some thing is wrong somewhere. Please kindly help.
Thank you in advance.

Konstantinos

unread,
Sep 19, 2013, 4:37:33 AM9/19/13
to ns-3-...@googlegroups.com
Hi,

You are missing one step. You have to tell the compiler to 'build' the SnrTag and to include the 'snr-tag.h' file in the list of ns3 headers.
This is done by modifying the wscript file of wifi module. You need to add the .cc file in the list of files to be built and the .h file in the list of header files.

Then you can use the SnrTag. 

Regards,
K.
Message has been deleted

Prosper

unread,
Sep 19, 2013, 9:18:18 PM9/19/13
to ns-3-...@googlegroups.com
Konstantinos,
Thank you a lot. It builds with no errors. Thanks so much :-)

Huamiao Hu

unread,
Nov 26, 2013, 10:04:45 AM11/26/13
to ns-3-...@googlegroups.com
Hi Konstantinos,

I followed your description to modify the ns3 to get the SNR value.
But when I run the simulation, the SNRs are all different values in the same distance. Here is my code.
Can you point out where am I wrong! Thank you so much!

#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/wifi-module.h"
#include "ns3/internet-module.h"
#include "ns3/point-to-point-module.h"
#include "ns3/mobility-module.h"
#include "ns3/applications-module.h"
#include "ns3/csma-module.h"
#include "ns3/flow-monitor-module.h"
#include <ns3/snr-tag.h>
#include <ns3/packet-sink.h>
#include <fstream>

using namespace ns3;
using namespace std;

NS_LOG_COMPONENT_DEFINE ("wifi_802.11g");

void ReceivePacket (Ptr<const Packet> packet, const Address & address)
{
SnrTag tag;
if (packet->PeekPacketTag(tag))
{
NS_LOG_DEBUG("Received Packet with SNR =" << tag.Get());
}
std::cout << "SNR = " << tag.Get() << std::endl;
}

int main (int argc, char *argv[])
{
uint32_t nMeteringNodes = 1;

CommandLine cmd;
cmd.AddValue ("nMeteringNodes", "Number of Metering Nodes", nMeteringNodes);
cmd.Parse (argc,argv);
    
NodeContainer p2pNodes;
p2pNodes.Create (2);

PointToPointHelper pointToPoint;
pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms"));

NetDeviceContainer p2pDevices;
p2pDevices = pointToPoint.Install (p2pNodes);

NodeContainer meteringNodes;
meteringNodes.Create (nMeteringNodes);
NodeContainer apNodes = p2pNodes.Get (0);

WifiHelper wifi;
wifi.SetStandard (WIFI_PHY_STANDARD_80211g);
wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
                         "DataMode", StringValue ("ErpOfdmRate24Mbps"));

YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();

YansWifiChannelHelper channel;
channel.AddPropagationLoss ("ns3::LogDistancePropagationLossModel",
                       "ReferenceLoss", DoubleValue (40.0460));
channel.AddPropagationLoss ("ns3::NakagamiPropagationLossModel",
                       "m0", DoubleValue (1),
"m1", DoubleValue (1),
"m2", DoubleValue (1));
channel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel");

phy.SetChannel (channel.Create ());
NqosWifiMacHelper mac = NqosWifiMacHelper::Default ();

Ssid ssid = Ssid ("ns-3-802.11g");
mac.SetType ("ns3::StaWifiMac",
        "Ssid", SsidValue (ssid),
"ActiveProbing", BooleanValue (false));

NetDeviceContainer staDevices;
staDevices = wifi.Install (phy, mac, meteringNodes);

mac.SetType ("ns3::ApWifiMac",
        "Ssid", SsidValue (ssid));

NetDeviceContainer apDevices;
apDevices = wifi.Install (phy, mac, apNodes);

MobilityHelper mobility;

Ptr<ListPositionAllocator> BsAlloc = CreateObject<ListPositionAllocator> ();

BsAlloc->Add(Vector (0.0, 0.0, 0.0));

mobility.SetPositionAllocator (BsAlloc);

mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");

mobility.Install (apNodes);

Ptr<ListPositionAllocator> meteringAlloc = CreateObject<ListPositionAllocator> ();

    double x = 50.0;
for (uint32_t i = 0; i < nMeteringNodes; i++)
{
meteringAlloc->Add (Vector (0.0, x, 0.0));
x += 2.0;
}

mobility.SetPositionAllocator (meteringAlloc);

mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");

mobility.Install (meteringNodes);

InternetStackHelper stack;
stack.Install (p2pNodes);
stack.Install (meteringNodes);

Ipv4AddressHelper address;

address.SetBase ("10.1.1.0", "255.255.255.0");
Ipv4InterfaceContainer p2pInterfaces;
p2pInterfaces = address.Assign (p2pDevices);

address.SetBase ("10.1.2.0", "255.255.255.0");
address.Assign (staDevices);
address.Assign (apDevices);

Ipv4GlobalRoutingHelper::PopulateRoutingTables ();

UdpServerHelper Server (9);

PacketSinkHelper sinkHelp ("ns3::UdpSocketFactory", (InetSocketAddress (Ipv4Address ("10.1.1.1"), 9)));
ApplicationContainer Sinks = sinkHelp.Install (p2pNodes.Get(0));
Sinks.Start (Seconds (0.0));
Sinks.Stop (Seconds (15.0));

ApplicationContainer serverApps = Server.Install (p2pNodes.Get(0));
serverApps.Start (Seconds (0.0));
serverApps.Stop (Seconds (15.0));

UdpClientHelper Client (p2pInterfaces.GetAddress (0), 9);
Client.SetAttribute ("MaxPackets", UintegerValue (10000000));
Client.SetAttribute ("Interval", TimeValue (Seconds (1.0)));
Client.SetAttribute ("PacketSize", UintegerValue (1024));

ApplicationContainer clientApps = Client.Install (meteringNodes.Get(0));
clientApps.Start (Seconds (1.0 ));
clientApps.Stop (Seconds (11.0 ));

Config::ConnectWithoutContext ("/NodeList/*/ApplicationList/*/$ns3::PacketSink/Rx", MakeCallback (&ReceivePacket));

FlowMonitorHelper flowmon;
Ptr<FlowMonitor> monitor = flowmon.InstallAll ();

Simulator::Stop (Seconds (15.0));
Simulator::Run ();

monitor->CheckForLostPackets ();
Ptr<Ipv4FlowClassifier> classifier = DynamicCast<Ipv4FlowClassifier> (flowmon.GetClassifier ());
std::map<FlowId, FlowMonitor::FlowStats> stats = monitor->GetFlowStats ();

for (std::map<FlowId, FlowMonitor::FlowStats>::const_iterator i = stats.begin (); i != stats.end (); ++i)
{

Ipv4FlowClassifier::FiveTuple t = classifier->FindFlow (i->first);
//std::cout << "Flow " << i->first << " (" << t.sourceAddress << " -> " << t.destinationAddress << ")\n";  

std::cout << " All Tx Packets: " << i->second.txPackets << "\n";
std::cout << " All Rx Packets: " << i->second.rxPackets << "\n";
std::cout << " Throughput: " << (i->second.rxBytes * 8 )/ (((i->second.timeLastRxPacket)-(i->second.timeFirstTxPacket))/1000000000)<< " bps" << "\n";
}

Simulator::Destroy ();
return 0;
}

Huamiao

Konstantinos

unread,
Nov 26, 2013, 10:54:39 AM11/26/13
to ns-3-...@googlegroups.com
This is expected in your scenario that you use fast-fading model (Nakagami)

If you commend these lines it should be constant (only affected by the LogDistance model)
channel.AddPropagationLoss ("ns3::NakagamiPropagationLossModel",
                        "m0", DoubleValue (1),
"m1", DoubleValue (1),
"m2", DoubleValue (1));



Huamiao Hu

unread,
Nov 26, 2013, 11:08:04 AM11/26/13
to ns-3-...@googlegroups.com
Hi Konstantinos,

Thank you so much! I understand now. 
Can I ask one more question, how can I get rayleigh channel?
I set with
channel.AddPropagationLoss ("ns3::LogDistancePropagationLossModel",
                            "ReferenceLoss", DoubleValue (40.0460));
channel.AddPropagationLoss ("ns3::NakagamiPropagationLossModel",
                            "m0", DoubleValue (1),
"m1", DoubleValue (1),
"m2", DoubleValue (1));
Is that correct? Thanks a lot!

Huamiao

Konstantinos

unread,
Nov 26, 2013, 12:26:20 PM11/26/13
to ns-3-...@googlegroups.com
As stated in the documentation: 
For m = 1 the Nakagami-m distribution equals the Rayleigh distribution. Thus this model also implements Rayleigh distribution based fast fading.

So, what you have done below, is correct.

Huamiao Hu

unread,
Nov 27, 2013, 5:59:06 AM11/27/13
to ns-3-...@googlegroups.com
Thank you very much!

Huamuai

Mohammed Alshaboti

unread,
Mar 5, 2014, 7:47:27 PM3/5/14
to ns-3-...@googlegroups.com
Hi,
I am trying get snr using the code you mentioned. But if gives me nothing.

Maybe as you said because the SnrTag is declared in mal-low.cc. 
I'm trying to move it to new header file my-snr.h. 

Could you help me how to declare SnrTag in new header file?

#ifndef MY_SNR_H
#define MY_SNR_H

#include "ns3/snr-tag.h"

namespace ns3 {
SnrTag tag;
}; // namespace ns3

#endif /* CROSS_LAYER_H */


On Thursday, February 23, 2012 8:25:44 PM UTC+3, Networks Geek wrote:

Now that sounds logical, because before when I used the SNR values
from the mac-low I had very large SNR Values, now I am having
reasonable values.

Thanks again,
Best regards,
Adel.

On Feb 23, 5:54 pm, Konstantinos <dinos.katsa...@gmail.com> wrote:
> Dear Adel,
>
> since I use the SnrTag myself, here is how I have done it:
>
> Add this code in yans-wifi-phy.cc
>
>       double signalDbm = RatioToDb (event->GetRxPowerW ()) + 30;
>       double noiseDbm = RatioToDb (event->GetRxPowerW () / snrPer.snr) -
> GetRxNoiseFigure () + 30;
>       NotifyMonitorSniffRx (packet, (uint16_t)GetChannelFrequencyMhz (),
> GetChannelNumber (), dataRate500KbpsUnits, isShortPreamble, signalDbm,
> noiseDbm);
>       // **********  SNR TAG  *********** //
>       SnrTag tag;
>       tag.Set(signalDbm - noiseDbm);
>       if (! packet->PeekPacketTag (tag))
>         {
>           packet->AddPacketTag (tag);
>           NS_LOG_DEBUG("Add SNR Tag with value :" << tag.Get());
>         }
>       // *********  SNR TAG  *********** //
>
> So, right after you notify that a packet is received and you have the
> signal and noise (plus interference) values in dBm, the sinr value (in dB)
> is just just (signal-noise)
>
> Then, when you have to read it, you can use this code (where temp_snr is a
> variable that you can work with):
>
>   Ptr<Packet> packet = receivedPacket;
>
>   // ***** SNR **** //
>   SnrTag tag;
>   if (packet->PeekPacketTag(tag)){
>       NS_LOG_DEBUG ("Received Packet with SRN = " << tag.Get());
>       temp_snr = tag.Get();
>   }
>   // ***** SNR **** //
>
> Regards,
> Konstantinos

Konstantinos

unread,
Mar 6, 2014, 6:11:29 AM3/6/14
to ns-3-...@googlegroups.com
Which ns-3 release are you using? The answer was 2yr old and since then at least 5-6 new releases of ns-3 have come with changes on of which was related to SNR tag.
The SNR tag has been de-coupled from mac-low.cc and there is no need to create a new header.

If you read the complete discussion in this thread and in others, you can see how you can get SNR value.

silviocs

unread,
Jul 11, 2014, 9:45:10 AM7/11/14
to ns-3-...@googlegroups.com
I think the file snr-tag.cc is missing here... :/

-- Silvio Sampaio


On Tuesday, April 30, 2013 8:13:17 AM UTC+1, Kurt Ricci wrote:

Aniesh Chawla

unread,
Sep 3, 2014, 2:20:07 AM9/3/14
to ns-3-...@googlegroups.com
Hi Konstantinos,
I have read the SNR tag and still my value is coming out to be zero. I am presently using ns-3.20 and ns-3.13 both.
I have put the following code in yans-wifi-phy.cc
SnrTag tag;
tag.Set(signalDbm - noiseDbm);
      if (!packet->PeekPacketTag (tag))

        {
          packet->AddPacketTag (tag);
          NS_LOG_DEBUG("Add SNR Tag with value :" << tag.Get());
        }


and in my file I am using
void SinkRxTrace(Ptr<const Packet> pkt,const Address &address)
{
        SnrTag tag;
        DoubleValue temp_snr;

  if (pkt->PeekPacketTag(tag)) {
       NS_LOG_DEBUG ("Received Packet with SNR = " << tag.Get());
      temp_snr = tag.Get();

      }
std::cout << "SNR = " << tag.Get() << std::endl;
---- this is printing as 0
std::cout << "SNR = " << temp_snr.Get() << std::endl; ---- this is also printing as 0

I am using YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
I am always getting temp_snr.Get() value is zero
I am not able to understand why this is happening. I also printed the value of SNR at the Yan-wifi-phy file and I am getting values there. But here always I am getting the value as zero. Am I doing something wrong?

Regards
Aniesh

Tommaso Pecorella

unread,
Sep 3, 2014, 2:48:08 AM9/3/14
to ns-3-...@googlegroups.com
Hi,

this has been discussed multiple times in other threads.
Do not use PacketTags for information that have to be transferred between nodes.

Try using ByteTags.

Moreover, if the tag has been found but the value is zero, then you must have done something very wrong with the Serialize and Deserialize methods in the tag.

In any case, this thread is kinda messed up. It started 2 years ago, then it was "freshened" by people asking random stuff, etc.
Please use a new one. I'd ask Kostantinos to close lock this thread for good (if possible) to avoid further misuse.

T.

th_...@qq.com

unread,
Apr 23, 2015, 9:52:43 AM4/23/15
to ns-3-...@googlegroups.com
hi,Jeremy
It's been 2 years,I hope you still work on ns3 and be in this group.
Maybe I met the same problem as yours two years ago,I saw you said that you changed your sink from tcp to udp,how exactly did you do that?
Really hope for your reply.

Mark

在 2013年3月23日星期六 UTC+8上午4:16:19,Jeremy Mack写道:

Jeremy Mack

unread,
Apr 23, 2015, 3:58:04 PM4/23/15
to ns-3-...@googlegroups.com
Hey Mark,

You just have to change the "Protocol" attribute for the PacketSink.

Jeremy

th_...@qq.com

unread,
Apr 24, 2015, 2:23:11 AM4/24/15
to ns-3-...@googlegroups.com
Hi,Jeremy
Thanks a lot.But I didn't use PacketSinkHelper,I just send sockets directly just like "wifi-simple-adhoc-grid.cc" does.
There is another request.Could you let me see your scratch code?
Maybe I can learn from it.

Mark

在 2015年4月24日星期五 UTC+8上午3:58:04,Jeremy Mack写道:

mughalh...@gmail.com

unread,
Nov 25, 2017, 2:23:24 AM11/25/17
to ns-3-users
Dear Konstantinos,
I hope you are doing well, I wanted to know that where/how to add this code in yans-wifi-phy.cc? As in this class there are only few methods i.e. constructors, DoDispose, GetChannel, SetChannel and StartTx. Do I need to create another method and declare it first in header file and initialize it in this cc file?
Actually, I am trying to find the default transmission power sent and received during transmission of packets.
Thanks
Best Regards,
Hassam Mughal

On Friday, February 24, 2012 at 1:54:45 AM UTC+9, Konstantinos wrote:
Dear Adel,

since I use the SnrTag myself, here is how I have done it:

Add this code in yans-wifi-phy.cc

      double signalDbm = RatioToDb (event->GetRxPowerW ()) + 30;
      double noiseDbm = RatioToDb (event->GetRxPowerW () / snrPer.snr) - GetRxNoiseFigure () + 30;
      NotifyMonitorSniffRx (packet, (uint16_t)GetChannelFrequencyMhz (), GetChannelNumber (), dataRate500KbpsUnits, isShortPreamble, signalDbm, noiseDbm);
      // **********  SNR TAG  *********** //
      SnrTag tag;
      tag.Set(signalDbm - noiseDbm);
      if (! packet->PeekPacketTag (tag))

        {
          packet->AddPacketTag (tag);
          NS_LOG_DEBUG("Add SNR Tag with value :" << tag.Get());
        }
      // *********  SNR TAG  *********** //

So, right after you notify that a packet is received and you have the signal and noise (plus interference) values in dBm, the sinr value (in dB) is just just (signal-noise)

Then, when you have to read it, you can use this code (where temp_snr is a variable that you can work with):

  Ptr<Packet> packet = receivedPacket;

  // ***** SNR **** //
  SnrTag tag;
  if (packet->PeekPacketTag(tag)){
      NS_LOG_DEBUG ("Received Packet with SRN = " << tag.Get());
      temp_snr = tag.Get();
  }

mughalh...@gmail.com

unread,
Nov 25, 2017, 7:57:04 AM11/25/17
to ns-3-users
Can you help me in identifying how the Konstantinos code worked? Like where exactly to add this code in the yans-wifi-phy.cc class?


On Friday, February 24, 2012 at 2:25:44 AM UTC+9, Networks Geek wrote:

Now that sounds logical, because before when I used the SNR values
from the mac-low I had very large SNR Values, now I am having
reasonable values.

Thanks again,
Best regards,
Adel.

mughalh...@gmail.com

unread,
Nov 25, 2017, 7:59:33 AM11/25/17
to ns-3-users
Hi Jeremy,
I hope you are doing well, Can you guide me like where to put the code of SNR in yans-wifi-phy.cc class shared by Konstantinos?
Thanks


On Tuesday, March 5, 2013 at 4:59:41 AM UTC+9, Jeremy Mack wrote:
Hello Konstantinos,

I put the your code into the yans-wifi-phy.cc file, but am having an error when trying to build the file. It says the SnrTag was not declared in the scope. I tried adding #include "ns3/tag.h" but it still give me the same error.

Thanks again for the fast reply !

Jeremy

On Monday, 4 March 2013 14:36:28 UTC-5, Konstantinos wrote:
Dear Jeremy,

The OnOff Application is for generating the packets. 
If you are using wifi, just add the first code snippet in yans-wifi-phy.cc which will add the SNR tag to the packets when received.

Now to read it you have to either modify the PacketSink or any other sink application that you use to "receive" the packets.

The easiest way to do it without modifications to existing code, is with the use of callback. Use the Config::Connect to connect a callback on the sink application which will triggered each time a packet is received (at the application layer). Then you can print the SNR with the second code snippet.


On Monday, March 4, 2013 7:20:06 PM UTC, Jeremy Mack wrote:
Hello Konstantinos,

Thank you for your help on the forums, your replies have helped me a lot these last few months while trying to learn ns-3. 

I am trying to determine the received power of each received packet so this example really helps. The only thing I am confused about is  when/how to read it. Currently I am use an On Off Application to generate traffic,so where exact do I put the code you gave  that reads the packets? Do I have to put it into the On Off application file or would it go my file?

Thanks,

Jeremy

Tommaso Pecorella

unread,
Nov 25, 2017, 8:33:05 AM11/25/17
to ns-3-users
The WifiPhy promiscuous trace contains the SNR value:
    .AddTraceSource ("MonitorSnifferRx",
                     
"Trace source simulating a wifi device in monitor mode "
                     
"sniffing all received frames",
                     
MakeTraceSourceAccessor (&WifiPhy::m_phyMonitorSniffRxTrace),
                     
"ns3::WifiPhy::MonitorSnifferRxTracedCallback")

  /**
   * A trace source that emulates a wifi device in monitor mode
   * sniffing a packet being received.
   *
   * As a reference with the real world, firing this trace
   * corresponds in the madwifi driver to calling the function
   * ieee80211_input_monitor()
   *
   * \see class CallBackTraceSource
   * \todo WifiTxVector and signalNoiseDbm should be be passed as
   * const  references because of their sizes.
   */

 
TracedCallback<Ptr<const Packet>, uint16_t, WifiTxVector, MpduInfo, SignalNoiseDbm> m_phyMonitorSniffRxTrace;


Mind that you'll need to filter the packets that belongs to you, because this is a promiscuous Rx trace.

T.

Hassam Mughal

unread,
Jan 2, 2018, 11:10:08 AM1/2/18
to ns-3-...@googlegroups.com
Dear Tommaso Pecorella,
Can you please provide some guidelines of how to implement this in my routing protocol class? I am unable to find any implementation tutorials in which these traced callbacks are being used in routing protocol class, as they belong to physical layer.

--
Posting to this group should follow these guidelines https://www.nsnam.org/wiki/Ns-3-users-guidelines-for-posting
---
You received this message because you are subscribed to a topic in the Google Groups "ns-3-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ns-3-users/eLAgrrd1aw4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ns-3-users+unsubscribe@googlegroups.com.
To post to this group, send email to ns-3-...@googlegroups.com.
Visit this group at https://groups.google.com/group/ns-3-users.
For more options, visit https://groups.google.com/d/optout.



--
Thanks
Best Regards,

Hassam Mughal
Research Associate & MS Student
Department of Information and Communication Engineering
Hankuk University of Foreign Studies, Global Campus, South Korea
Treasurer - IEEE Computer Society Karachi Section
Co-Founder - Electronics Junkies

Tommaso Pecorella

unread,
Jan 3, 2018, 6:40:34 PM1/3/18
to ns-3-users
Hi,

an example of MonitorSnifferRx is in examples/wireless/wifi-spectrum-per-example.cc
You'll have to create a function in your routing protocol, setup the callback like in the example and filter the packets you need.

T.
To unsubscribe from this group and all its topics, send an email to ns-3-users+...@googlegroups.com.

To post to this group, send email to ns-3-...@googlegroups.com.
Visit this group at https://groups.google.com/group/ns-3-users.
For more options, visit https://groups.google.com/d/optout.

Hassam Mughal

unread,
Jan 4, 2018, 1:17:40 AM1/4/18
to ns-3-...@googlegroups.com
Dear Tommaso,
A bundle of thanks. Two more things,First, what is the best way to get the routing protocol header's value in the Wifi-Phy.cc and dsdv-manet.cc? Do I need to create a packet tag in my routing protocol class and add the packet tag there, and Extract it in the Wifi-Phy.cc and dsdv-manet.cc classes using PeekPacketTag?
I have tried to create the instance of the dsdv header class, but I am unable to create it in these class, as it says could not be resolved, even after importing the dsdv-header class. Second, is this the right way to let the physical layer know the transmission power it has to use using the above technique? Or there is some other way to do so?
Thanks for your kindness and guidelines.

To unsubscribe from this group and all its topics, send an email to ns-3-users+unsubscribe@googlegroups.com.

To post to this group, send email to ns-3-...@googlegroups.com.
Visit this group at https://groups.google.com/group/ns-3-users.
For more options, visit https://groups.google.com/d/optout.

Tommaso Pecorella

unread,
Jan 4, 2018, 6:03:35 PM1/4/18
to ns-3-users
Hi,

yes, a PacketTag is the best solution.
Mind that not all the packets will have that Tag - you'll need to make sure that you gracefully handle this situation.

T.

Hassam Mughal

unread,
Jan 4, 2018, 9:14:38 PM1/4/18
to ns-3-...@googlegroups.com
Yah exactly. That's the issue I am facing at the moment. Because packet is being encapsulated at each level accordingly.

To unsubscribe from this group and all its topics, send an email to ns-3-users+unsubscribe@googlegroups.com.

To post to this group, send email to ns-3-...@googlegroups.com.
Visit this group at https://groups.google.com/group/ns-3-users.
For more options, visit https://groups.google.com/d/optout.
Message has been deleted
Message has been deleted

KS

unread,
Apr 15, 2020, 6:01:46 PM4/15/20
to ns-3-users
Hello,

Is it possible to get interference too?
I am trying to get the value of the SINR and I am using YansWifiChannel.
Reply all
Reply to author
Forward
0 new messages