View | Details | Raw Unified | Return to bug 2413
Collapse All | Expand All

(-)a/src/internet/helper/ipv6-address-helper.cc (+7 lines)
 Lines 86-91   Ipv6Address Ipv6AddressHelper::NewAddress (Address addr) Link Here 
86
      Ipv6AddressGenerator::AddAllocated (address);
86
      Ipv6AddressGenerator::AddAllocated (address);
87
      return address;
87
      return address;
88
    }
88
    }
89
  else if (UanAddress::IsMatchingType (addr))
90
    {
91
      Ipv6Address network = Ipv6AddressGenerator::GetNetwork (Ipv6Prefix (64));
92
      Ipv6Address address = Ipv6Address::MakeAutoconfiguredAddress (UanAddress::ConvertFrom (addr), network);
93
      Ipv6AddressGenerator::AddAllocated (address);
94
      return address;
95
    }
89
  else
96
  else
90
    {
97
    {
91
      NS_FATAL_ERROR ("Did not pass in a valid Mac Address (16, 48 or 64 bits)");
98
      NS_FATAL_ERROR ("Did not pass in a valid Mac Address (16, 48 or 64 bits)");
(-)a/src/internet/model/arp-header.cc (-1 / +1 lines)
 Lines 136-142   uint32_t Link Here 
136
ArpHeader::GetSerializedSize (void) const
136
ArpHeader::GetSerializedSize (void) const
137
{
137
{
138
  NS_LOG_FUNCTION (this);
138
  NS_LOG_FUNCTION (this);
139
  NS_ASSERT((m_macSource.GetLength () == 6) || (m_macSource.GetLength () == 8));
139
  NS_ASSERT((m_macSource.GetLength () == 6) || (m_macSource.GetLength () == 8) || (m_macSource.GetLength () == 1));
140
  NS_ASSERT (m_macSource.GetLength () == m_macDest.GetLength ());
140
  NS_ASSERT (m_macSource.GetLength () == m_macDest.GetLength ());
141
141
142
  uint32_t length = 16;   // Length minus two hardware addresses
142
  uint32_t length = 16;   // Length minus two hardware addresses
(-)a/src/internet/model/ipv6-interface.cc (+6 lines)
 Lines 113-118   void Ipv6Interface::DoSetup () Link Here 
113
          AddAddress (ifaddr);
113
          AddAddress (ifaddr);
114
          m_linkLocalAddress = ifaddr;
114
          m_linkLocalAddress = ifaddr;
115
        }
115
        }
116
      else if (UanAddress::IsMatchingType (addr))
117
      {
118
          Ipv6InterfaceAddress ifaddr = Ipv6InterfaceAddress (Ipv6Address::MakeAutoconfiguredLinkLocalAddress (UanAddress::ConvertFrom (addr)), Ipv6Prefix (64));
119
          AddAddress (ifaddr);
120
          m_linkLocalAddress = ifaddr;
121
      }
116
      else
122
      else
117
        {
123
        {
118
          NS_FATAL_ERROR ("IPv6 autoconf for this kind of address not implemented.");
124
          NS_FATAL_ERROR ("IPv6 autoconf for this kind of address not implemented.");
(-)a/src/network/utils/ipv6-address.cc (+40 lines)
 Lines 415-420   Ipv6Address Ipv6Address::MakeAutoconfiguredAddress (Mac64Address addr, Ipv6Addre Link Here 
415
  return ret;
415
  return ret;
416
}
416
}
417
417
418
Ipv6Address Ipv6Address::MakeAutoconfiguredAddress (UanAddress addr, Ipv6Address prefix)
419
{
420
  NS_LOG_FUNCTION (addr << prefix);
421
  Ipv6Address ret;
422
  uint8_t buf[2];
423
  uint8_t buf2[16];
424
425
  buf[0] = 0;
426
  buf[1] = addr.GetAsInt();
427
  prefix.GetBytes (buf2);
428
429
  memcpy (buf2 + 14, buf, 2);
430
  buf2[11] = 0xff;
431
  buf2[12] = 0xfe;
432
433
  ret.Set (buf2);
434
  return ret;
435
}
436
418
Ipv6Address Ipv6Address::MakeAutoconfiguredLinkLocalAddress (Mac16Address addr)
437
Ipv6Address Ipv6Address::MakeAutoconfiguredLinkLocalAddress (Mac16Address addr)
419
{
438
{
420
  NS_LOG_FUNCTION (addr);
439
  NS_LOG_FUNCTION (addr);
 Lines 475-480   Ipv6Address Ipv6Address::MakeAutoconfiguredLinkLocalAddress (Mac64Address addr) Link Here 
475
  return ret;
494
  return ret;
476
}
495
}
477
496
497
Ipv6Address Ipv6Address::MakeAutoconfiguredLinkLocalAddress (UanAddress addr)
498
{
499
  NS_LOG_FUNCTION (addr);
500
  Ipv6Address ret;
501
  uint8_t buf[2];
502
  uint8_t buf2[16];
503
504
  buf[0] = 0;
505
  buf[1] = addr.GetAsInt();
506
507
  memset (buf2, 0x00, sizeof (buf2));
508
  buf2[0] = 0xfe;
509
  buf2[1] = 0x80;
510
  memcpy (buf2 + 14, buf, 2);
511
  buf2[11] = 0xff;
512
  buf2[12] = 0xfe;
513
514
  ret.Set (buf2);
515
  return ret;
516
}
517
478
Ipv6Address Ipv6Address::MakeSolicitedAddress (Ipv6Address addr)
518
Ipv6Address Ipv6Address::MakeSolicitedAddress (Ipv6Address addr)
479
{
519
{
480
  NS_LOG_FUNCTION (addr);
520
  NS_LOG_FUNCTION (addr);
(-)a/src/network/utils/ipv6-address.h (+16 lines)
 Lines 30-35    Link Here 
30
#include "ns3/address.h"
30
#include "ns3/address.h"
31
#include "ns3/ipv4-address.h"
31
#include "ns3/ipv4-address.h"
32
#include "ns3/deprecated.h"
32
#include "ns3/deprecated.h"
33
#include "uan-address.h"
33
34
34
namespace ns3 { 
35
namespace ns3 { 
35
36
 Lines 163-168   public: Link Here 
163
   */
164
   */
164
  static Ipv6Address MakeAutoconfiguredAddress (Mac64Address addr, Ipv6Address prefix);
165
  static Ipv6Address MakeAutoconfiguredAddress (Mac64Address addr, Ipv6Address prefix);
165
166
167
  /**
168
   * \brief Make the autoconfigured IPv6 address with UanAddress.
169
   * \param addr the UAN address (8 bits).
170
   * \param prefix the IPv6 prefix
171
   * \return autoconfigured IPv6 address
172
   */
173
  static Ipv6Address MakeAutoconfiguredAddress (UanAddress addr, Ipv6Address prefix);
174
166
  /**
175
  /**
167
   * \brief Make the autoconfigured link-local IPv6 address with Mac16Address.
176
   * \brief Make the autoconfigured link-local IPv6 address with Mac16Address.
168
   * \param mac the MAC address (16 bits).
177
   * \param mac the MAC address (16 bits).
 Lines 184-189   public: Link Here 
184
   */
193
   */
185
  static Ipv6Address MakeAutoconfiguredLinkLocalAddress (Mac64Address mac);
194
  static Ipv6Address MakeAutoconfiguredLinkLocalAddress (Mac64Address mac);
186
195
196
   /**
197
    * \brief Make the autoconfigured link-local IPv6 address with UanAddress.
198
    * \param mac the MAC address (8 bits).
199
    * \return autoconfigured link-local IPv6 address
200
    */
201
  static Ipv6Address MakeAutoconfiguredLinkLocalAddress (UanAddress mac);
202
187
  /**
203
  /**
188
   * \brief Print this address to the given output stream.
204
   * \brief Print this address to the given output stream.
189
   *
205
   *
(-)a/src/network/wscript (+2 lines)
 Lines 62-67   def build(bld): Link Here 
62
        'utils/packet-socket-server.cc',
62
        'utils/packet-socket-server.cc',
63
        'utils/packet-data-calculators.cc',
63
        'utils/packet-data-calculators.cc',
64
        'utils/packet-probe.cc',
64
        'utils/packet-probe.cc',
65
        'utils/uan-address.cc',
65
        'helper/application-container.cc',
66
        'helper/application-container.cc',
66
        'helper/net-device-container.cc',
67
        'helper/net-device-container.cc',
67
        'helper/node-container.cc',
68
        'helper/node-container.cc',
 Lines 152-157   def build(bld): Link Here 
152
        'utils/pcap-test.h',
153
        'utils/pcap-test.h',
153
        'utils/packet-data-calculators.h',
154
        'utils/packet-data-calculators.h',
154
        'utils/packet-probe.h',
155
        'utils/packet-probe.h',
156
        'utils/uan-address.h',
155
        'helper/application-container.h',
157
        'helper/application-container.h',
156
        'helper/net-device-container.h',
158
        'helper/net-device-container.h',
157
        'helper/node-container.h',
159
        'helper/node-container.h',
(-)a/src/sixlowpan/model/sixlowpan-net-device.cc (+4 lines)
 Lines 2099-2104   Ipv6Address SixLowPanNetDevice::MakeLinkLocalAddressFromMac (Address const &addr Link Here 
2099
        {
2099
        {
2100
          ipv6Addr = Ipv6Address::MakeAutoconfiguredLinkLocalAddress (Mac16Address::ConvertFrom (addr));
2100
          ipv6Addr = Ipv6Address::MakeAutoconfiguredLinkLocalAddress (Mac16Address::ConvertFrom (addr));
2101
        }
2101
        }
2102
      else if (UanAddress::IsMatchingType (addr))
2103
        {
2104
          ipv6Addr = Ipv6Address::MakeAutoconfiguredLinkLocalAddress (UanAddress::ConvertFrom (addr));
2105
        }
2102
    }
2106
    }
2103
  if (ipv6Addr.IsAny ())
2107
  if (ipv6Addr.IsAny ())
2104
    {
2108
    {
(-)a/src/uan/model/uan-header-common.cc (-10 / +42 lines)
 Lines 19-25    Link Here 
19
 */
19
 */
20
20
21
#include "uan-header-common.h"
21
#include "uan-header-common.h"
22
#include "uan-address.h"
22
#include "ns3/uan-address.h"
23
#include "ns3/arp-l3-protocol.h"
24
#include "ns3/ipv6-l3-protocol.h"
25
#include "ns3/ipv4-l3-protocol.h"
23
26
24
namespace ns3 {
27
namespace ns3 {
25
28
 Lines 29-41   UanHeaderCommon::UanHeaderCommon () Link Here 
29
{
32
{
30
}
33
}
31
34
32
UanHeaderCommon::UanHeaderCommon (const UanAddress src, const UanAddress dest, uint8_t type)
35
UanHeaderCommon::UanHeaderCommon (const UanAddress src, const UanAddress dest, uint8_t type, uint8_t protocolNumber)
33
  : Header (),
36
  : Header (),
34
    m_dest (dest),
37
    m_dest (dest),
35
    m_src (src),
38
    m_src (src)
36
    m_type (type)
37
{
39
{
38
40
  m_uanProtocolBits.m_protocolNumber = protocolNumber;
41
  m_uanProtocolBits.m_type = type;
39
}
42
}
40
43
41
TypeId
44
TypeId
 Lines 73-79   UanHeaderCommon::SetSrc (UanAddress src) Link Here 
73
void
76
void
74
UanHeaderCommon::SetType (uint8_t type)
77
UanHeaderCommon::SetType (uint8_t type)
75
{
78
{
76
  m_type = type;
79
  m_uanProtocolBits.m_type = type;
80
}
81
82
void
83
UanHeaderCommon::SetProtocolNumber (uint16_t protocolNumber)
84
{
85
  NS_ASSERT_MSG(protocolNumber > 3 || protocolNumber <= 0, "UanHeaderCommon::SetProtocolNumber(): Protocol not supported");
86
  if(protocolNumber == Ipv4L3Protocol::PROT_NUMBER)
87
    m_uanProtocolBits.m_protocolNumber = 1;
88
  if(protocolNumber == ArpL3Protocol::PROT_NUMBER)
89
    m_uanProtocolBits.m_protocolNumber = 2;
90
  if(protocolNumber == Ipv6L3Protocol::PROT_NUMBER)
91
    m_uanProtocolBits.m_protocolNumber = 3;
77
}
92
}
78
93
79
UanAddress
94
UanAddress
 Lines 89-95   UanHeaderCommon::GetSrc (void) const Link Here 
89
uint8_t
104
uint8_t
90
UanHeaderCommon::GetType (void) const
105
UanHeaderCommon::GetType (void) const
91
{
106
{
92
  return m_type;
107
  return m_uanProtocolBits.m_type;
108
}
109
110
uint16_t
111
UanHeaderCommon::GetProtocolNumber (void) const
112
{
113
  if(m_uanProtocolBits.m_protocolNumber == 1)
114
    return Ipv4L3Protocol::PROT_NUMBER;
115
  if(m_uanProtocolBits.m_protocolNumber == 2)
116
    return ArpL3Protocol::PROT_NUMBER;
117
  if(m_uanProtocolBits.m_protocolNumber == 3)
118
    return Ipv6L3Protocol::PROT_NUMBER;
119
  return 0;
93
}
120
}
94
121
95
// Inherrited methods
122
// Inherrited methods
 Lines 105-111   UanHeaderCommon::Serialize (Buffer::Iterator start) const Link Here 
105
{
132
{
106
  start.WriteU8 (m_src.GetAsInt ());
133
  start.WriteU8 (m_src.GetAsInt ());
107
  start.WriteU8 (m_dest.GetAsInt ());
134
  start.WriteU8 (m_dest.GetAsInt ());
108
  start.WriteU8 (m_type);
135
  char tmp = m_uanProtocolBits.m_type;
136
  tmp = tmp << 4;
137
  tmp += m_uanProtocolBits.m_protocolNumber;
138
  start.WriteU8 (tmp);
109
}
139
}
110
140
111
uint32_t
141
uint32_t
 Lines 115-121   UanHeaderCommon::Deserialize (Buffer::Iterator start) Link Here 
115
145
116
  m_src = UanAddress (rbuf.ReadU8 ());
146
  m_src = UanAddress (rbuf.ReadU8 ());
117
  m_dest = UanAddress (rbuf.ReadU8 ());
147
  m_dest = UanAddress (rbuf.ReadU8 ());
118
  m_type = rbuf.ReadU8 ();
148
  char tmp = rbuf.ReadU8 ();
149
  m_uanProtocolBits.m_type = tmp >> 4;
150
  m_uanProtocolBits.m_protocolNumber = tmp;
119
151
120
  return rbuf.GetDistanceFrom (start);
152
  return rbuf.GetDistanceFrom (start);
121
}
153
}
 Lines 123-129   UanHeaderCommon::Deserialize (Buffer::Iterator start) Link Here 
123
void
155
void
124
UanHeaderCommon::Print (std::ostream &os) const
156
UanHeaderCommon::Print (std::ostream &os) const
125
{
157
{
126
  os << "UAN src=" << m_src << " dest=" << m_dest << " type=" << (uint32_t) m_type;
158
  os << "UAN src=" << m_src << " dest=" << m_dest << " type=" << (uint32_t) m_uanProtocolBits.m_type << "Protocol Number=" << (uint32_t) m_uanProtocolBits.m_protocolNumber;
127
}
159
}
128
160
129
161
(-)a/src/uan/model/uan-header-common.h (-4 / +23 lines)
 Lines 24-33    Link Here 
24
#include "ns3/header.h"
24
#include "ns3/header.h"
25
#include "ns3/nstime.h"
25
#include "ns3/nstime.h"
26
#include "ns3/simulator.h"
26
#include "ns3/simulator.h"
27
#include "uan-address.h"
27
#include "ns3/uan-address.h"
28
28
29
namespace ns3 {
29
namespace ns3 {
30
30
31
  struct UanProtocolBits
32
  {
33
    uint8_t  m_type : 4;
34
    uint8_t  m_protocolNumber : 4;
35
  };
36
31
/**
37
/**
32
 * \ingroup uan
38
 * \ingroup uan
33
 *
39
 *
 Lines 50-57   public: Link Here 
50
   * \param src Source address defined in header.
56
   * \param src Source address defined in header.
51
   * \param dest Destination address defined in header.
57
   * \param dest Destination address defined in header.
52
   * \param type Header type.
58
   * \param type Header type.
59
   * \param protocolNumber the layer 3 protocol number
53
   */
60
   */
54
  UanHeaderCommon (const UanAddress src, const UanAddress dest, uint8_t type);
61
  UanHeaderCommon (const UanAddress src, const UanAddress dest, uint8_t type, uint8_t protocolNumber);
55
  /** Destructor */
62
  /** Destructor */
56
  virtual ~UanHeaderCommon ();
63
  virtual ~UanHeaderCommon ();
57
64
 Lines 80-85   public: Link Here 
80
   * \param type The type value.
87
   * \param type The type value.
81
   */
88
   */
82
  void SetType (uint8_t type);
89
  void SetType (uint8_t type);
90
  /**
91
   * Set the packet type.
92
   *
93
   * Used to indicate the layer 3 protocol
94
   * \param protocolNumber The layer 3 protocol number value.
95
   */
96
  void SetProtocolNumber (uint16_t protocolNumber);
83
97
84
  /**
98
  /**
85
   * Get the destination address.
99
   * Get the destination address.
 Lines 99-105   public: Link Here 
99
   * \return value of type field.
113
   * \return value of type field.
100
   */
114
   */
101
  uint8_t GetType (void) const;
115
  uint8_t GetType (void) const;
102
116
  /**
117
   * Get the packet type value.
118
   *
119
   * \return value of protocolNumber field.
120
   */
121
  uint16_t GetProtocolNumber (void) const;
103
122
104
  // Inherited methods
123
  // Inherited methods
105
  virtual uint32_t GetSerializedSize (void) const;
124
  virtual uint32_t GetSerializedSize (void) const;
 Lines 110-116   public: Link Here 
110
private:
129
private:
111
  UanAddress m_dest;  //!< The destination address.
130
  UanAddress m_dest;  //!< The destination address.
112
  UanAddress m_src;   //!< The source address.
131
  UanAddress m_src;   //!< The source address.
113
  uint8_t m_type;     //!< The type field.
132
  UanProtocolBits m_uanProtocolBits;  //!< The type and protocol bits
114
133
115
};  // class UanHeaderCommon
134
};  // class UanHeaderCommon
116
135
(-)a/src/uan/model/uan-mac-aloha.cc (-23 / +6 lines)
 Lines 20-26    Link Here 
20
20
21
#include "uan-mac-aloha.h"
21
#include "uan-mac-aloha.h"
22
#include "uan-tx-mode.h"
22
#include "uan-tx-mode.h"
23
#include "uan-address.h"
23
#include "ns3/uan-address.h"
24
#include "ns3/log.h"
24
#include "ns3/log.h"
25
#include "uan-phy.h"
25
#include "uan-phy.h"
26
#include "uan-header-common.h"
26
#include "uan-header-common.h"
 Lines 77-95   UanMacAloha::GetTypeId (void) Link Here 
77
  return tid;
77
  return tid;
78
}
78
}
79
79
80
Address
81
UanMacAloha::GetAddress (void)
82
{
83
  return m_address;
84
}
85
86
void
87
UanMacAloha::SetAddress (UanAddress addr)
88
{
89
  m_address=addr;
90
}
91
bool
80
bool
92
UanMacAloha::Enqueue (Ptr<Packet> packet, const Address &dest, uint16_t protocolNumber)
81
UanMacAloha::Enqueue (Ptr<Packet> packet, uint16_t protocolNumber, const Address &dest)
93
{
82
{
94
  NS_LOG_DEBUG ("" << Simulator::Now ().GetSeconds () << " MAC " << UanAddress::ConvertFrom (GetAddress ()) << " Queueing packet for " << UanAddress::ConvertFrom (dest));
83
  NS_LOG_DEBUG ("" << Simulator::Now ().GetSeconds () << " MAC " << UanAddress::ConvertFrom (GetAddress ()) << " Queueing packet for " << UanAddress::ConvertFrom (dest));
95
84
 Lines 102-110   UanMacAloha::Enqueue (Ptr<Packet> packet, const Address &dest, uint16_t protocol Link Here 
102
      header.SetSrc (src);
91
      header.SetSrc (src);
103
      header.SetDest (udest);
92
      header.SetDest (udest);
104
      header.SetType (0);
93
      header.SetType (0);
94
      header.SetProtocolNumber (protocolNumber);
105
95
106
      packet->AddHeader (header);
96
      packet->AddHeader (header);
107
      m_phy->SendPacket (packet, protocolNumber);
97
      m_phy->SendPacket (packet, GetTxModeIndex ());
108
      return true;
98
      return true;
109
    }
99
    }
110
  else
100
  else
 Lines 112-118   UanMacAloha::Enqueue (Ptr<Packet> packet, const Address &dest, uint16_t protocol Link Here 
112
}
102
}
113
103
114
void
104
void
115
UanMacAloha::SetForwardUpCb (Callback<void, Ptr<Packet>, const UanAddress& > cb)
105
UanMacAloha::SetForwardUpCb (Callback<void, Ptr<Packet>, uint16_t, const UanAddress&> cb)
116
{
106
{
117
  m_forUpCb = cb;
107
  m_forUpCb = cb;
118
}
108
}
 Lines 133-139   UanMacAloha::RxPacketGood (Ptr<Packet> pkt, double sinr, UanTxMode txMode) Link Here 
133
123
134
  if (header.GetDest () == GetAddress () || header.GetDest () == UanAddress::GetBroadcast ())
124
  if (header.GetDest () == GetAddress () || header.GetDest () == UanAddress::GetBroadcast ())
135
    {
125
    {
136
      m_forUpCb (pkt, header.GetSrc ());
126
      m_forUpCb (pkt, header.GetProtocolNumber (), header.GetSrc ());
137
    }
127
    }
138
128
139
}
129
}
 Lines 144-156   UanMacAloha::RxPacketError (Ptr<Packet> pkt, double sinr) Link Here 
144
  NS_LOG_DEBUG ("" << Simulator::Now () << " MAC " << UanAddress::ConvertFrom (GetAddress ()) << " Received packet in error with sinr " << sinr);
134
  NS_LOG_DEBUG ("" << Simulator::Now () << " MAC " << UanAddress::ConvertFrom (GetAddress ()) << " Received packet in error with sinr " << sinr);
145
}
135
}
146
136
147
Address
148
UanMacAloha::GetBroadcast (void) const
149
{
150
  UanAddress broadcast (255);
151
  return broadcast;
152
}
153
154
int64_t
137
int64_t
155
UanMacAloha::AssignStreams (int64_t stream)
138
UanMacAloha::AssignStreams (int64_t stream)
156
{
139
{
(-)a/src/uan/model/uan-mac-aloha.h (-7 / +4 lines)
 Lines 22-28    Link Here 
22
#define UAN_MAC_ALOHA_H
22
#define UAN_MAC_ALOHA_H
23
23
24
#include "uan-mac.h"
24
#include "uan-mac.h"
25
#include "uan-address.h"
25
#include "ns3/uan-address.h"
26
26
27
namespace ns3
27
namespace ns3
28
{
28
{
 Lines 55-66   public: Link Here 
55
55
56
56
57
  // Inherited methods
57
  // Inherited methods
58
  Address GetAddress (void);
58
  virtual bool Enqueue (Ptr<Packet> pkt, uint16_t protocolNumber, const Address &dest);
59
  virtual void SetAddress (UanAddress addr);
59
  virtual void SetForwardUpCb (Callback<void, Ptr<Packet>, uint16_t, const UanAddress&> cb);
60
  virtual bool Enqueue (Ptr<Packet> pkt, const Address &dest, uint16_t protocolNumber);
61
  virtual void SetForwardUpCb (Callback<void, Ptr<Packet>, const UanAddress& > cb);
62
  virtual void AttachPhy (Ptr<UanPhy> phy);
60
  virtual void AttachPhy (Ptr<UanPhy> phy);
63
  virtual Address GetBroadcast (void) const;
64
  virtual void Clear (void);
61
  virtual void Clear (void);
65
  int64_t AssignStreams (int64_t stream);
62
  int64_t AssignStreams (int64_t stream);
66
63
 Lines 70-76   private: Link Here 
70
  /** PHY layer attached to this MAC. */
67
  /** PHY layer attached to this MAC. */
71
  Ptr<UanPhy> m_phy;
68
  Ptr<UanPhy> m_phy;
72
  /** Forwarding up callback. */
69
  /** Forwarding up callback. */
73
  Callback<void, Ptr<Packet>, const UanAddress& > m_forUpCb;
70
  Callback<void, Ptr<Packet>, uint16_t, const UanAddress& > m_forUpCb;
74
  /** Flag when we've been cleared. */
71
  /** Flag when we've been cleared. */
75
  bool m_cleared;
72
  bool m_cleared;
76
73
(-)a/src/uan/model/uan-mac-cw.cc (-25 / +6 lines)
 Lines 107-126   UanMacCw::GetTypeId (void) Link Here 
107
  return tid;
107
  return tid;
108
}
108
}
109
109
110
Address
111
UanMacCw::GetAddress ()
112
{
113
  return this->m_address;
114
}
115
116
void
117
UanMacCw::SetAddress (UanAddress addr)
118
{
119
  m_address = addr;
120
}
121
122
bool
110
bool
123
UanMacCw::Enqueue (Ptr<Packet> packet, const Address &dest, uint16_t protocolNumber)
111
UanMacCw::Enqueue (Ptr<Packet> packet, uint16_t protocolNumber, const Address &dest)
124
{
112
{
125
113
126
  switch (m_state)
114
  switch (m_state)
 Lines 153-164   UanMacCw::Enqueue (Ptr<Packet> packet, const Address &dest, uint16_t protocolNum Link Here 
153
        header.SetType (0);
141
        header.SetType (0);
154
        packet->AddHeader (header);
142
        packet->AddHeader (header);
155
143
156
        m_enqueueLogger (packet, protocolNumber);
144
        m_enqueueLogger (packet, GetTxModeIndex ());
157
145
158
        if (m_phy->IsStateBusy ())
146
        if (m_phy->IsStateBusy ())
159
          {
147
          {
160
            m_pktTx = packet;
148
            m_pktTx = packet;
161
            m_pktTxProt = protocolNumber;
149
            m_pktTxProt = GetTxModeIndex ();
162
            m_state = CCABUSY;
150
            m_state = CCABUSY;
163
            uint32_t cw = (uint32_t) m_rv->GetValue (0,m_cw);
151
            uint32_t cw = (uint32_t) m_rv->GetValue (0,m_cw);
164
            m_savedDelayS = Seconds ((double)(cw) * m_slotTime.GetSeconds ());
152
            m_savedDelayS = Seconds ((double)(cw) * m_slotTime.GetSeconds ());
 Lines 172-178   UanMacCw::Enqueue (Ptr<Packet> packet, const Address &dest, uint16_t protocolNum Link Here 
172
            NS_LOG_DEBUG ("Time " << Simulator::Now ().GetSeconds () << ": Addr " << GetAddress () << ": Enqueuing new packet while idle (sending)");
160
            NS_LOG_DEBUG ("Time " << Simulator::Now ().GetSeconds () << ": Addr " << GetAddress () << ": Enqueuing new packet while idle (sending)");
173
            NS_ASSERT (m_phy->GetTransducer ()->GetArrivalList ().size () == 0 && !m_phy->IsStateTx ());
161
            NS_ASSERT (m_phy->GetTransducer ()->GetArrivalList ().size () == 0 && !m_phy->IsStateTx ());
174
            m_state = TX;
162
            m_state = TX;
175
            m_phy->SendPacket (packet,protocolNumber);
163
            m_phy->SendPacket (packet,GetTxModeIndex ());
176
164
177
          }
165
          }
178
        break;
166
        break;
 Lines 188-194   UanMacCw::Enqueue (Ptr<Packet> packet, const Address &dest, uint16_t protocolNum Link Here 
188
}
176
}
189
177
190
void
178
void
191
UanMacCw::SetForwardUpCb (Callback<void, Ptr<Packet>, const UanAddress&> cb)
179
UanMacCw::SetForwardUpCb (Callback<void, Ptr<Packet>, uint16_t, const UanAddress&> cb)
192
{
180
{
193
  m_forwardUpCb = cb;
181
  m_forwardUpCb = cb;
194
}
182
}
 Lines 202-214   UanMacCw::AttachPhy (Ptr<UanPhy> phy) Link Here 
202
  m_phy->RegisterListener (this);
190
  m_phy->RegisterListener (this);
203
}
191
}
204
192
205
Address
206
UanMacCw::GetBroadcast (void) const
207
{
208
  return UanAddress::GetBroadcast ();
209
}
210
211
212
void
193
void
213
UanMacCw::NotifyRxStart (void)
194
UanMacCw::NotifyRxStart (void)
214
{
195
{
 Lines 348-354   UanMacCw::PhyRxPacketGood (Ptr<Packet> packet, double sinr, UanTxMode mode) Link Here 
348
329
349
  if (header.GetDest () == m_address || header.GetDest () == UanAddress::GetBroadcast ())
330
  if (header.GetDest () == m_address || header.GetDest () == UanAddress::GetBroadcast ())
350
    {
331
    {
351
      m_forwardUpCb (packet, header.GetSrc ());
332
      m_forwardUpCb (packet, header.GetProtocolNumber (), header.GetSrc ());
352
    }
333
    }
353
}
334
}
354
void
335
void
(-)a/src/uan/model/uan-mac-cw.h (-6 / +3 lines)
 Lines 83-94   public: Link Here 
83
  virtual Time GetSlotTime (void);
83
  virtual Time GetSlotTime (void);
84
84
85
  // Inherited methods from UanMac
85
  // Inherited methods from UanMac
86
  virtual Address GetAddress ();
86
  virtual bool Enqueue (Ptr<Packet> pkt, uint16_t protocolNumber, const Address &dest);
87
  virtual void SetAddress (UanAddress addr);
87
  virtual void SetForwardUpCb (Callback<void, Ptr<Packet>, uint16_t, const UanAddress&> cb);
88
  virtual bool Enqueue (Ptr<Packet> pkt, const Address &dest, uint16_t protocolNumber);
89
  virtual void SetForwardUpCb (Callback<void, Ptr<Packet>, const UanAddress&> cb);
90
  virtual void AttachPhy (Ptr<UanPhy> phy);
88
  virtual void AttachPhy (Ptr<UanPhy> phy);
91
  virtual Address GetBroadcast (void) const;
92
  virtual void Clear (void);
89
  virtual void Clear (void);
93
  int64_t AssignStreams (int64_t stream);
90
  int64_t AssignStreams (int64_t stream);
94
91
 Lines 119-125   private: Link Here 
119
  } State;
116
  } State;
120
117
121
  /** Forwarding up callback. */
118
  /** Forwarding up callback. */
122
  Callback <void, Ptr<Packet>, const UanAddress& > m_forwardUpCb;
119
  Callback <void, Ptr<Packet>, uint16_t, const UanAddress&> m_forwardUpCb;
123
  /** The MAC address. */
120
  /** The MAC address. */
124
  UanAddress m_address;
121
  UanAddress m_address;
125
  /** PHY layer attached to this MAC. */
122
  /** PHY layer attached to this MAC. */
(-)a/src/uan/model/uan-mac-rc-gw.cc (-22 / +4 lines)
 Lines 170-196   UanMacRcGw::GetTypeId (void) Link Here 
170
  return tid;
170
  return tid;
171
}
171
}
172
172
173
Address
174
UanMacRcGw::GetAddress (void)
175
{
176
  return m_address;
177
}
178
179
void
180
UanMacRcGw::SetAddress (UanAddress addr)
181
{
182
  m_address = addr;
183
}
184
185
bool
173
bool
186
UanMacRcGw::Enqueue (Ptr<Packet> packet, const Address &dest, uint16_t protocolNumber)
174
UanMacRcGw::Enqueue (Ptr<Packet> packet, uint16_t protocolNumber, const Address &dest)
187
{
175
{
188
  NS_LOG_WARN ("RCMAC Gateway transmission to acoustic nodes is not yet implemented");
176
  NS_LOG_WARN ("RCMAC Gateway transmission to acoustic nodes is not yet implemented");
189
  return false;
177
  return false;
190
}
178
}
191
179
192
void
180
void
193
UanMacRcGw::SetForwardUpCb (Callback<void, Ptr<Packet>, const UanAddress&> cb)
181
UanMacRcGw::SetForwardUpCb (Callback<void, Ptr<Packet>, uint16_t, const UanAddress&> cb)
194
{
182
{
195
  m_forwardUpCb = cb;
183
  m_forwardUpCb = cb;
196
}
184
}
 Lines 208-219   UanMacRcGw::ReceiveError (Ptr<Packet> pkt, double sinr) Link Here 
