UWBIRMac.h

00001 /* -*- mode:c++ -*- ********************************************************
00002  * file:        UWBIRMac.h
00003  *
00004  * author:      Jerome Rousselot <jerome.rousselot@csem.ch>
00005  *
00006  * copyright:   (C) 2008-2009 Centre Suisse d'Electronique et Microtechnique (CSEM) SA
00007  *        Systems Engineering
00008  *              Real-Time Software and Networking
00009  *              Jaquet-Droz 1, CH-2002 Neuchatel, Switzerland.
00010  *
00011  *              This program is free software; you can redistribute it
00012  *              and/or modify it under the terms of the GNU General Public
00013  *              License as published by the Free Software Foundation; either
00014  *              version 2 of the License, or (at your option) any later
00015  *              version.
00016  *              For further information see file COPYING
00017  *              in the top level directory
00018  * description: All MAC designed for use with UWB-IR should derive from this
00019  *        class. It provides the necessary functions to build UWBIR
00020  *        packets and to receive them.
00021  ***************************************************************************/
00022 //
00023 // See the following publications for more information:
00024 // [1] An Ultra Wideband Impulse Radio PHY Layer Model for Network Simulation,
00025 // J. Rousselot, J.-D. Decotignie, Simulation: Transactions of the Society
00026 // for Computer Simulation, 2010 (submitted).
00027 // [2] A High-Precision Ultra Wideband Impulse Radio Physical Layer Model
00028 // for Network Simulation, Jérôme Rousselot, Jean-Dominique Decotignie,
00029 // Second International Omnet++ Workshop,Simu'TOOLS, Rome, 6 Mar 09.
00030 // http://portal.acm.org/citation.cfm?id=1537714
00031 //
00032 
00033 #ifndef UWBIRMAC_H
00034 #define UWBIRMAC_H
00035 
00036 #include "BaseMacLayer.h"
00037 #include "Decider.h"
00038 #include "MacToPhyControlInfo.h"
00039 #include "PhyToMacControlInfo.h"
00040 #include "Signal_.h"
00041 #include "MacToPhyInterface.h"
00042 #include "UWBIRMacPkt_m.h"
00043 #include "IEEE802154A.h"
00044 #include "RadioUWBIR.h"
00045 #include "DeciderResultUWBIR.h"
00046 #include "Packet.h"
00047 #include "UWBIRMacPkt.h"
00048 #include <vector>
00049 #include <utility>
00050 
00051 using namespace std;
00052 
00053 
00064 class UWBIRMac : public BaseMacLayer {
00065 
00066 public:
00067 
00068     virtual void initialize(int stage);
00069 
00070     virtual void finish();
00071 
00072     UWBIRMac(): packet(100) { }
00073 
00074 protected:
00075     bool debug;
00076     bool stats;
00077     bool trace;
00078     bool rsDecoder;
00079     bool packetsAlwaysValid;
00080     double totalRxBits, errRxBits; // double and not long as we divide one by the other to get the BER
00081     MacToPhyInterface* phy;
00082     Packet packet;
00083     int catPacket;
00084     int prf; // pulse repetition frequency
00085     cOutVector packetsBER;
00086     cOutVector dataLengths;
00087     cOutVector erroneousSymbols;
00088     cOutVector sentPulses;
00089     cOutVector receivedPulses;
00090     cOutVector meanPacketBER;
00091     cOutVector packetSuccessRate;
00092     cOutVector packetSuccessRateNoRS;
00093     cOutVector ber;
00094     cStdDev meanBER;
00095     cOutVector RSErrorRate;
00096     cOutVector success, successNoRS;
00097 
00098     long nbReceivedPacketsNoRS, nbReceivedPacketsRS;
00099     long nbSentPackets;
00100     long nbSymbolErrors, nbSymbolsReceived;
00101     long nbHandledRxPackets;
00102     long nbFramesDropped;
00103 
00104     // warning: cfg value is currently ignored
00105     void prepareData(UWBIRMacPkt* packet, IEEE802154A::config cfg = IEEE802154A::cfg_mandatory_4M);
00106 
00107     void handleLowerMsg(cPacket *msg);
00108 
00109     bool validatePacket(UWBIRMacPkt * mac);
00110 
00111     void initCounters();
00112 
00113 };
00114 
00115 #endif // UWBIRMAC_H
00116