--
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.
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.
ThanksJeremy
--
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
ns3::PacketSink is accessible through the following paths with Config::Set and Config::Connect:
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 thisvoid ReceivePacket(Ptr<const Packet> packet, const Address &)
{
NS_LOG_DEBUG ("Received one packet!");
}
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
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
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.
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
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();
}
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.
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
.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;
--
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.
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.
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.
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.