208
{
196
{
209
}
197
}
210
198
211
Address
212
UanMacRcGw::GetBroadcast (void) const
213
{
214
  return UanAddress::GetBroadcast ();
215
}
216
217
void
199
void
218
UanMacRcGw::ReceivePacket (Ptr<Packet> pkt, double sinr, UanTxMode mode)
200
UanMacRcGw::ReceivePacket (Ptr<Packet> pkt, double sinr, UanTxMode mode)
219
{
201
{
 Lines 247-253   UanMacRcGw::ReceivePacket (Ptr<Packet> pkt, double sinr, UanTxMode mode) Link Here 
247
            NS_LOG_DEBUG (Simulator::Now ().GetSeconds () << " GW Received data packet from " << ch.GetSrc () << " length = " << pkt->GetSize ());
229
            NS_LOG_DEBUG (Simulator::Now ().GetSeconds () << " GW Received data packet from " << ch.GetSrc () << " length = " << pkt->GetSize ());
248
            m_ackData[ch.GetSrc ()].rxFrames.insert (dh.GetFrameNo ());
230
            m_ackData[ch.GetSrc ()].rxFrames.insert (dh.GetFrameNo ());
249
          }
231
          }
250
        m_forwardUpCb (pkt, ch.GetSrc ());
232
        m_forwardUpCb (pkt, ch.GetProtocolNumber (), ch.GetSrc ());
