src/uan/model/uan-mac-rc.h
author Vedran Miletić <rivanvx@gmail.com>
Tue, 02 Aug 2011 17:42:33 -0400
changeset 7385 10beb0e53130
parent 7353 09fccf6195ea
child 8980 0202e0b04282
permissions -rw-r--r--
standardize emacs c++ mode comments
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7385
10beb0e53130 standardize emacs c++ mode comments
Vedran Miletić <rivanvx@gmail.com>
parents: 7353
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
6478
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
     2
/*
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
     3
 * Copyright (c) 2009 University of Washington
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
     4
 *
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
     7
 * published by the Free Software Foundation;
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
     8
 *
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    12
 * GNU General Public License for more details.
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    13
 *
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    17
 *
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    18
 * Author: Leonard Tracy <lentracy@gmail.com>
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    19
 */
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    20
7353
09fccf6195ea bug 1203: Inconsistently named ifndef/define macros in ns-3 headers
Vedran Miletic <rivanvx@gmail.com>
parents: 6852
diff changeset
    21
#ifndef UAN_MAC_RC_H
09fccf6195ea bug 1203: Inconsistently named ifndef/define macros in ns-3 headers
Vedran Miletic <rivanvx@gmail.com>
parents: 6852
diff changeset
    22
#define UAN_MAC_RC_H
6478
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    23
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    24
#include "uan-mac.h"
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    25
#include "uan-address.h"
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    26
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    27
#include "ns3/nstime.h"
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    28
#include "ns3/trace-source-accessor.h"
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    29
#include "ns3/traced-callback.h"
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    30
#include "ns3/event-id.h"
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    31
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    32
#include <list>
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    33
#include <utility>
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    34
#include <vector>
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    35
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    36
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    37
namespace ns3 {
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    38
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    39
class Address;
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    40
class UanTxMode;
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    41
class UanHeaderRcRts;
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    42
class UanHeaderRcCts;
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    43
class UanHeaderRcCtsGlobal;
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    44
class UanPhy;
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    45
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    46
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    47
/**
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    48
 * \class Reservation
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    49
 * \brief Stores reservation info for use in scheduling data channel by reservation channel MAC
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    50
 */
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    51
class Reservation
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    52
{
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    53
public:
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    54
  /**
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    55
   * \brief Create empty object with default values
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    56
   */
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    57
  Reservation ();
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    58
  /**
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    59
   * \brief Create Reservation object with given packet list, frame number and max packets
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    60
   * \param list List of packets for assigned to reservation
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    61
   * \param frameNo Frame number of reservation transmission
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    62
   * \param maxPkts Maximum number of packets to assign to reservation from packet list (0 = no maximum)
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    63
   */
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    64
  Reservation (std::list<std::pair <Ptr<Packet>, UanAddress > > &list, uint8_t frameNo, uint32_t maxPkts = 0);
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    65
  ~Reservation ();
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    66
  /**
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    67
   * \returns number of frames in reservation
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    68
   */
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    69
  uint32_t GetNoFrames () const;
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    70
  /**
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    71
   * \returns total byte length of reservation (sum of all packets with headers)
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    72
   */
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    73
  uint32_t GetLength () const;
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    74
  /**
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    75
   * \returns reference to list of packets in this reservation
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    76
   */
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    77
  const std::list<std::pair <Ptr<Packet>, UanAddress > > &GetPktList (void) const;
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    78
  /**
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    79
   * \returns Frame number of reservation
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    80
   */
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    81
  uint8_t GetFrameNo () const;
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    82
  /**
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    83
   * \returns Retry number of reservation
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    84
   */
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    85
  uint8_t GetRetryNo () const;
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    86
  /**
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    87
   * \returns Timestamp nth RTS send for this reservation
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    88
   * \param n Timestamp for retry number n to return
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    89
   */
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    90
  Time GetTimestamp (uint8_t n) const;
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    91
  /**
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    92
   * \returns True if reservation packets have been transmitted
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    93
   */
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    94
  bool IsTransmitted () const;
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    95
  /**
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    96
   * \param fn Frame number to set reservation to
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    97
   */
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    98
  void SetFrameNo (uint8_t fn);
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    99
  /**
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   100
   * \param t Time of latest RTS send
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   101
   */
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   102
  void AddTimestamp (Time t);
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   103
  /**
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   104
   * \brief Increments retry count by 1
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   105
   */
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   106
  void IncrementRetry ();
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   107
  /**
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   108
   * \param t True if resevation has been transmitted
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   109
   * \brief Sets reservation transmitted state
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   110
   */
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   111
  void SetTransmitted (bool t = true);
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   112
private:
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   113
  std::list<std::pair <Ptr<Packet>, UanAddress > > m_pktList;
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   114
  uint32_t m_length;
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   115
  uint8_t m_frameNo;
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   116
  std::vector<Time> m_timestamp;
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   117
  uint8_t m_retryNo;
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   118
  bool m_transmitted;
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   119
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   120
};
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   121
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   122
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   123
/**
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   124
 * \class UanMacRc
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   125
 * \brief Non-gateway node MAC for reservation channel MAC protocol
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   126
 *
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   127
 * This MAC protocol assumes a network topology where all traffic
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   128
 * is destined for a set of GW nodes which are connected via
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   129
 * some out of band (RF?) means.  This particular implementation
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   130
 * assumes that there is only a single gateway.
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   131
 *
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   132
 * For more information on class operation email
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   133
 * lentracy@u.washington.edu
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   134
 * (This work is, as of yet, unpublished)
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   135
 */
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   136
class UanMacRc : public UanMac
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   137
{
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   138
public:
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   139
  enum {
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   140
    TYPE_DATA, TYPE_GWPING, TYPE_RTS, TYPE_CTS, TYPE_ACK
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   141
  };
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   142
  UanMacRc ();
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   143
  virtual ~UanMacRc ();
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   144
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   145
  static TypeId GetTypeId (void);
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   146
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   147
  // Inherited virtual functions
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   148
  virtual Address GetAddress (void);
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   149
  virtual void SetAddress (UanAddress addr);
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   150
  virtual bool Enqueue (Ptr<Packet> pkt, const Address &dest, uint16_t protocolNumber);
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   151
  virtual void SetForwardUpCb (Callback<void, Ptr<Packet>, const UanAddress&> cb);
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   152
  virtual void AttachPhy (Ptr<UanPhy> phy);
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   153
  virtual Address GetBroadcast (void) const;
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   154
  virtual void Clear (void);
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   155
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   156
private:
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   157
  enum State {
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   158
    UNASSOCIATED, GWPSENT, IDLE, RTSSENT, DATATX
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   159
  };
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   160
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   161
  State m_state;
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   162
  bool m_rtsBlocked;
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   163
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   164
  EventId m_startAgain;
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   165
  UanAddress m_address;
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   166
  double m_retryRate;
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   167
  UanAddress m_assocAddr;
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   168
  Ptr<UanPhy> m_phy;
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   169
  uint32_t m_numRates;
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   170
  uint32_t m_currentRate;
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   171
  uint32_t m_maxFrames;
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   172
  uint32_t m_queueLimit;
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   173
  uint8_t m_frameNo;
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   174
  Time m_sifs;
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   175
  Time m_learnedProp;
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   176
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   177
  uint16_t m_numRetryRates;
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   178
  double m_minRetryRate;
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   179
  double m_retryStep;
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   180
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   181
  uint32_t m_ctsSizeN;
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   182
  uint32_t m_ctsSizeG;
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   183
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   184
  bool m_cleared;
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   185
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   186
  std::list<std::pair <Ptr<Packet>, UanAddress > > m_pktQueue;
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   187
  std::list<Reservation> m_resList;
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   188
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   189
  Callback<void, Ptr<Packet>, const UanAddress& > m_forwardUpCb;
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   190
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   191
  TracedCallback<Ptr<const Packet>, UanTxMode > m_rxLogger;
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   192
  TracedCallback<Ptr<const Packet>, uint16_t > m_enqueueLogger;
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   193
  TracedCallback<Ptr<const Packet>, uint16_t > m_dequeueLogger;
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   194
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   195
  EventId m_rtsEvent;
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   196
  void ReceiveOkFromPhy (Ptr<Packet>, double sinr, UanTxMode mode);
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   197
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   198
  void Associate (void);
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   199
  void AssociateTimeout (void);
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   200
  void SendRts (void);
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   201
  void RtsTimeout (void);
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   202
  UanHeaderRcRts CreateRtsHeader (const Reservation &res);
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   203
  void ScheduleData (const UanHeaderRcCts &ctsh, const UanHeaderRcCtsGlobal &ctsg, uint32_t ctsBytes);
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   204
  void ProcessAck (Ptr<Packet> ack);
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   205
  void SendPacket (Ptr<Packet> pkt, uint32_t rate);
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   206
  bool IsPhy1Ok (void);
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   207
  void BlockRtsing (void);
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   208
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   209
  static uint32_t m_cntrlSends;
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   210
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   211
protected:
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   212
  void DoDispose ();
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   213
};
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   214
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   215
}
b401db8531f5 Bug 970 - move UAN over to new directory structure
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   216
7353
09fccf6195ea bug 1203: Inconsistently named ifndef/define macros in ns-3 headers
Vedran Miletic <rivanvx@gmail.com>
parents: 6852
diff changeset
   217
#endif /* UAN_MAC_RC_H */