Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(195)

Unified Diff: src/devices/uan/uan-mac-cw.h

Issue 1350041: UAN module addition
Patch Set: Created 13 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/devices/uan/uan-mac-cw.h
===================================================================
new file mode 100644
--- /dev/null
+++ b/src/devices/uan/uan-mac-cw.h
@@ -0,0 +1,120 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2009 University of Washington
+ *
+ * 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: Leonard Tracy <lentracy@gmail.com>
+ */
+
+#ifndef UANMACCW_H
+#define UANMACCW_H
+
+#include "ns3/uan-mac.h"
+#include "ns3/nstime.h"
+#include "ns3/simulator.h"
+#include "ns3/uan-phy.h"
+#include "ns3/uan-tx-mode.h"
+#include "ns3/uan-address.h"
+
+
+namespace ns3 {
+
+/**
+ * \class UanMacCw
+ * \brief CW-MAC A MAC protocol similar in idea to the 802.11 DCF with constant backoff window
+ *
+ * For more information on this MAC protocol, see:
+ * Parrish, N.; Tracy, L.; Roy, S.; Arabshahi, P.; Fox, W.,
+ * "System Design Considerations for Undersea Networks: Link and Multiple Access Protocols,"
+ * Selected Areas in Communications, IEEE Journal on , vol.26, no.9, pp.1720-1730, December 2008
+ */
+class UanMacCw : public ns3::UanMac,
+ public ns3::UanPhyListener
+{
+public:
+ UanMacCw ();
+ virtual ~UanMacCw ();
+ static TypeId GetTypeId (void);
+
+ /**
+ * \param cw Contention window size
+ */
+ virtual void SetCw (uint32_t cw);
+ /**
+ * \param duration Slot time duration
+ */
+ virtual void SetSlotTime (Time duration);
+ /**
+ * \returns Contention window size
+ */
+ virtual uint32_t GetCw (void);
+ /**
+ * \returns slot time duration
+ */
+ virtual Time GetSlotTime (void);
+
+ // Inherited methods
+ virtual Address GetAddress ();
+ virtual void SetAddress (UanAddress addr);
+ virtual bool Enqueue (Ptr<Packet> pkt, const Address &dest, uint16_t protocolNumber);
+ virtual void SetForwardUpCb (Callback<void, Ptr<Packet>, const UanAddress&> cb);
+ virtual void AttachPhy (Ptr<UanPhy> phy);
+ virtual Address GetBroadcast (void) const;
+
+ // PHY listeners
+ virtual void NotifyRxStart (void);
+ virtual void NotifyRxEndOk (void);
+ virtual void NotifyRxEndError (void);
+ virtual void NotifyCcaStart (void);
+ virtual void NotifyCcaEnd (void);
+ virtual void NotifyTxStart (Time duration);
+private:
+ typedef enum {
+ IDLE, CCABUSY, RUNNING, TX
+ } State;
+
+ Callback <void, Ptr<Packet>, const UanAddress& > m_forwardUpCb;
+ UanAddress m_address;
+ Ptr<UanPhy> m_phy;
+ TracedCallback<Ptr<const Packet>, UanTxMode > m_rxLogger;
+ TracedCallback<Ptr<const Packet>, uint16_t > m_enqueueLogger;
+ TracedCallback<Ptr<const Packet>, uint16_t > m_dequeueLogger;
+
+ // Mac parameters
+ uint32_t m_cw;
+ Time m_slotTime;
+
+ // State variables
+ Time m_sendTime;
+ Time m_savedDelayS;
+ Ptr<Packet> m_pktTx;
+ uint16_t m_pktTxProt;
+ EventId m_sendEvent;
+ EventId m_txEndEvent;
+ State m_state;
+
+ void PhyRxPacketGood (Ptr<Packet> packet, double sinr, UanTxMode mode);
+ void PhyRxPacketError (Ptr<Packet> packet, double sinr);
+ void SaveTimer (void);
+ void StartTimer (void);
+ void SendPacket (void);
+ void EndTx (void);
+protected:
+ virtual void DoDispose ();
+};
+
+}
+
+#endif // UANMACCW_H

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b