251
      }
233
      }
252
      break;
234
      break;
253
    case UanMacRc::TYPE_GWPING:
235
    case UanMacRc::TYPE_GWPING:
 Lines 388-394   UanMacRcGw::StartCycle (void) Link Here 
388
      ctsg.SetRetryRate (m_currentRetryRate);
370
      ctsg.SetRetryRate (m_currentRetryRate);
389
      ctsg.SetTxTimeStamp (Simulator::Now ());
371
      ctsg.SetTxTimeStamp (Simulator::Now ());
390
372
391
      UanHeaderCommon ch (m_address, UanAddress::GetBroadcast (), UanMacRc::TYPE_CTS);
373
      UanHeaderCommon ch (m_address, UanAddress::GetBroadcast (), UanMacRc::TYPE_CTS, 0);
392
      Ptr<Packet> p = Create<Packet> ();
374
      Ptr<Packet> p = Create<Packet> ();
393
      p->AddHeader (ctsg);
375
      p->AddHeader (ctsg);
394
      p->AddHeader (ch);
376
      p->AddHeader (ch);
(-)a/src/uan/model/uan-mac-rc-gw.h (-7 / +4 lines)
 Lines 22-28    Link Here 
22
#define UAN_MAC_RC_GW_H
22
#define UAN_MAC_RC_GW_H
23
23
24
#include "uan-mac.h"
24
#include "uan-mac.h"
25
#include "uan-address.h"
25
#include "ns3/uan-address.h"
26
26
27
#include "ns3/nstime.h"
27
#include "ns3/nstime.h"
28
#include "ns3/traced-callback.h"
28
#include "ns3/traced-callback.h"
 Lines 67-78   public: Link Here 
