Difficulties with the snr-tag

491 views
Skip to first unread message

Yair Samson

unread,
Sep 9, 2014, 10:20:08 AM9/9/14
to ns-3-...@googlegroups.com
Hi guys

I am desperately stuck, I am trying to display the snr-tag after I received the packet.
i followed this guide,

I know it's lil bit old and that the files already exists, and i dont need to create and add them.

the problem is that i am getting that the snr value is zero all the time,
I also printed the value of the SNR at the Yan-wifi-phy file and I am getting values there, so i am pretty sure 
that the values of the snr isn't zero when i add it to the packet. 
the problem is that I always get the value 0 at the receive callback.

another question,

I've been using this use of snr, using the callback of PhyRxOkTrace 

PhyRxOkTrace (std::string context, Ptr<const Packet> packet, double snr, WifiMode mode, enum WifiPreamble preamble)

and i was wondering, if this snr is the as the snr-tag calculation?  

i would appreciate any help..

Regards,
Yair

Konstantinos

unread,
Sep 9, 2014, 11:04:20 AM9/9/14
to ns-3-...@googlegroups.com
Dear Yair,

Please provide the scenario script and the modified YansWifiPhy that you have added the SNR tag to check where the problem might be. 

As for the SNR in the SNRtag and the PhyRxOk, they are different.
If you check the source code, the SNRtag uses (signal - noise) in dB as specified in the link you posted.
837  double signalDbm = RatioToDb (event->GetRxPowerW ()) + 30;
838  double noiseDbm = RatioToDb (event->GetRxPowerW () / snrPer.snr) - GetRxNoiseFigure () + 30;

and PhyRxOk uses which is in Watt not in dB.
827  snrPer = m_interference.CalculateSnrPer (event);

Yair Samson

unread,
Sep 10, 2014, 2:54:55 AM9/10/14
to ns-3-...@googlegroups.com
Hi Konstantinos,

Thank you for your help.

I am using NS-3.19 version.

I have the snr-tag.cc and snr-tag.h files, and i modified the wscript file, and it complie ok.

At yans-wifi-phy.cc file , I modified it like you said in previous threads:












Then, in my file, i tried to read the snr-tag and the value that I received is always 0.
I used callback for receive and read the value from the packet.
I attached the relevant files.

Regards,
Yair.



בתאריך יום שלישי, 9 בספטמבר 2014 18:04:20 UTC+3, מאת Konstantinos:
yans-wifi-phy.cc
snr-tag.cc
snr-tag.h

Konstantinos

unread,
Sep 10, 2014, 4:22:47 AM9/10/14
to ns-3-...@googlegroups.com
Hi Yair,

As I thought, the problem is in the yans-wifi-phy and the order you have the methods.
You add your SNRtag after this method
m_state->SwitchFromRxEndOk (packet, snrPer.snr, event->GetPayloadMode (), event->GetPreambleType ());
which is the linking between PHY and upper layer, ie informing that the packet is received.
The packet you pass as parameter with this method does not have an SNRtag because you add it afterwards.

However, I would also like to see the printing, how you read the SNR to confirm the issue. Because you should also check if there is a SNRtag to print. 
And in your case there shouldn't be, hence you should not see anything, not 0.

Yair Samson

unread,
Sep 10, 2014, 5:05:45 AM9/10/14
to ns-3-...@googlegroups.com
Hello Konstantinos.

You are right, the order was wrong, I dont know how i've missed it. maybe because it was late.
thank you very much for the help.
As for the value of zero, I noticed that the tag didnt exist, from the problem before and that the printing wasn't inside the case of if I got a tag, 
so as you said i didnt attched a tag and when i tried to get the value it was zero.

It's a stupid mistake that i made,
thank a lot for the help,
Yair.

בתאריך יום רביעי, 10 בספטמבר 2014 11:22:47 UTC+3, מאת Konstantinos:

Aniesh Chawla

unread,
Nov 17, 2014, 2:17:02 AM11/17/14
to ns-3-...@googlegroups.com

