# HG changeset patch # User Konstantinos Katsaros # Date 1360521515 18000 # Node ID 310d371059d5552790c47a830becd0d52bc994af # Parent 4a9feececbf3de8b4a8cf12f765b285c015cfd63 Bug 1566 - WiFi SNR tag improvements diff -r 4a9feececbf3 -r 310d371059d5 src/wifi/model/mac-low.cc --- a/src/wifi/model/mac-low.cc Sat Feb 09 11:23:11 2013 -0800 +++ b/src/wifi/model/mac-low.cc Sun Feb 10 13:38:35 2013 -0500 @@ -33,6 +33,7 @@ #include "wifi-mac-trailer.h" #include "qos-utils.h" #include "edca-txop-n.h" +#include "snr-tag.h" NS_LOG_COMPONENT_DEFINE ("MacLow"); @@ -42,74 +43,6 @@ namespace ns3 { -class SnrTag : 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 (double snr); - double Get (void) const; -private: - double m_snr; -}; - -TypeId -SnrTag::GetTypeId (void) -{ - static TypeId tid = TypeId ("ns3::SnrTag") - .SetParent () - .AddConstructor () - .AddAttribute ("Snr", "The snr of the last packet received", - DoubleValue (0.0), - MakeDoubleAccessor (&SnrTag::Get), - MakeDoubleChecker ()) - ; - return tid; -} -TypeId -SnrTag::GetInstanceTypeId (void) const -{ - return GetTypeId (); -} - -uint32_t -SnrTag::GetSerializedSize (void) const -{ - return sizeof (double); -} -void -SnrTag::Serialize (TagBuffer i) const -{ - i.WriteDouble (m_snr); -} -void -SnrTag::Deserialize (TagBuffer i) -{ - m_snr = i.ReadDouble (); -} -void -SnrTag::Print (std::ostream &os) const -{ - os << "Snr=" << m_snr; -} -void -SnrTag::Set (double snr) -{ - m_snr = snr; -} -double -SnrTag::Get (void) const -{ - return m_snr; -} - - MacLowTransmissionListener::MacLowTransmissionListener () { } diff -r 4a9feececbf3 -r 310d371059d5 src/wifi/model/snr-tag.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/wifi/model/snr-tag.cc Sun Feb 10 13:38:35 2013 -0500 @@ -0,0 +1,94 @@ +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2005,2006 INRIA + * Copyright (c) 2009 MIRKO BANCHI + * Copyright (c) 2013 University of Surrey + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Mathieu Lacage + * Author: Mirko Banchi + * Author: Konstantinos Katsaros + */ + +#include "snr-tag.h" +#include "ns3/tag.h" +#include "ns3/double.h" + +namespace ns3 { + +NS_OBJECT_ENSURE_REGISTERED (SnrTag); + +TypeId +SnrTag::GetTypeId (void) +{ + static TypeId tid = TypeId ("ns3::SnrTag") + .SetParent () + .AddConstructor () + .AddAttribute ("Snr", "The snr of the last packet received", + DoubleValue (0.0), + MakeDoubleAccessor (&SnrTag::Get), + MakeDoubleChecker ()) + ; + return tid; +} +TypeId +SnrTag::GetInstanceTypeId (void) const +{ + return GetTypeId (); +} + +SnrTag::SnrTag () + : m_snr (0) +{ +} +SnrTag::SnrTag (double snr) + : m_snr (snr) +{ +} + + +uint32_t +SnrTag::GetSerializedSize (void) const +{ + return sizeof (double); +} +void +SnrTag::Serialize (TagBuffer i) const +{ + i.WriteDouble (m_snr); +} +void +SnrTag::Deserialize (TagBuffer i) +{ + m_snr = i.ReadDouble (); +} +void +SnrTag::Print (std::ostream &os) const +{ + os << "Snr=" << m_snr; +} +void +SnrTag::Set (double snr) +{ + m_snr = snr; +} +double +SnrTag::Get (void) const +{ + return m_snr; +} + + +} diff -r 4a9feececbf3 -r 310d371059d5 src/wifi/model/snr-tag.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/wifi/model/snr-tag.h Sun Feb 10 13:38:35 2013 -0500 @@ -0,0 +1,68 @@ +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2005,2006 INRIA + * Copyright (c) 2009 MIRKO BANCHI + * Copyright (c) 2013 University of Surrey + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Mathieu Lacage + * Author: Mirko Banchi + * Author: Konstantinos Katsaros + */ + +#ifndef SNR_TAG_H +#define SNR_TAG_H + +#include "ns3/packet.h" + +namespace ns3 { + +class Tag; + +class SnrTag : public Tag +{ +public: + static TypeId GetTypeId (void); + virtual TypeId GetInstanceTypeId (void) const; + + /** + * Create a SnrTag with the default snr 0 + */ + SnrTag(); + + /** + * Create a SnrTag with the given snr value + */ + SnrTag(double snr); + + virtual uint32_t GetSerializedSize (void) const; + virtual void Serialize (TagBuffer i) const; + virtual void Deserialize (TagBuffer i); + virtual void Print (std::ostream &os) const; + + /** + * Set the SNR to the given value. + * + * @param snr the value of the snr to set + */ + void Set (double snr); + double Get (void) const; +private: + double m_snr; +}; + + +} +#endif /* SNR_TAG_H */ diff -r 4a9feececbf3 -r 310d371059d5 src/wifi/wscript --- a/src/wifi/wscript Sat Feb 09 11:23:11 2013 -0800 +++ b/src/wifi/wscript Sun Feb 10 13:38:35 2013 -0500 @@ -60,6 +60,7 @@ 'model/block-ack-agreement.cc', 'model/block-ack-manager.cc', 'model/block-ack-cache.cc', + 'model/snr-tag.cc', 'helper/athstats-helper.cc', 'helper/wifi-helper.cc', 'helper/yans-wifi-helper.cc', @@ -132,6 +133,7 @@ 'model/block-ack-agreement.h', 'model/block-ack-manager.h', 'model/block-ack-cache.h', + 'model/snr-tag.h', 'helper/athstats-helper.h', 'helper/wifi-helper.h', 'helper/yans-wifi-helper.h',