67
  static TypeId GetTypeId (void);
67
  static TypeId GetTypeId (void);
68
68
69
  // Inherited methods
69
  // Inherited methods
70
  virtual Address GetAddress (void);
70
  virtual bool Enqueue (Ptr<Packet> pkt, uint16_t protocolNumber, const Address &dest);
71
  virtual void SetAddress (UanAddress addr);
71
  virtual void SetForwardUpCb (Callback<void, Ptr<Packet>, uint16_t, const UanAddress&> cb);
72
  virtual bool Enqueue (Ptr<Packet> pkt, const Address &dest, uint16_t protocolNumber);
73
  virtual void SetForwardUpCb (Callback<void, Ptr<Packet>, const UanAddress&> cb);
74
  virtual void AttachPhy (Ptr<UanPhy> phy);
72
  virtual void AttachPhy (Ptr<UanPhy> phy);
75
  virtual Address GetBroadcast (void) const;
76
  virtual void Clear (void);
73
  virtual void Clear (void);
77
  int64_t AssignStreams (int64_t stream);
74
  int64_t AssignStreams (int64_t stream);
78
75
 Lines 126-132   private: Link Here 
126
    uint8_t expFrames;  //!< Expected number of frames.
123
    uint8_t expFrames;  //!< Expected number of frames.