Hi
I have gone through https://groups.google.com/forum/#!msg/ns-3-users/eLAgrrd1aw4/J_It9pxscq0J
and in that also I asked the question in the end for which T replied that I should use ByteTag but I believe Packet tags are also working fine.
However, in my simulation I am not able to get any SNR tag values. Can you please help me identify the problem.
I have added SNR tag code at the right position in Yans-wifi-phy.cc and I am receiving packets by calling the function

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

Thanks a lot for your time

Regards
Aniesh

I am attaching the files along with this, please help me identify the error as to why peekpackettag is not giving anyvalue
yans-wifi-phy.cc
wifi-tcp-snr-adhoc.cc

Konstantinos

unread,
Nov 17, 2014, 4:41:01 AM11/17/14
to ns-3-...@googlegroups.com
Hi,

You are using TCP which is a byte-stream protocol and does not preserve packet boundaries.
So the received packet from PHY at which you attached the SNR tag, will be re-constructed at the TCP layer and hence lose the meta-data information (tags).

Solution: Use a different trace source (eg. at IP or MAC layer)

aniesh chawla

unread,
Nov 17, 2014, 4:53:26 AM11/17/14
to ns-3-...@googlegroups.com
Thanks a lot Konstantions, I was struggling on this for quite a long time.

--
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/X_n0NqTH2BU/unsubscribe.
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 http://groups.google.com/group/ns-3-users.
For more options, visit https://groups.google.com/d/optout.

Hadi Samani

unread,
Jun 15, 2016, 11:45:45 AM6/15/16
to ns-3-users
Hello

I use ns3 ns all in one 3.25 and I have added the snr tag in yans-wifi-phy.cc as Konstantinos mentioned. As I am new in ns3 and also C++ I do not know how should I call the snr tag in my script and connect it to my node, which is receiving packets in udp client server.
I want to get the SNR of the receiver node. would you please help me.

Best Regards
Hadi
yans-wifi-phy.cc
wifi-mobility14.cc

Mahesh

unread,
Sep 29, 2017, 10:55:05 AM9/29/17
to ns-3-users
Hi Konstantinos,

I am getting 0 SNR for all the nodes when I use TcpSocketFactory. You asked to use a different trace source. Which one should be used exactly ? Can you please clarify ? Currently, I have the following trace:
Config::ConnectWithoutContext("/NodeList/*/ApplicationList/*/$ns3::PacketSink/Rx",MakeCallback (&ReceivePacket));

Also, I am getting the source address in ReceivePacket output. For example,
Address = 10.1.1.1; SNR = 0

How do I get the destination address (whose SNR is to be displayed) ?

Konstantinos

unread,
Sep 29, 2017, 11:12:54 AM9/29/17
to ns-3-users
TCP does not respect packet boundaries. A packet received at PHY layer, where the SNR tag is attached, will be de-constructed to byte stream at TCP in order to send the application packet.
Hence the packet tag will be lost. It may survive it you use ByteTag, but then the results may not be correct as two pakcets received with different SNR may form a single application packet.
Therefore, I would suggest to either trace the TCP Rx event or directly at the PHY layer when the packet is received.

The second question about which nodes receives it, it can be easily infered by the context of the trace source, ie which node fires that.

Regards
K

Mahesh

unread,
Sep 29, 2017, 12:03:40 PM9/29/17
to ns-3-users
Hey K,

Thanks a lot for your kind reply.

I used TCP Rx trace as follows:
Config::ConnectWithoutContext("/NodeList/*/$ns3::TcpL4Protocol/SocketList/*/Rx", MakeCallback (&ReceivePacket));

Is this even correct ? Because I cannot see ReceivePacket function being triggered ? I am sorry for asking such a question, but I cannot figure a way to get the SNR for TCP packets. Regarding my second question, how do I print the destination at which SNR is measured corresponding to each ReceivePacket callback ?

Hoping for a reply.
Reply all
Reply to author
Forward
0 new messages