127
  };
124
  };
128
  /** Forwarding up callback. */
125
  /** Forwarding up callback. */
129
  Callback<void, Ptr<Packet>, const UanAddress& > m_forwardUpCb;
126
  Callback<void, Ptr<Packet>, uint16_t, const UanAddress&> m_forwardUpCb;
130
  
127
  
131
  Ptr<UanPhy> m_phy;            //!< PHY layer attached to this MAC.
128
  Ptr<UanPhy> m_phy;            //!< PHY layer attached to this MAC.
132
  UanAddress m_address;         //!< The MAC address.
129
  UanAddress m_address;         //!< The MAC address.
(-)a/src/uan/model/uan-mac-rc.cc (-25 / +7 lines)
 Lines 275-294   UanMacRc::AssignStreams (int64_t stream) Link Here 
275
  return 1;
275
  return 1;
276
}
276
}
277
277
278
Address
279
UanMacRc::GetAddress (void)
280
{
281
  return m_address;
282
}
283
284
void
285
UanMacRc::SetAddress (UanAddress addr)
286
{
287
  m_address = addr;
288
}
289
290
bool
278
bool
291
UanMacRc::Enqueue (Ptr<Packet> packet, const Address &dest, uint16_t protocolNumber)
279
UanMacRc::Enqueue (Ptr<Packet> packet, uint16_t protocolNumber, const Address &dest)
292
{
280
{
293
  if (protocolNumber > 0)
281
  if (protocolNumber > 0)
294
    {
282
    {
 Lines 324-330   UanMacRc::Enqueue (Ptr<Packet> packet, const Address &dest, uint16_t protocolNum Link Here 
324
}
312
}
325
313
326
void
314
void
327
UanMacRc::SetForwardUpCb (Callback<void, Ptr<Packet>, const UanAddress&> cb)
315
UanMacRc::SetForwardUpCb (Callback<void, Ptr<Packet>, uint16_t, const UanAddress&> cb)
328
{
316
{
329
  m_forwardUpCb = cb;
317
  m_forwardUpCb = cb;
330
}
318
}
 Lines 336-347   UanMacRc::AttachPhy (Ptr<UanPhy> phy) Link Here 
336
  m_phy->SetReceiveOkCallback (MakeCallback (&UanMacRc::ReceiveOkFromPhy, this));
324
  m_phy->SetReceiveOkCallback (MakeCallback (&UanMacRc::ReceiveOkFromPhy, this));
337
}
325
}
338
326
339
Address
340
UanMacRc::GetBroadcast (void) const
341
{
342
  return UanAddress::GetBroadcast ();
343
}
344
345
void
327
void
346
UanMacRc::ReceiveOkFromPhy (Ptr<Packet> pkt, double sinr, UanTxMode mode)
328
UanMacRc::ReceiveOkFromPhy (Ptr<Packet> pkt, double sinr, UanTxMode mode)
347
{
329
{
 Lines 362-368   UanMacRc::ReceiveOkFromPhy (Ptr<Packet> pkt, double sinr, UanTxMode mode) Link Here 
362
          NS_LOG_DEBUG (Simulator::Now ().GetSeconds () << " Node " << m_address << " UanMacRc Receiving DATA packet from PHY");
344
          NS_LOG_DEBUG (Simulator::Now ().GetSeconds () << " Node " << m_address << " UanMacRc Receiving DATA packet from PHY");
363
          UanHeaderRcData dh;
345
          UanHeaderRcData dh;
364
          pkt->RemoveHeader (dh);
346
          pkt->RemoveHeader (dh);
365
          m_forwardUpCb (pkt, ch.GetSrc ());
347
          m_forwardUpCb (pkt, ch.GetProtocolNumber (), ch.GetSrc ());
366
        }
348
        }
367
      break;
349
      break;
368
    case TYPE_RTS:
350
    case TYPE_RTS:
 Lines 634-640   UanMacRc::Associate (void) Link Here 
634
    {
616
    {
635
      Ptr<Packet> pkt = Create<Packet> (0);
617
      Ptr<Packet> pkt = Create<Packet> (0);
636
      pkt->AddHeader (CreateRtsHeader (res));
618
      pkt->AddHeader (CreateRtsHeader (res));
637
      pkt->AddHeader (UanHeaderCommon (m_address, UanAddress::GetBroadcast (), (uint8_t) TYPE_GWPING));
619
      pkt->AddHeader (UanHeaderCommon (m_address, UanAddress::GetBroadcast (), (uint8_t) TYPE_GWPING, 0));
638
      NS_LOG_DEBUG (Simulator::Now ().GetSeconds () << " Sending first GWPING " << *pkt);
620
      NS_LOG_DEBUG (Simulator::Now ().GetSeconds () << " Sending first GWPING " << *pkt);
639
      SendPacket (pkt,m_currentRate + m_numRates);
621
      SendPacket (pkt,m_currentRate + m_numRates);
640
    }
622
    }
 Lines 665-671   UanMacRc::AssociateTimeout () Link Here 
665
      res.IncrementRetry ();
647
      res.IncrementRetry ();
666
648
667
      pkt->AddHeader (CreateRtsHeader (res));
649
      pkt->AddHeader (CreateRtsHeader (res));
668
      pkt->AddHeader (UanHeaderCommon (m_address, UanAddress::GetBroadcast (), (uint8_t) TYPE_GWPING));
650
      pkt->AddHeader (UanHeaderCommon (m_address, UanAddress::GetBroadcast (), (uint8_t) TYPE_GWPING, 0));
669
651
670
      SendPacket (pkt,m_currentRate + m_numRates);
652
      SendPacket (pkt,m_currentRate + m_numRates);
671
      m_resList.push_back (res);
653
      m_resList.push_back (res);
 Lines 698-704   UanMacRc::SendRts (void) Link Here 
698
    {
680
    {
699
      Ptr<Packet> pkt = Create<Packet> (0);
681
      Ptr<Packet> pkt = Create<Packet> (0);
700
      pkt->AddHeader (CreateRtsHeader (res));
682
      pkt->AddHeader (CreateRtsHeader (res));
701
      pkt->AddHeader (UanHeaderCommon (m_address, UanAddress::GetBroadcast (), (uint8_t) TYPE_RTS));
683
      pkt->AddHeader (UanHeaderCommon (m_address, UanAddress::GetBroadcast (), (uint8_t) TYPE_RTS, 0));
702
      SendPacket (pkt,m_currentRate + m_numRates);
684
      SendPacket (pkt,m_currentRate + m_numRates);
703
    }
685
    }
704
  m_state = RTSSENT;
686
  m_state = RTSSENT;
 Lines 761-767   UanMacRc::RtsTimeout (void) Link Here 
761
      res.IncrementRetry ();
743
      res.IncrementRetry ();
762
      m_resList.push_back (res);
744
      m_resList.push_back (res);
763
      pkt->AddHeader (CreateRtsHeader (res));
745
      pkt->AddHeader (CreateRtsHeader (res));
764
      pkt->AddHeader (UanHeaderCommon (m_address, UanAddress::GetBroadcast (), (uint8_t) TYPE_RTS));
746
      pkt->AddHeader (UanHeaderCommon (m_address, UanAddress::GetBroadcast (), (uint8_t) TYPE_RTS, 0));
765
      SendPacket (pkt,m_currentRate + m_numRates);
747
      SendPacket (pkt,m_currentRate + m_numRates);
766
748
767
    }
749
    }
(-)a/src/uan/model/uan-mac-rc.h (-7 / +4 lines)
 Lines 22-28    Link Here 
22
#define UAN_MAC_RC_H
22
#define UAN_MAC_RC_H
23
23
24
#include "uan-mac.h"
24
#include "uan-mac.h"
25
#include "uan-address.h"
25
#include "ns3/uan-address.h"
26
26
27
#include "ns3/nstime.h"
27
#include "ns3/nstime.h"
28
#include "ns3/trace-source-accessor.h"
28
#include "ns3/trace-source-accessor.h"
 Lines 183-194   public: Link Here 
183
  static TypeId GetTypeId (void);
183
  static TypeId GetTypeId (void);
184
184
185
  // Inherited methods
185
  // Inherited methods
186
  virtual Address GetAddress (void);
186
  virtual bool Enqueue (Ptr<Packet> pkt, uint16_t protocolNumber, const Address &dest);
187
  virtual void SetAddress (UanAddress addr);
187
  virtual void SetForwardUpCb (Callback<void, Ptr<Packet>, uint16_t, const UanAddress&> cb);
188
  virtual bool Enqueue (Ptr<Packet> pkt, const Address &dest, uint16_t protocolNumber);
189
  virtual void SetForwardUpCb (Callback<void, Ptr<Packet>, const UanAddress&> cb);
190
  virtual void AttachPhy (Ptr<UanPhy> phy);
188
  virtual void AttachPhy (Ptr<UanPhy> phy);
191
  virtual Address GetBroadcast (void) const;
192
  virtual void Clear (void);
189
  virtual void Clear (void);
193
  int64_t AssignStreams (int64_t stream);
190
  int64_t AssignStreams (int64_t stream);
194
191
 Lines 241-247   private: Link Here 
241
  std::list<Reservation> m_resList;
238
  std::list<Reservation> m_resList;
242
239
243
  /** The callback to forward a packet up to higher layer. */
240
  /** The callback to forward a packet up to higher layer. */
244
  Callback<void, Ptr<Packet>, const UanAddress& > m_forwardUpCb;
241
  Callback<void, Ptr<Packet>, uint16_t, const UanAddress&> m_forwardUpCb;
245
242
246
  /** A packet was destined for and received at this MAC layer. */
243
  /** A packet was destined for and received at this MAC layer. */
247
  TracedCallback<Ptr<const Packet>, UanTxMode > m_rxLogger;
244
  TracedCallback<Ptr<const Packet>, UanTxMode > m_rxLogger;
(-)a/src/uan/model/uan-mac.cc (+37 lines)
 Lines 24-29   namespace ns3 { Link Here 
24
24
25
NS_OBJECT_ENSURE_REGISTERED (UanMac);
25
NS_OBJECT_ENSURE_REGISTERED (UanMac);
26
26
27
UanMac::UanMac ()
28
  : m_txModeIndex (0)
29
{
30
31
}
32
27
TypeId UanMac::GetTypeId (void)
33
TypeId UanMac::GetTypeId (void)
28
{
34
{
29
  static TypeId tid = TypeId ("ns3::UanMac")
35
  static TypeId tid = TypeId ("ns3::UanMac")
 Lines 33-36   TypeId UanMac::GetTypeId (void) Link Here 
33
  return tid;
39
  return tid;
34
}
40
}
35
41
42
void
43
UanMac::SetTxModeIndex (uint32_t txModeIndex)
44
{
45
  m_txModeIndex = txModeIndex;
46
}
47
48
uint32_t
49
UanMac::GetTxModeIndex ()
50
{
51
  return m_txModeIndex;
52
}
53
54
Address
55
UanMac::GetAddress (void)
56
{
57
  return m_address;
58
}
59
60
void
61
UanMac::SetAddress (UanAddress addr)
62
{
63
  m_address=addr;
64
}
65
66
Address
67
UanMac::GetBroadcast (void) const
68
{
69
  UanAddress broadcast = UanAddress(255);
70
  return broadcast;
71
}
72
36
} // namespace ns3
73
} // namespace ns3
(-)a/src/uan/model/uan-mac.h (-6 / +17 lines)
 Lines 48-53   class UanAddress; Link Here 
48
class UanMac : public Object
48
class UanMac : public Object
49
{
49
{
50
public:
50
public:
51
  /** Default constructor */
52
  UanMac ();
51
  /**
53
  /**
52
   * Register this type.
54
   * Register this type.
53
   * \return The TypeId.
55
   * \return The TypeId.
 Lines 59-82   public: Link Here 
59
   *
61
   *
60
   * \return MAC Address.
62
   * \return MAC Address.
61
   */
63
   */
62
  virtual Address GetAddress (void) = 0;
64
  virtual Address GetAddress (void);
63
65
64
  /**
66
  /**
65
   * Set the address.
67
   * Set the address.
66
   *
68
   *
67
   * \param addr UanAddress for this MAC.
69
   * \param addr UanAddress for this MAC.
68
   */
70
   */
69
  virtual void SetAddress (UanAddress addr) = 0;
71
  virtual void SetAddress (UanAddress addr);
70
72
71
  /**
73
  /**
72
   * Enqueue packet to be transmitted.
74
   * Enqueue packet to be transmitted.
73
   *
75
   *
74
   * \param pkt Packet to be transmitted.
76
   * \param pkt Packet to be transmitted.
75
   * \param dest Destination address.
77
   * \param dest Destination address.
76
   * \param protocolNumber Protocol number.  Usage varies by MAC.
78
   * \param protocolNumber The type of the packet.
77
   * \return True if packet was successfully enqueued.
79
   * \return True if packet was successfully enqueued.
78
   */
80
   */
79
  virtual bool Enqueue (Ptr<Packet> pkt, const Address &dest, uint16_t protocolNumber) = 0;
81
  virtual bool Enqueue (Ptr<Packet> pkt, uint16_t protocolNumber, const Address &dest) = 0;
80
  /**
82
  /**
81
   * Set the callback to forward packets up to higher layers.
83
   * Set the callback to forward packets up to higher layers.
82
   * 
84
   * 
 Lines 84-90   public: Link Here 
84
   * \pname{packet} The packet.
86
   * \pname{packet} The packet.
85
   * \pname{address} The source address.
87
   * \pname{address} The source address.
86
   */
88
   */
87
  virtual void SetForwardUpCb (Callback<void, Ptr<Packet>, const UanAddress&> cb) = 0;
89
  virtual void SetForwardUpCb (Callback<void, Ptr<Packet>, uint16_t, const UanAddress&> cb) = 0;
88
90
89
  /**
91
  /**
90
   * Attach PHY layer to this MAC.
92
   * Attach PHY layer to this MAC.
 Lines 101-107   public: Link Here 
101
   *
103
   *
102
   * \return The broadcast address.
104
   * \return The broadcast address.
103
   */
105
   */
104
  virtual Address GetBroadcast (void) const = 0;
106
  virtual Address GetBroadcast (void) const;
105
107
106
  /** Clears all pointer references. */
108
  /** Clears all pointer references. */
107
  virtual void Clear (void) = 0;
109
  virtual void Clear (void) = 0;
 Lines 125-130   public: Link Here 
125
  typedef void (* PacketModeTracedCallback)
127
  typedef void (* PacketModeTracedCallback)
126
    (Ptr<const Packet> packet, UanTxMode mode);
128
    (Ptr<const Packet> packet, UanTxMode mode);
127
129
130
  uint32_t GetTxModeIndex ();
131
  void SetTxModeIndex (uint32_t txModeIndex);
132
133
private:
134
  /** Modulation type */
135
  uint32_t m_txModeIndex;
136
  /** The MAC address. */
137
  UanAddress m_address;
138
128
};  // class UanMac
139
};  // class UanMac
129
140
130
} // namespace ns3
141
} // namespace ns3
(-)a/src/uan/model/uan-net-device.cc (-7 / +9 lines)
 Lines 271-290   UanNetDevice::GetBroadcast () const Link Here 
271
bool
271
bool
272
UanNetDevice::IsMulticast () const
272
UanNetDevice::IsMulticast () const
273
{
273
{
274
  return false;
274
  return true;
275
}
275
}
276
276
277
Address
277
Address
278
UanNetDevice::GetMulticast (Ipv4Address multicastGroup) const
278
UanNetDevice::GetMulticast (Ipv4Address multicastGroup) const
279
{
279
{
280
  NS_FATAL_ERROR ("UanNetDevice does not support multicast");
281
  return m_mac->GetBroadcast ();
280
  return m_mac->GetBroadcast ();
282
}
281
}
283
282
284
Address
283
Address
285
UanNetDevice::GetMulticast (Ipv6Address addr) const
284
UanNetDevice::GetMulticast (Ipv6Address addr) const
286
{
285
{
287
  NS_FATAL_ERROR ("UanNetDevice does not support multicast");
288
  return m_mac->GetBroadcast ();
286
  return m_mac->GetBroadcast ();
289
}
287
}
290
288
 Lines 302-308   UanNetDevice::IsPointToPoint () const Link Here 
302
bool
300
bool
303
UanNetDevice::Send (Ptr<Packet> packet, const Address &dest, uint16_t protocolNumber)
301
UanNetDevice::Send (Ptr<Packet> packet, const Address &dest, uint16_t protocolNumber)
304
{
302
{
305
  return m_mac->Enqueue (packet, dest, protocolNumber);
303
  uint8_t tmp [6];
304
  dest.CopyTo (tmp);
305
  UanAddress udest (tmp[0]);
306
307
  return m_mac->Enqueue (packet, protocolNumber, udest);
306
}
308
}
307
309
308
bool
310
bool
 Lines 327-333   UanNetDevice::SetNode (Ptr<Node> node) Link Here 
327
bool
329
bool
328
UanNetDevice::NeedsArp () const
330
UanNetDevice::NeedsArp () const
329
{
331
{
330
  return false;
332
  return true;
331
}
333
}
332
334
333
void
335
void
 Lines 337-347   UanNetDevice::SetReceiveCallback (NetDevice::ReceiveCallback cb) Link Here 
337
}
339
}
338
340
339
void
341
void
340
UanNetDevice::ForwardUp (Ptr<Packet> pkt, const UanAddress &src)
342
UanNetDevice::ForwardUp (Ptr<Packet> pkt, uint16_t protocolNumber, const UanAddress &src)
341
{
343
{
342
  NS_LOG_DEBUG ("Forwarding packet up to application");
344
  NS_LOG_DEBUG ("Forwarding packet up to application");
343
  m_rxLogger (pkt, src);
345
  m_rxLogger (pkt, src);
344
  m_forwardUp (this, pkt, 0, src);
346
  m_forwardUp (this, pkt, protocolNumber, src);
345
347
346
}
348
}
347
349
(-)a/src/uan/model/uan-net-device.h (-2 / +3 lines)
 Lines 24-30    Link Here 
24
#include "ns3/net-device.h"
24
#include "ns3/net-device.h"
25
#include "ns3/pointer.h"
25
#include "ns3/pointer.h"
26
#include "ns3/traced-callback.h"
26
#include "ns3/traced-callback.h"
27
#include "uan-address.h"
27
#include "ns3/uan-address.h"
28
#include <list>
28
#include <list>
29
29
30
namespace ns3 {
30
namespace ns3 {
 Lines 162-169   private: Link Here 
162
   *
162
   *
163
   * \param pkt The packet.
163
   * \param pkt The packet.
164
   * \param src The source address.
164
   * \param src The source address.
165
   * \param protocolNumber The layer 3 protocol number.
165
   */
166
   */
166
  virtual void ForwardUp (Ptr<Packet> pkt, const UanAddress &src);
167
  virtual void ForwardUp (Ptr<Packet> pkt, uint16_t protocolNumber, const UanAddress &src);
167
  
168
  
168
  /** \return The channel attached to this device. */
169
  /** \return The channel attached to this device. */
169
  Ptr<UanChannel> DoGetChannel (void) const;
170
  Ptr<UanChannel> DoGetChannel (void) const;
(-)a/src/uan/wscript (-2 lines)
 Lines 8-14   def build(bld): Link Here 
8
        'model/uan-mac.cc',
8
        'model/uan-mac.cc',
9
        'model/uan-transducer.cc',
9
        'model/uan-transducer.cc',
10
        'model/uan-transducer-hd.cc',
10
        'model/uan-transducer-hd.cc',
11
        'model/uan-address.cc',
12
        'model/uan-net-device.cc',
11
        'model/uan-net-device.cc',
13
        'model/uan-tx-mode.cc',
12
        'model/uan-tx-mode.cc',
14
        'model/uan-prop-model.cc',
13
        'model/uan-prop-model.cc',
 Lines 46-52   def build(bld): Link Here 
46
        'model/uan-transducer.h',
45
        'model/uan-transducer.h',
47
        'model/uan-phy-gen.h',
46
        'model/uan-phy-gen.h',
48
        'model/uan-transducer-hd.h',
47
        'model/uan-transducer-hd.h',
49
        'model/uan-address.h',
50
        'model/uan-prop-model-ideal.h',
48
        'model/uan-prop-model-ideal.h',
51
        'model/uan-mac-aloha.h',
49
        'model/uan-mac-aloha.h',
52
        'model/uan-header-common.h',
50
        'model/uan-header-common.h',

Return to bug 2413