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

(-)a/src/internet/model/arp-header.cc (-1 / +1 lines)
 Lines 136-142    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
(-)1f2769a4f8ec (+178 lines)
Added Link Here 
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
 * This program is free software; you can redistribute it and/or modify
4
 * it under the terms of the GNU General Public License version 2 as
5
 * published by the Free Software Foundation;
6
 *
7
 * This program is distributed in the hope that it will be useful,
8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
 * GNU General Public License for more details.
11
 *
12
 * You should have received a copy of the GNU General Public License
13
 * along with this program; if not, write to the Free Software
14
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
15
 *
16
 * Author: Hossam Khader <hossamkhader@gmail.com>
17
 */
18
19
#include "ns3/core-module.h"
20
#include "ns3/node-container.h"
21
#include "ns3/mobility-helper.h"
22
#include "ns3/mobility-model.h"
23
#include "ns3/basic-energy-source-helper.h"
24
#include "ns3/energy-source-container.h"
25
#include "ns3/uan-helper.h"
26
#include "ns3/uan-channel.h"
27
#include "ns3/acoustic-modem-energy-model-helper.h"
28
#include "ns3/uan-application-helper.h"
29
#include "ns3/uan-application.h"
30
#include "ns3/ipv4-address-helper.h"
31
#include "ns3/internet-stack-helper.h"
32
#include "ns3/ipv4-interface.h"
33
#include "ns3/arp-cache.h"
34
35
using namespace ns3;
36
37
/**
38
 *
39
 * This example shows the usage of UanApplication to transfer data.
40
 * Two nodes are sending their remaining energy percentage (1 byte)
41
 * to a gateway node, that prints the received data.
42
 * The transmissions are scheduled at random times to avoid collisions
43
 * ARP parameters should be tuned, based on the network size
44
 *
45
 */
46
47
NS_LOG_COMPONENT_DEFINE ("UanApplicationExample");
48
49
void SetupPositions ();
50
void SetupEnergy ();
51
void SetupCommunications ();
52
void PrintReceivedPacket (Address src, Buffer data);
53
void SetupApplications ();
54
void SendPacket ();
55
void Run ();
56
57
NodeContainer nodeContainer;
58
59
void
60
SetupPositions ()
61
{
62
  MobilityHelper mobilityHelper;
63
  mobilityHelper.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
64
  mobilityHelper.Install (nodeContainer);
65
  nodeContainer.Get (0)->GetObject<MobilityModel> ()->SetPosition (Vector (0, 0, 0));
66
  nodeContainer.Get (1)->GetObject<MobilityModel> ()->SetPosition (Vector (100, 0, 0));
67
  nodeContainer.Get (2)->GetObject<MobilityModel> ()->SetPosition (Vector (-100, 0, 0));
68
}
69
70
void
71
SetupEnergy ()
72
{
73
  BasicEnergySourceHelper energySourceHelper;
74
  energySourceHelper.Set ("BasicEnergySourceInitialEnergyJ", DoubleValue (900000));
75
  energySourceHelper.Install (nodeContainer);
76
}
77
78
void
79
SetupCommunications ()
80
{
81
  Ptr<UanChannel> channel = CreateObject<UanChannel> ();
82
  UanHelper uanHelper;
83
  NetDeviceContainer netDeviceContainer = uanHelper.Install (nodeContainer, channel);
84
  EnergySourceContainer energySourceContainer;
85
  NodeContainer::Iterator node = nodeContainer.Begin ();
86
  while (node != nodeContainer.End ())
87
    {
88
      energySourceContainer.Add ((*node)->GetObject<EnergySourceContainer> ()->Get (0));
89
      node++;
90
    }
91
  AcousticModemEnergyModelHelper acousticModemEnergyModelHelper;
92
  acousticModemEnergyModelHelper.Install (netDeviceContainer, energySourceContainer);
93
94
  InternetStackHelper internet;
95
  internet.Install (nodeContainer);
96
  Ipv4AddressHelper ipv4;
97
  ipv4.SetBase ("10.0.0.0", "255.255.255.0");
98
  ipv4.Assign (netDeviceContainer);
99
100
  node = nodeContainer.Begin ();
101
  while (node != nodeContainer.End ())
102
    {
103
      (*node)->GetObject<Ipv4L3Protocol> ()->GetInterface (1)->GetArpCache ()->SetDeadTimeout (Hours (24));
104
      (*node)->GetObject<Ipv4L3Protocol> ()->GetInterface (1)->GetArpCache ()->SetAliveTimeout (Hours (12));
105
      (*node)->GetObject<Ipv4L3Protocol> ()->GetInterface (1)->GetArpCache ()->SetWaitReplyTimeout (Seconds (10));
106
      node++;
107
    }
108
}
109
110
void
111
PrintReceivedPacket (Address src, Buffer data)
112
{
113
  std::cout << "Time:" << Simulator::Now ().GetHours () << "|"
114
            << "Node:" << Ipv4Address::ConvertFrom (src)
115
            << "|Energy:" << (int)(data.Begin ().ReadU8 ()) << "%" << std::endl;
116
}
117
118
void
119
SetupApplications ()
120
{
121
  UanApplicationHelper uanApplicationHelper;
122
  ApplicationContainer applicationContainer;
123
  uanApplicationHelper.SetPort (9);
124
  applicationContainer = uanApplicationHelper.Install (nodeContainer);
125
  applicationContainer.Start (Seconds (0));
126
  NodeContainer::Iterator node = nodeContainer.Begin ();
127
  while (node != nodeContainer.End ())
128
    {
129
      Ptr<UanApplication> uanApplication = (*node)->GetApplication (0)->GetObject<UanApplication> ();
130
      uanApplication->SetPacketReceivedCallback (MakeCallback<void, Address, Buffer>(&PrintReceivedPacket));
131
      node++;
132
    }
133
}
134
135
void
136
SendPacket ()
137
{
138
  Ptr<UniformRandomVariable> uniformRandomVariable = CreateObject<UniformRandomVariable> ();
139
  NodeContainer::Iterator node = nodeContainer.Begin ();
140
  node++;
141
  while (node != nodeContainer.End ())
142
    {
143
      uint8_t energy = ((*node)->GetObject<EnergySourceContainer> ()->Get (0)->GetEnergyFraction ()) * 100;
144
      Ptr<UanApplication> uanApplication = (*node)->GetApplication (0)->GetObject<UanApplication> ();
145
      Buffer dataBuffer;
146
      dataBuffer.AddAtEnd (sizeof (uint8_t));
147
      Buffer::Iterator i = dataBuffer.Begin ();
148
      double time = uniformRandomVariable->GetValue (0, 15);
149
      i.WriteU8 (energy);
150
      Simulator::Schedule (Seconds (time), &UanApplication::Send, uanApplication, Ipv4Address ("10.0.0.1"), dataBuffer);
151
      node++;
152
    }
153
  Simulator::Schedule (Minutes (5), &SendPacket);
154
}
155
156
void
157
Run ()
158
{
159
  nodeContainer.Create (3);
160
  SetupPositions ();
161
  SetupEnergy ();
162
  SetupCommunications ();
163
  SetupApplications ();
164
  SendPacket ();
165
}
166
167
int
168
main (int argc, char *argv[])
169
{
170
  CommandLine cmd;
171
  cmd.Parse (argc, argv);
172
  Run ();
173
  Simulator::Stop (Days (20));
174
  Simulator::Run ();
175
  Simulator::Destroy ();
176
177
  return 0;
178
}
(-)1f2769a4f8ec (+158 lines)
Added Link Here 
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
 * This program is free software; you can redistribute it and/or modify
4
 * it under the terms of the GNU General Public License version 2 as
5
 * published by the Free Software Foundation;
6
 *
7
 * This program is distributed in the hope that it will be useful,
8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
 * GNU General Public License for more details.
11
 *
12
 * You should have received a copy of the GNU General Public License
13
 * along with this program; if not, write to the Free Software
14
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
15
 *
16
 * Author: Hossam Khader <hossamkhader@gmail.com>
17
 */
18
19
#include "ns3/core-module.h"
20
#include "ns3/node-container.h"
21
#include "ns3/mobility-helper.h"
22
#include "ns3/mobility-model.h"
23
#include "ns3/basic-energy-source-helper.h"
24
#include "ns3/energy-source-container.h"
25
#include "ns3/uan-helper.h"
26
#include "ns3/uan-channel.h"
27
#include "ns3/acoustic-modem-energy-model-helper.h"
28
#include "ns3/uan-raw-application-helper.h"
29
#include "ns3/uan-raw-application.h"
30
31
using namespace ns3;
32
33
/**
34
 *
35
 * This example shows the usage of UanRawApplication to transfer data.
36
 * Two nodes are sending their remaining energy percentage (1 byte)
37
 * to a gateway node, that prints the received data.
38
 * The transmissions are scheduled at random times to avoid collisions
39
 *
40
 */
41
42
NS_LOG_COMPONENT_DEFINE ("UanRawApplicationExample");
43
44
void SetupPositions ();
45
void SetupEnergy ();
46
void SetupCommunications ();
47
void PrintReceivedPacket (Address src, Buffer data);
48
void SetupApplications ();
49
void SendPacket ();
50
void Run ();
51
52
NodeContainer nodeContainer;
53
54
void
55
SetupPositions ()
56
{
57
  MobilityHelper mobilityHelper;
58
  mobilityHelper.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
59
  mobilityHelper.Install (nodeContainer);
60
  nodeContainer.Get (0)->GetObject<MobilityModel> ()->SetPosition (Vector (0, 0, 0));
61
  nodeContainer.Get (1)->GetObject<MobilityModel> ()->SetPosition (Vector (100, 0, 0));
62
  nodeContainer.Get (2)->GetObject<MobilityModel> ()->SetPosition (Vector (-100, 0, 0));
63
}
64
65
void
66
SetupEnergy ()
67
{
68
  BasicEnergySourceHelper energySourceHelper;
69
  energySourceHelper.Set ("BasicEnergySourceInitialEnergyJ", DoubleValue (900000));
70
  energySourceHelper.Install (nodeContainer);
71
}
72
73
void
74
SetupCommunications ()
75
{
76
  Ptr<UanChannel> channel = CreateObject<UanChannel> ();
77
  UanHelper uanHelper;
78
  NetDeviceContainer netDeviceContainer = uanHelper.Install (nodeContainer, channel);
79
  EnergySourceContainer energySourceContainer;
80
  NodeContainer::Iterator node = nodeContainer.Begin ();
81
  while (node != nodeContainer.End ())
82
    {
83
      energySourceContainer.Add ((*node)->GetObject<EnergySourceContainer> ()->Get (0));
84
      node++;
85
    }
86
  AcousticModemEnergyModelHelper acousticModemEnergyModelHelper;
87
  acousticModemEnergyModelHelper.Install (netDeviceContainer, energySourceContainer);
88
}
89
90
void
91
PrintReceivedPacket (Address src, Buffer data)
92
{
93
  std::cout << "Time:" << Simulator::Now ().GetHours () << "|"
94
            << "Node:" << (int)(UanAddress::ConvertFrom (src).GetAsInt ())
95
            << "|Energy:" << (int)(data.Begin ().ReadU8 ()) << "%" << std::endl;
96
}
97
98
void
99
SetupApplications ()
100
{
101
  UanRawApplicationHelper uanRawApplicationHelper;
102
  ApplicationContainer applicationContainer;
103
  applicationContainer = uanRawApplicationHelper.Install (nodeContainer);
104
  applicationContainer.Start (Seconds (0));
105
  NodeContainer::Iterator node = nodeContainer.Begin ();
106
  while (node != nodeContainer.End ())
107
    {
108
      Ptr<UanRawApplication> uanRawApplication = (*node)->GetApplication (0)->GetObject<UanRawApplication> ();
109
      uanRawApplication->SetPacketReceivedCallback (MakeCallback<void, Address, Buffer>(&PrintReceivedPacket));
110
      node++;
111
    }
112
}
113
114
void
115
SendPacket ()
116
{
117
  Ptr<UniformRandomVariable> uniformRandomVariable = CreateObject<UniformRandomVariable> ();
118
  NodeContainer::Iterator node = nodeContainer.Begin ();
119
  node++;
120
  while (node != nodeContainer.End ())
121
    {
122
      uint8_t energy = ((*node)->GetObject<EnergySourceContainer> ()->Get (0)->GetEnergyFraction ()) * 100;
123
      Ptr<UanRawApplication> uanRawApplication = (*node)->GetApplication (0)->GetObject<UanRawApplication> ();
124
      Buffer dataBuffer;
125
      dataBuffer.AddAtEnd (sizeof (uint8_t));
126
      Buffer::Iterator i = dataBuffer.Begin ();
127
      double time = uniformRandomVariable->GetValue (0, 15);
128
      i.WriteU8 (energy);
129
      Simulator::Schedule (Seconds (time), &UanRawApplication::Send, uanRawApplication, UanAddress (0), dataBuffer);
130
      node++;
131
    }
132
  Simulator::Schedule (Minutes (5), &SendPacket);
133
}
134
135
void
136
Run ()
137
{
138
  Packet::EnablePrinting ();
139
  nodeContainer.Create (3);
140
  SetupPositions ();
141
  SetupEnergy ();
142
  SetupCommunications ();
143
  SetupApplications ();
144
  SendPacket ();
145
}
146
147
int
148
main (int argc, char *argv[])
149
{
150
  CommandLine cmd;
151
  cmd.Parse (argc, argv);
152
  Run ();
153
  Simulator::Stop (Days (20));
154
  Simulator::Run ();
155
  Simulator::Destroy ();
156
157
  return 0;
158
}
(-)a/src/uan/examples/wscript (+6 lines)
 Lines 6-8    Link Here 
6
6
7
    obj = bld.create_ns3_program('uan-rc-example', ['internet', 'mobility', 'stats', 'applications', 'uan'])
7
    obj = bld.create_ns3_program('uan-rc-example', ['internet', 'mobility', 'stats', 'applications', 'uan'])
8
    obj.source = 'uan-rc-example.cc'
8
    obj.source = 'uan-rc-example.cc'
9
10
    obj = bld.create_ns3_program('uan-application-example', ['internet', 'uan', 'mobility', 'energy'])
11
    obj.source = 'uan-application-example.cc'
12
13
    obj = bld.create_ns3_program('uan-raw-application-example', ['internet', 'uan', 'mobility', 'energy'])
14
    obj.source = 'uan-raw-application-example.cc'
(-)1f2769a4f8ec (+90 lines)
Added Link Here 
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
 * This program is free software; you can redistribute it and/or modify
4
 * it under the terms of the GNU General Public License version 2 as
5
 * published by the Free Software Foundation;
6
 *
7
 * This program is distributed in the hope that it will be useful,
8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
 * GNU General Public License for more details.
11
 *
12
 * You should have received a copy of the GNU General Public License
13
 * along with this program; if not, write to the Free Software
14
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
15
 * 
16
 * Author: Hossam Khader <hossamkhader@gmail.com>
17
 */
18
19
#include "uan-application-helper.h"
20
#include "ns3/names.h"
21
#include "ns3/packet-socket-factory.h"
22
#include "ns3/packet-socket-helper.h"
23
#include "ns3/net-device.h"
24
#include "ns3/address.h"
25
#include "ns3/uan-application.h"
26
#include "ns3/internet-stack-helper.h"
27
28
29
namespace ns3 {
30
31
UanApplicationHelper::UanApplicationHelper ()
32
  : m_port (0)
33
{
34
  m_factory.SetTypeId ("ns3::UanApplication");
35
}
36
37
void 
38
UanApplicationHelper::SetAttribute (std::string name, const AttributeValue &value)
39
{
40
  m_factory.Set (name, value);
41
}
42
43
ApplicationContainer
44
UanApplicationHelper::Install (Ptr<Node> node) const
45
{
46
  return ApplicationContainer (DoInstall (node));
47
}
48
49
ApplicationContainer
50
UanApplicationHelper::Install (std::string nodeName) const
51
{
52
  Ptr<Node> node = Names::Find<Node> (nodeName);
53
  return ApplicationContainer (DoInstall (node));
54
}
55
56
ApplicationContainer
57
UanApplicationHelper::Install (NodeContainer c) const
58
{
59
  ApplicationContainer apps;
60
  for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
61
    {
62
      apps.Add (DoInstall (*i));
63
    }
64
65
  return apps;
66
}
67
68
Ptr<Application>
69
UanApplicationHelper::DoInstall (Ptr<Node> node) const
70
{
71
  if(node->GetObject<Ipv4> () == NULL)
72
    {
73
      InternetStackHelper internet;
74
      internet.Install (node);
75
    }
76
77
  Ptr<Application> app = m_factory.Create<Application> ();
78
  node->AddApplication (app);
79
  app->GetObject<UanApplication> ()->SetPort (m_port);
80
81
  return app;
82
}
83
84
void
85
UanApplicationHelper::SetPort (uint16_t port)
86
{
87
  m_port = port;
88
}
89
90
} // namespace ns3
(-)1f2769a4f8ec (+100 lines)
Added Link Here 
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
 * This program is free software; you can redistribute it and/or modify
4
 * it under the terms of the GNU General Public License version 2 as
5
 * published by the Free Software Foundation;
6
 *
7
 * This program is distributed in the hope that it will be useful,
8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
 * GNU General Public License for more details.
11
 *
12
 * You should have received a copy of the GNU General Public License
13
 * along with this program; if not, write to the Free Software
14
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
15
 * 
16
 * Author: Hossam Khader <hossamkhader@gmail.com>
17
 */
18
19
#ifndef UANAPPLICATION_HELPER_H
20
#define UANAPPLICATION_HELPER_H
21
22
23
#include "ns3/object-factory.h"
24
#include "ns3/attribute.h"
25
#include "ns3/node-container.h"
26
#include "ns3/application-container.h"
27
28
namespace ns3 {
29
30
/**
31
 * \ingroup uan
32
 * \brief A helper to make it easier to instantiate an ns3::UanApplication 
33
 * on a set of nodes.
34
 */
35
class UanApplicationHelper
36
{
37
public:
38
  /**
39
   * Create an UanApplicationHelper to make it easier to work with UanApplication
40
   */
41
  UanApplicationHelper ();
42
43
  /**
44
   * Helper function used to set the underlying application attributes.
45
   */
46
  void SetAttribute (std::string name, const AttributeValue &value);
47
48
  /**
49
   * Install an ns3::UanApplication on each node of the input container
50
   * configured with all the attributes set with SetAttribute.
51
   *
52
   * \param c NodeContainer of the set of nodes on which an UanApplication 
53
   * will be installed.
54
   * \returns Container of Ptr to the applications installed.
55
   */
56
  ApplicationContainer Install (NodeContainer c) const;
57
58
  /**
59
   * Install an ns3::UanApplication on the node configured with all the 
60
   * attributes set with SetAttribute.
61
   *
62
   * \param node The node on which an UanApplication will be installed.
63
   * \returns Container of Ptr to the applications installed.
64
   */
65
  ApplicationContainer Install (Ptr<Node> node) const;
66
67
  /**
68
   * Install an ns3::UanApplication on the node configured with all the 
69
   * attributes set with SetAttribute.
70
   *
71
   * \param nodeName The node on which an UanApplication will be installed.
72
   * \returns Container of Ptr to the applications installed.
73
   */
74
  ApplicationContainer Install (std::string nodeName) const;
75
76
  /**
77
   * Sets the UDP port number that the UanApplication will use
78
   *
79
   * \param port The UDP port number
80
   */
81
  void SetPort (uint16_t port);
82
83
private:
84
  /**
85
   * Install an ns3::UanApplication on the node configured with all the 
86
   * attributes set with SetAttribute.
87
   *
88
   * \param node The node on which an UanApplication will be installed.
89
   * \returns Ptr to the application installed.
90
   */
91
  Ptr<Application> DoInstall (Ptr<Node> node) const;
92
93
  ObjectFactory m_factory; //!< Object factory.
94
  uint16_t m_port;
95
};
96
97
} // namespace ns3
98
99
#endif /* UANAPPLICATION_HELPER_H */
100
(-)1f2769a4f8ec (+81 lines)
Added Link Here 
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
 * This program is free software; you can redistribute it and/or modify
4
 * it under the terms of the GNU General Public License version 2 as
5
 * published by the Free Software Foundation;
6
 *
7
 * This program is distributed in the hope that it will be useful,
8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
 * GNU General Public License for more details.
11
 *
12
 * You should have received a copy of the GNU General Public License
13
 * along with this program; if not, write to the Free Software
14
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
15
 * 
16
 * Author: Hossam Khader <hossamkhader@gmail.com>
17
 */
18
19
#include "uan-raw-application-helper.h"
20
#include "ns3/names.h"
21
#include "ns3/packet-socket-factory.h"
22
#include "ns3/packet-socket-helper.h"
23
#include "ns3/net-device.h"
24
#include "ns3/address.h"
25
#include "ns3/uan-application.h"
26
27
28
namespace ns3 {
29
30
UanRawApplicationHelper::UanRawApplicationHelper ()
31
{
32
  m_factory.SetTypeId ("ns3::UanRawApplication");
33
}
34
35
void 
36
UanRawApplicationHelper::SetAttribute (std::string name, const AttributeValue &value)
37
{
38
  m_factory.Set (name, value);
39
}
40
41
ApplicationContainer
42
UanRawApplicationHelper::Install (Ptr<Node> node) const
43
{
44
  return ApplicationContainer (DoInstall (node));
45
}
46
47
ApplicationContainer
48
UanRawApplicationHelper::Install (std::string nodeName) const
49
{
50
  Ptr<Node> node = Names::Find<Node> (nodeName);
51
  return ApplicationContainer (DoInstall (node));
52
}
53
54
ApplicationContainer
55
UanRawApplicationHelper::Install (NodeContainer c) const
56
{
57
  ApplicationContainer apps;
58
  for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
59
    {
60
      apps.Add (DoInstall (*i));
61
    }
62
63
  return apps;
64
}
65
66
Ptr<Application>
67
UanRawApplicationHelper::DoInstall (Ptr<Node> node) const
68
{
69
  if(node->GetObject<PacketSocketFactory> () == NULL)
70
    {
71
      PacketSocketHelper packetSocketHelper;
72
      packetSocketHelper.Install (node);
73
    }
74
75
  Ptr<Application> app = m_factory.Create<Application> ();
76
  node->AddApplication (app);
77
78
  return app;
79
}
80
81
} // namespace ns3
(-)1f2769a4f8ec (+92 lines)
Added Link Here 
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
 * This program is free software; you can redistribute it and/or modify
4
 * it under the terms of the GNU General Public License version 2 as
5
 * published by the Free Software Foundation;
6
 *
7
 * This program is distributed in the hope that it will be useful,
8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
 * GNU General Public License for more details.
11
 *
12
 * You should have received a copy of the GNU General Public License
13
 * along with this program; if not, write to the Free Software
14
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
15
 * 
16
 * Author: Hossam Khader <hossamkhader@gmail.com>
17
 */
18
19
#ifndef UANRAWAPPLICATION_HELPER_H
20
#define UANRAWAPPLICATION_HELPER_H
21
22
23
#include "ns3/object-factory.h"
24
#include "ns3/attribute.h"
25
#include "ns3/node-container.h"
26
#include "ns3/application-container.h"
27
28
namespace ns3 {
29
30
/**
31
 * \ingroup uan
32
 * \brief A helper to make it easier to instantiate an ns3::UanApplication 
33
 * on a set of nodes.
34
 */
35
class UanRawApplicationHelper
36
{
37
public:
38
  /**
39
   * Create an UanApplicationHelper to make it easier to work with UanRawApplication
40
   */
41
  UanRawApplicationHelper ();
42
43
  /**
44
   * Helper function used to set the underlying application attributes.
45
   */
46
  void SetAttribute (std::string name, const AttributeValue &value);
47
48
  /**
49
   * Install an ns3::UanRawApplication on each node of the input container
50
   * configured with all the attributes set with SetAttribute.
51
   *
52
   * \param c NodeContainer of the set of nodes on which an UanRawApplication 
53
   * will be installed.
54
   * \returns Container of Ptr to the applications installed.
55
   */
56
  ApplicationContainer Install (NodeContainer c) const;
57
58
  /**
59
   * Install an ns3::UanRawApplication on the node configured with all the 
60
   * attributes set with SetAttribute.
61
   *
62
   * \param node The node on which an UanRawApplication will be installed.
63
   * \returns Container of Ptr to the applications installed.
64
   */
65
  ApplicationContainer Install (Ptr<Node> node) const;
66
67
  /**
68
   * Install an ns3::UanRawApplication on the node configured with all the 
69
   * attributes set with SetAttribute.
70
   *
71
   * \param nodeName The node on which an UanRawApplication will be installed.
72
   * \returns Container of Ptr to the applications installed.
73
   */
74
  ApplicationContainer Install (std::string nodeName) const;
75
76
private:
77
  /**
78
   * Install an ns3::UanRawApplication on the node configured with all the 
79
   * attributes set with SetAttribute.
80
   *
81
   * \param node The node on which an UanRawApplication will be installed.
82
   * \returns Ptr to the application installed.
83
   */
84
  Ptr<Application> DoInstall (Ptr<Node> node) const;
85
86
  ObjectFactory m_factory; //!< Object factory.
87
};
88
89
} // namespace ns3
90
91
#endif /* UANRAWAPPLICATION_HELPER_H */
92
(-)1f2769a4f8ec (+172 lines)
Added Link Here 
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
 * This program is free software; you can redistribute it and/or modify
4
 * it under the terms of the GNU General Public License version 2 as
5
 * published by the Free Software Foundation;
6
 *
7
 * This program is distributed in the hope that it will be useful,
8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
 * GNU General Public License for more details.
11
 *
12
 * You should have received a copy of the GNU General Public License
13
 * along with this program; if not, write to the Free Software
14
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
15
 * 
16
 * Author: Hossam Khader <hossamkhader@gmail.com>
17
 */
18
#include "uan-application.h"
19
#include "ns3/log.h"
20
#include "ns3/socket-factory.h"
21
#include "ns3/packet-socket-address.h"
22
#include "ns3/packet-socket.h"
23
24
namespace ns3 {
25
26
NS_LOG_COMPONENT_DEFINE ("UanApplication");
27
28
NS_OBJECT_ENSURE_REGISTERED (UanApplication);
29
30
TypeId 
31
UanApplication::GetTypeId (void)
32
{
33
  static TypeId tid = TypeId ("ns3::UanApplication")
34
    .SetParent<Application> ()
35
    .SetGroupName ("Applications")
36
    .AddConstructor<UanApplication> ()
37
  ;
38
  return tid;
39
}
40
41
UanApplication::UanApplication ()
42
{
43
  NS_LOG_FUNCTION (this);
44
  m_socket = NULL;
45
  m_packetReceivedCallback.Nullify ();
46
}
47
UanApplication::~UanApplication ()
48
{
49
  NS_LOG_FUNCTION (this);
50
}
51
52
void
53
UanApplication::DoDispose (void)
54
{
55
  NS_LOG_FUNCTION (this);
56
  m_socket = NULL;
57
  m_packetReceivedCallback.Nullify ();
58
  Application::DoDispose ();
59
}
60
61
uint32_t
62
UanApplication::GetApplicationId (void) const
63
{
64
  NS_LOG_FUNCTION (this);
65
  Ptr<Node> node = GetNode ();
66
  for (uint32_t i = 0; i < node->GetNApplications (); ++i)
67
    {
68
      if (node->GetApplication (i) == this)
69
        {
70
          return i;
71
        }
72
    }
73
  NS_ASSERT_MSG (false, "forgot to add application to node");
74
  return 0;
75
}
76
77
78
void 
79
UanApplication::Send (Address dst, const Buffer dataBuffer)
80
{
81
  NS_LOG_FUNCTION (this);
82
  const uint8_t * data = dataBuffer.PeekData ();
83
  Ptr<Socket> socket;
84
  socket = Socket::CreateSocket (GetNode (), TypeId::LookupByName ("ns3::UdpSocketFactory"));
85
  Ptr<Packet> packet = Create<Packet> (data, dataBuffer.GetSize ());
86
  NS_ASSERT (socket != NULL);
87
  if(Ipv4Address::IsMatchingType (dst))
88
    {
89
      InetSocketAddress local = InetSocketAddress (Ipv4Address::GetAny (), m_port);
90
      socket->Bind (local);
91
      socket->Connect (InetSocketAddress (Ipv4Address::ConvertFrom (dst), m_port));
92
      socket->Send (packet);
93
    }
94
95
  socket->Close ();
96
}
97
98
void
99
UanApplication::Receive (Ptr<Socket> socket)
100
{
101
  NS_LOG_FUNCTION (this << socket);
102
  NS_ASSERT (m_socket != NULL);
103
  Address srcAddress;
104
  while (m_socket->GetRxAvailable () > 0)
105
    {
106
      Ptr<Packet> packet = m_socket->RecvFrom (srcAddress);
107
      uint8_t *buffer = new uint8_t[packet->GetSize ()];
108
      packet->CopyData (buffer, packet->GetSize ());
109
      if(!m_packetReceivedCallback.IsNull ())
110
        {
111
          Buffer dataBuffer;
112
          dataBuffer.AddAtEnd ( packet->GetSize ());
113
          Buffer::Iterator iterator = dataBuffer.Begin ();
114
          iterator.Write (buffer, packet->GetSize ());
115
          m_packetReceivedCallback (InetSocketAddress::ConvertFrom (srcAddress).GetIpv4 (), dataBuffer);
116
        }
117
      delete[] buffer;
118
    }
119
120
} 
121
122
void 
123
UanApplication::StartApplication (void)
124
{
125
  NS_LOG_FUNCTION (this);
126
  if (!m_socket)
127
    {
128
      m_socket = Socket::CreateSocket (GetNode (), TypeId::LookupByName ("ns3::UdpSocketFactory"));
129
    }
130
  InetSocketAddress local = InetSocketAddress (Ipv4Address::GetAny (), m_port);
131
  m_socket->Bind (local);
132
  m_socket->SetRecvCallback (MakeCallback (&UanApplication::Receive, this));
133
}
134
 
135
void 
136
UanApplication::StopApplication (void)
137
{
138
  NS_LOG_FUNCTION (this);
139
  if(m_socket != NULL)
140
    {
141
      m_socket->Close ();
142
    }
143
  else
144
    {
145
      NS_LOG_WARN ("UanApplication found null socket to close in StopApplication");
146
    }
147
}
148
149
void
150
UanApplication::SetPacketReceivedCallback (PacketReceivedCallback callback)
151
{
152
  NS_LOG_FUNCTION (this);
153
  if (callback.IsNull ())
154
    {
155
      NS_LOG_DEBUG ("UanApplication:Setting NULL packet received callback!");
156
    }
157
  m_packetReceivedCallback = callback;
158
}
159
160
void
161
UanApplication::SetPort (uint16_t port)
162
{
163
  m_port = port;
164
}
165
166
uint16_t
167
UanApplication::GetPort () const
168
{
169
  return m_port;
170
}
171
172
} // namespace ns3
(-)1f2769a4f8ec (+105 lines)
Added Link Here 
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
 * This program is free software; you can redistribute it and/or modify
4
 * it under the terms of the GNU General Public License version 2 as
5
 * published by the Free Software Foundation;
6
 *
7
 * This program is distributed in the hope that it will be useful,
8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
 * GNU General Public License for more details.
11
 *
12
 * You should have received a copy of the GNU General Public License
13
 * along with this program; if not, write to the Free Software
14
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
15
 * 
16
 * Author: Hossam Khader <hossamkhader@gmail.com>
17
 */
18
19
#ifndef UANAPPLICATION_H
20
#define UANAPPLICATION_H
21
22
23
#include "ns3/application.h"
24
#include "ns3/packet.h"
25
#include "ns3/uan-address.h"
26
#include "ns3/socket.h"
27
28
namespace ns3 {
29
30
/**
31
 * \ingroup uan
32
 * \brief a simple UDP application to be used in UAN networks
33
 * 
34
 * The Application uses the NS-3 IP stack, and UDP Sockets to send and received
35
 * data.
36
 * The user interacts with the application mainly through two functions:
37
 * Send () : Used to send the data in the buffer parameter to the
38
 * destination IPv4 address.
39
 * SetPacketReceivedCallback (): Used to set a receive callback where the raw 
40
 * packet payload, and the source IPv4 address will be passed as
41
 * parameters.
42
 */
43
44
class UanApplication : public Application
45
{
46
public:
47
48
  typedef Callback<void, Address, Buffer> PacketReceivedCallback;
49
50
  /**
51
   * \brief Get the type ID.
52
   * \return the object TypeId
53
   */
54
  static TypeId GetTypeId (void);
55
56
  /**
57
   * create a uan application
58
   */
59
  UanApplication ();
60
  virtual ~UanApplication ();
61
62
  /**
63
   * \brief Send a packet to the destination
64
   * \param dst the destination IPv4 address
65
   * \param dataBuffer the data to be sent
66
   */
67
  void Send (Address dst, const Buffer dataBuffer);
68
69
  /**
70
   * \brief Set a callback when a packet is received
71
   * \param callback the packet received callback
72
   */
73
  void SetPacketReceivedCallback (PacketReceivedCallback callback);
74
75
  void SetPort (uint16_t port);
76
  uint16_t GetPort () const;
77
78
private:
79
80
  // inherited from Application base class.
81
  virtual void StartApplication (void);
82
  virtual void StopApplication (void);
83
  virtual void DoDispose (void);
84
  /**
85
   * \brief Return the application ID in the node.
86
   * \returns the application id
87
   */
88
  uint32_t GetApplicationId (void) const;
89
  /**
90
   * \brief Receive a packet
91
   * \param socket the receiving socket
92
   *
93
   * This function is called by lower layers through a callback.
94
   */
95
  void Receive (Ptr<Socket> socket);
96
97
  Ptr<Socket> m_socket; //!< Associated socket
98
  uint16_t m_port;      //!< Port number
99
  PacketReceivedCallback m_packetReceivedCallback;
100
101
};
102
103
} // namespace ns3
104
105
#endif /* UANAPPLICATION_H */
(-)a/src/uan/model/uan-header-common.cc (-6 / +6 lines)
 Lines 29-35    Link Here 
29
{
29
{
30
}
30
}
31
31
32
UanHeaderCommon::UanHeaderCommon (const UanAddress src, const UanAddress dest, uint8_t type)
32
UanHeaderCommon::UanHeaderCommon (const UanAddress src, const UanAddress dest, uint16_t type)
33
  : Header (),
33
  : Header (),
34
    m_dest (dest),
34
    m_dest (dest),
35
    m_src (src),
35
    m_src (src),
 Lines 71-77    Link Here 
71
}
71
}
72
72
73
void
73
void
74
UanHeaderCommon::SetType (uint8_t type)
74
UanHeaderCommon::SetType (uint16_t type)
75
{
75
{
76
  m_type = type;
76
  m_type = type;
77
}
77
}
 Lines 86-92    Link Here 
86
{
86
{
87
  return m_src;
87
  return m_src;
88
}
88
}
89
uint8_t
89
uint16_t
90
UanHeaderCommon::GetType (void) const
90
UanHeaderCommon::GetType (void) const
91
{
91
{
92
  return m_type;
92
  return m_type;
 Lines 97-103    Link Here 
97
uint32_t
97
uint32_t
98
UanHeaderCommon::GetSerializedSize (void) const
98
UanHeaderCommon::GetSerializedSize (void) const
99
{
99
{
100
  return 1 + 1 + 1;
100
  return 1 + 1 + 2;
101
}
101
}
102
102
103
void
103
void
 Lines 105-111    Link Here 
105
{
105
{
106
  start.WriteU8 (m_src.GetAsInt ());
106
  start.WriteU8 (m_src.GetAsInt ());
107
  start.WriteU8 (m_dest.GetAsInt ());
107
  start.WriteU8 (m_dest.GetAsInt ());
108
  start.WriteU8 (m_type);
108
  start.WriteU16 (m_type);
109
}
109
}
110
110
111
uint32_t
111
uint32_t
 Lines 115-121    Link Here 
115
115
116
  m_src = UanAddress (rbuf.ReadU8 ());
116
  m_src = UanAddress (rbuf.ReadU8 ());
117
  m_dest = UanAddress (rbuf.ReadU8 ());
117
  m_dest = UanAddress (rbuf.ReadU8 ());
118
  m_type = rbuf.ReadU8 ();
118
  m_type = rbuf.ReadU16 ();
119
119
120
  return rbuf.GetDistanceFrom (start);
120
  return rbuf.GetDistanceFrom (start);
121
}
121
}
(-)a/src/uan/model/uan-header-common.h (-5 / +5 lines)
 Lines 34-40    Link Here 
34
 * Common packet header fields.
34
 * Common packet header fields.
35
 *
35
 *
36
 * Includes 1 byte src address, 1 byte dest address,
36
 * Includes 1 byte src address, 1 byte dest address,
37
 * and a 1 byte type field.
37
 * and a 2 bytes type field.
38
 *
38
 *
39
 * The type field is protocol specific; see the relevant MAC protocol.
39
 * The type field is protocol specific; see the relevant MAC protocol.
40
 */
40
 */
 Lines 51-57    Link Here 
51
   * \param dest Destination address defined in header.
51
   * \param dest Destination address defined in header.
52
   * \param type Header type.
52
   * \param type Header type.
53
   */
53
   */
54
  UanHeaderCommon (const UanAddress src, const UanAddress dest, uint8_t type);
54
  UanHeaderCommon (const UanAddress src, const UanAddress dest, uint16_t type);
55
  /** Destructor */
55
  /** Destructor */
56
  virtual ~UanHeaderCommon ();
56
  virtual ~UanHeaderCommon ();
57
57
 Lines 79-85    Link Here 
79
   * Use of this value is protocol specific.
79
   * Use of this value is protocol specific.
80
   * \param type The type value.
80
   * \param type The type value.
81
   */
81
   */
82
  void SetType (uint8_t type);
82
  void SetType (uint16_t type);
83
83
84
  /**
84
  /**
85
   * Get the destination address.
85
   * Get the destination address.
 Lines 98-104    Link Here 
98
   *
98
   *
99
   * \return value of type field.
99
   * \return value of type field.
100
   */
100
   */
101
  uint8_t GetType (void) const;
101
  uint16_t GetType (void) const;
102
102
103
103
104
  // Inherited methods
104
  // Inherited methods
 Lines 110-116    Link Here 
110
private:
110
private:
111
  UanAddress m_dest;  //!< The destination address.
111
  UanAddress m_dest;  //!< The destination address.
112
  UanAddress m_src;   //!< The source address.
112
  UanAddress m_src;   //!< The source address.
113
  uint8_t m_type;     //!< The type field.
113
  uint16_t m_type;     //!< The type field.
114
114
115
};  // class UanHeaderCommon
115
};  // class UanHeaderCommon
116
116
(-)a/src/uan/model/uan-mac-aloha.cc (-6 / +18 lines)
 Lines 36-42    Link Here 
36
36
37
UanMacAloha::UanMacAloha ()
37
UanMacAloha::UanMacAloha ()
38
  : UanMac (),
38
  : UanMac (),
39
    m_cleared (false)
39
    m_cleared (false),
40
    m_txMode (UanTxMode::PSK)
40
{
41
{
41
}
42
}
42
43
 Lines 101-110    Link Here 
101
      UanHeaderCommon header;
102
      UanHeaderCommon header;
102
      header.SetSrc (src);
103
      header.SetSrc (src);
103
      header.SetDest (udest);
104
      header.SetDest (udest);
104
      header.SetType (0);
105
      header.SetType (protocolNumber);
105
106
      packet->AddHeader (header);
106
      packet->AddHeader (header);
107
      m_phy->SendPacket (packet, protocolNumber);
107
      m_phy->SendPacket (packet, GetTxMode ());
108
      return true;
108
      return true;
109
    }
109
    }
110
  else
110
  else
 Lines 112-118    Link Here 
112
}
112
}
113
113
114
void
114
void
115
UanMacAloha::SetForwardUpCb (Callback<void, Ptr<Packet>, const UanAddress& > cb)
115
UanMacAloha::SetForwardUpCb (Callback<void, Ptr<Packet>, const UanAddress&, uint16_t> cb)
116
{
116
{
117
  m_forUpCb = cb;
117
  m_forUpCb = cb;
118
}
118
}
 Lines 133-139    Link Here 
133
133
134
  if (header.GetDest () == GetAddress () || header.GetDest () == UanAddress::GetBroadcast ())
134
  if (header.GetDest () == GetAddress () || header.GetDest () == UanAddress::GetBroadcast ())
135
    {
135
    {
136
      m_forUpCb (pkt, header.GetSrc ());
136
      m_forUpCb (pkt, header.GetSrc (), header.GetType ());
137
    }
137
    }
138
138
139
}
139
}
 Lines 158-161    Link Here 
158
  return 0;
158
  return 0;
159
}
159
}
160
160
161
void
162
UanMacAloha::SetTxMode (UanTxMode::ModulationType txMode)
163
{
164
  m_txMode = txMode;
161
}
165
}
166
167
UanTxMode::ModulationType
168
UanMacAloha::GetTxMode ()
169
{
170
  return m_txMode;
171
}
172
173
}
(-)a/src/uan/model/uan-mac-aloha.h (-2 / +9 lines)
 Lines 23-28    Link Here 
23
23
24
#include "uan-mac.h"
24
#include "uan-mac.h"
25
#include "uan-address.h"
25
#include "uan-address.h"
26
#include "uan-tx-mode.h"
26
27
27
namespace ns3
28
namespace ns3
28
{
29
{
 Lines 58-68    Link Here 
58
  Address GetAddress (void);
59
  Address GetAddress (void);
59
  virtual void SetAddress (UanAddress addr);
60
  virtual void SetAddress (UanAddress addr);
60
  virtual bool Enqueue (Ptr<Packet> pkt, const Address &dest, uint16_t protocolNumber);
61
  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 SetForwardUpCb (Callback<void, Ptr<Packet>, const UanAddress&, uint16_t> cb);
62
  virtual void AttachPhy (Ptr<UanPhy> phy);
63
  virtual void AttachPhy (Ptr<UanPhy> phy);
63
  virtual Address GetBroadcast (void) const;
64
  virtual Address GetBroadcast (void) const;
64
  virtual void Clear (void);
65
  virtual void Clear (void);
65
  int64_t AssignStreams (int64_t stream);
66
  int64_t AssignStreams (int64_t stream);
67
  
68
  UanTxMode::ModulationType GetTxMode ();
69
  void SetTxMode (UanTxMode::ModulationType txMode);
66
70
67
private:
71
private:
68
  /** The MAC address. */
72
  /** The MAC address. */
 Lines 70-76    Link Here 
70
  /** PHY layer attached to this MAC. */
74
  /** PHY layer attached to this MAC. */
71
  Ptr<UanPhy> m_phy;
75
  Ptr<UanPhy> m_phy;
72
  /** Forwarding up callback. */
76
  /** Forwarding up callback. */
73
  Callback<void, Ptr<Packet>, const UanAddress& > m_forUpCb;
77
  Callback<void, Ptr<Packet>, const UanAddress&, uint16_t > m_forUpCb;
74
  /** Flag when we've been cleared. */
78
  /** Flag when we've been cleared. */
75
  bool m_cleared;
79
  bool m_cleared;
76
80
 Lines 92-97    Link Here 
92
  void RxPacketError (Ptr<Packet> pkt, double sinr);
96
  void RxPacketError (Ptr<Packet> pkt, double sinr);
93
protected:
97
protected:
94
  virtual void DoDispose ();
98
  virtual void DoDispose ();
99
  
100
private:
101
  UanTxMode::ModulationType m_txMode;
95
102
96
};  // class UanMacAloha
103
};  // class UanMacAloha
97
104
(-)a/src/uan/model/uan-mac-cw.cc (-7 / +20 lines)
 Lines 38-44    Link Here 
38
    m_phy (0),
38
    m_phy (0),
39
    m_pktTx (0),
39
    m_pktTx (0),
40
    m_state (IDLE),
40
    m_state (IDLE),
41
    m_cleared (false)
41
    m_cleared (false),
42
    m_txMode (UanTxMode::PSK)
42
43
43
{
44
{
44
  m_rv = CreateObject<UniformRandomVariable> ();
45
  m_rv = CreateObject<UniformRandomVariable> ();
 Lines 150-164    Link Here 
150
        UanHeaderCommon header;
151
        UanHeaderCommon header;
151
        header.SetDest (UanAddress::ConvertFrom (dest));
152
        header.SetDest (UanAddress::ConvertFrom (dest));
152
        header.SetSrc (m_address);
153
        header.SetSrc (m_address);
153
        header.SetType (0);
154
        header.SetType (protocolNumber);
154
        packet->AddHeader (header);
155
        packet->AddHeader (header);
155
156
156
        m_enqueueLogger (packet, protocolNumber);
157
        m_enqueueLogger (packet, GetTxMode ());
157
158
158
        if (m_phy->IsStateBusy ())
159
        if (m_phy->IsStateBusy ())
159
          {
160
          {
160
            m_pktTx = packet;
161
            m_pktTx = packet;
161
            m_pktTxProt = protocolNumber;
162
            m_pktTxProt = GetTxMode ();
162
            m_state = CCABUSY;
163
            m_state = CCABUSY;
163
            uint32_t cw = (uint32_t) m_rv->GetValue (0,m_cw);
164
            uint32_t cw = (uint32_t) m_rv->GetValue (0,m_cw);
164
            m_savedDelayS = Seconds ((double)(cw) * m_slotTime.GetSeconds ());
165
            m_savedDelayS = Seconds ((double)(cw) * m_slotTime.GetSeconds ());
 Lines 172-178    Link Here 
172
            NS_LOG_DEBUG ("Time " << Simulator::Now ().GetSeconds () << ": Addr " << GetAddress () << ": Enqueuing new packet while idle (sending)");
173
            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 ());
174
            NS_ASSERT (m_phy->GetTransducer ()->GetArrivalList ().size () == 0 && !m_phy->IsStateTx ());
174
            m_state = TX;
175
            m_state = TX;
175
            m_phy->SendPacket (packet,protocolNumber);
176
            m_phy->SendPacket (packet,GetTxMode ());
176
177
177
          }
178
          }
178
        break;
179
        break;
 Lines 188-194    Link Here 
188
}
189
}
189
190
190
void
191
void
191
UanMacCw::SetForwardUpCb (Callback<void, Ptr<Packet>, const UanAddress&> cb)
192
UanMacCw::SetForwardUpCb (Callback<void, Ptr<Packet>, const UanAddress&, uint16_t> cb)
192
{
193
{
193
  m_forwardUpCb = cb;
194
  m_forwardUpCb = cb;
194
}
195
}
 Lines 348-354    Link Here 
348
349
349
  if (header.GetDest () == m_address || header.GetDest () == UanAddress::GetBroadcast ())
350
  if (header.GetDest () == m_address || header.GetDest () == UanAddress::GetBroadcast ())
350
    {
351
    {
351
      m_forwardUpCb (packet, header.GetSrc ());
352
      m_forwardUpCb (packet, header.GetSrc (), header.GetType ());
352
    }
353
    }
353
}
354
}
354
void
355
void
 Lines 395-398    Link Here 
395
  m_savedDelayS = Seconds (0);
396
  m_savedDelayS = Seconds (0);
396
}
397
}
397
398
399
void
400
UanMacCw::SetTxMode (UanTxMode::ModulationType txMode)
401
{
402
  m_txMode = txMode;
403
}
404
405
UanTxMode::ModulationType
406
UanMacCw::GetTxMode ()
407
{
408
  return m_txMode;
409
}
410
398
} // namespace ns3
411
} // namespace ns3
(-)a/src/uan/model/uan-mac-cw.h (-2 / +8 lines)
 Lines 86-92    Link Here 
86
  virtual Address GetAddress ();
86
  virtual Address GetAddress ();
87
  virtual void SetAddress (UanAddress addr);
87
  virtual void SetAddress (UanAddress addr);
88
  virtual bool Enqueue (Ptr<Packet> pkt, const Address &dest, uint16_t protocolNumber);
88
  virtual bool Enqueue (Ptr<Packet> pkt, const Address &dest, uint16_t protocolNumber);
89
  virtual void SetForwardUpCb (Callback<void, Ptr<Packet>, const UanAddress&> cb);
89
  virtual void SetForwardUpCb (Callback<void, Ptr<Packet>, const UanAddress&, uint16_t> cb);
90
  virtual void AttachPhy (Ptr<UanPhy> phy);
90
  virtual void AttachPhy (Ptr<UanPhy> phy);
91
  virtual Address GetBroadcast (void) const;
91
  virtual Address GetBroadcast (void) const;
92
  virtual void Clear (void);
92
  virtual void Clear (void);
 Lines 99-104    Link Here 
99
  virtual void NotifyCcaStart (void);
99
  virtual void NotifyCcaStart (void);
100
  virtual void NotifyCcaEnd (void);
100
  virtual void NotifyCcaEnd (void);
101
  virtual void NotifyTxStart (Time duration);
101
  virtual void NotifyTxStart (Time duration);
102
  
103
  UanTxMode::ModulationType GetTxMode ();
104
  void SetTxMode (UanTxMode::ModulationType txMode);
102
105
103
  /**
106
  /**
104
   *  TracedCallback signature for enqueue/dequeue of a packet.
107
   *  TracedCallback signature for enqueue/dequeue of a packet.
 Lines 119-125    Link Here 
119
  } State;
122
  } State;
120
123
121
  /** Forwarding up callback. */
124
  /** Forwarding up callback. */
122
  Callback <void, Ptr<Packet>, const UanAddress& > m_forwardUpCb;
125
  Callback <void, Ptr<Packet>, const UanAddress&, uint16_t> m_forwardUpCb;
123
  /** The MAC address. */
126
  /** The MAC address. */
124
  UanAddress m_address;
127
  UanAddress m_address;
125
  /** PHY layer attached to this MAC. */
128
  /** PHY layer attached to this MAC. */
 Lines 183-188    Link Here 
183
186
184
protected:
187
protected:
185
  virtual void DoDispose ();
188
  virtual void DoDispose ();
189
  
190
private:
191
  UanTxMode::ModulationType m_txMode;
186
192
187
};  // class UanMacCw
193
};  // class UanMacCw
188
194
(-)a/src/uan/model/uan-mac-rc-gw.cc (-2 / +2 lines)
 Lines 190-196    Link Here 
190
}
190
}
191
191
192
void
192
void
193
UanMacRcGw::SetForwardUpCb (Callback<void, Ptr<Packet>, const UanAddress&> cb)
193
UanMacRcGw::SetForwardUpCb (Callback<void, Ptr<Packet>, const UanAddress&, uint16_t> cb)
194
{
194
{
195
  m_forwardUpCb = cb;
195
  m_forwardUpCb = cb;
196
}
196
}
 Lines 247-253    Link Here 
247
            NS_LOG_DEBUG (Simulator::Now ().GetSeconds () << " GW Received data packet from " << ch.GetSrc () << " length = " << pkt->GetSize ());
247
            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 ());
248
            m_ackData[ch.GetSrc ()].rxFrames.insert (dh.GetFrameNo ());
249
          }
249
          }
250
        m_forwardUpCb (pkt, ch.GetSrc ());
250
        m_forwardUpCb (pkt, ch.GetSrc (), ch.GetType ());
251
      }
251
      }
252
      break;
252
      break;
253
    case UanMacRc::TYPE_GWPING:
253
    case UanMacRc::TYPE_GWPING:
(-)a/src/uan/model/uan-mac-rc-gw.h (-2 / +2 lines)
 Lines 70-76    Link Here 
70
  virtual Address GetAddress (void);
70
  virtual Address GetAddress (void);
71
  virtual void SetAddress (UanAddress addr);
71
  virtual void SetAddress (UanAddress addr);
72
  virtual bool Enqueue (Ptr<Packet> pkt, const Address &dest, uint16_t protocolNumber);
72
  virtual bool Enqueue (Ptr<Packet> pkt, const Address &dest, uint16_t protocolNumber);
73
  virtual void SetForwardUpCb (Callback<void, Ptr<Packet>, const UanAddress&> cb);
73
  virtual void SetForwardUpCb (Callback<void, Ptr<Packet>, const UanAddress&, uint16_t> cb);
74
  virtual void AttachPhy (Ptr<UanPhy> phy);
74
  virtual void AttachPhy (Ptr<UanPhy> phy);
75
  virtual Address GetBroadcast (void) const;
75
  virtual Address GetBroadcast (void) const;
76
  virtual void Clear (void);
76
  virtual void Clear (void);
 Lines 126-132    Link Here 
126
    uint8_t expFrames;  //!< Expected number of frames.
126
    uint8_t expFrames;  //!< Expected number of frames.
127
  };
127
  };
128
  /** Forwarding up callback. */
128
  /** Forwarding up callback. */
129
  Callback<void, Ptr<Packet>, const UanAddress& > m_forwardUpCb;
129
  Callback<void, Ptr<Packet>, const UanAddress&, uint16_t> m_forwardUpCb;
130
  
130
  
131
  Ptr<UanPhy> m_phy;            //!< PHY layer attached to this MAC.
131
  Ptr<UanPhy> m_phy;            //!< PHY layer attached to this MAC.
132
  UanAddress m_address;         //!< The MAC address.
132
  UanAddress m_address;         //!< The MAC address.
(-)a/src/uan/model/uan-mac-rc.cc (-2 / +2 lines)
 Lines 324-330    Link Here 
324
}
324
}
325
325
326
void
326
void
327
UanMacRc::SetForwardUpCb (Callback<void, Ptr<Packet>, const UanAddress&> cb)
327
UanMacRc::SetForwardUpCb (Callback<void, Ptr<Packet>, const UanAddress&, uint16_t> cb)
328
{
328
{
329
  m_forwardUpCb = cb;
329
  m_forwardUpCb = cb;
330
}
330
}
 Lines 362-368    Link Here 
362
          NS_LOG_DEBUG (Simulator::Now ().GetSeconds () << " Node " << m_address << " UanMacRc Receiving DATA packet from PHY");
362
          NS_LOG_DEBUG (Simulator::Now ().GetSeconds () << " Node " << m_address << " UanMacRc Receiving DATA packet from PHY");
363
          UanHeaderRcData dh;
363
          UanHeaderRcData dh;
364
          pkt->RemoveHeader (dh);
364
          pkt->RemoveHeader (dh);
365
          m_forwardUpCb (pkt, ch.GetSrc ());
365
          m_forwardUpCb (pkt, ch.GetSrc (), ch.GetType ());
366
        }
366
        }
367
      break;
367
      break;
368
    case TYPE_RTS:
368
    case TYPE_RTS:
(-)a/src/uan/model/uan-mac-rc.h (-2 / +2 lines)
 Lines 186-192    Link Here 
186
  virtual Address GetAddress (void);
186
  virtual Address GetAddress (void);
187
  virtual void SetAddress (UanAddress addr);
187
  virtual void SetAddress (UanAddress addr);
188
  virtual bool Enqueue (Ptr<Packet> pkt, const Address &dest, uint16_t protocolNumber);
188
  virtual bool Enqueue (Ptr<Packet> pkt, const Address &dest, uint16_t protocolNumber);
189
  virtual void SetForwardUpCb (Callback<void, Ptr<Packet>, const UanAddress&> cb);
189
  virtual void SetForwardUpCb (Callback<void, Ptr<Packet>, const UanAddress&, uint16_t> cb);
190
  virtual void AttachPhy (Ptr<UanPhy> phy);
190
  virtual void AttachPhy (Ptr<UanPhy> phy);
191
  virtual Address GetBroadcast (void) const;
191
  virtual Address GetBroadcast (void) const;
192
  virtual void Clear (void);
192
  virtual void Clear (void);
 Lines 241-247    Link Here 
241
  std::list<Reservation> m_resList;
241
  std::list<Reservation> m_resList;
242
242
243
  /** The callback to forward a packet up to higher layer. */
243
  /** The callback to forward a packet up to higher layer. */
244
  Callback<void, Ptr<Packet>, const UanAddress& > m_forwardUpCb;
244
  Callback<void, Ptr<Packet>, const UanAddress&, uint16_t > m_forwardUpCb;
245
245
246
  /** A packet was destined for and received at this MAC layer. */
246
  /** A packet was destined for and received at this MAC layer. */
247
  TracedCallback<Ptr<const Packet>, UanTxMode > m_rxLogger;
247
  TracedCallback<Ptr<const Packet>, UanTxMode > m_rxLogger;
(-)a/src/uan/model/uan-mac.h (-2 / +2 lines)
 Lines 84-90    Link Here 
84
   * \pname{packet} The packet.
84
   * \pname{packet} The packet.
85
   * \pname{address} The source address.
85
   * \pname{address} The source address.
86
   */
86
   */
87
  virtual void SetForwardUpCb (Callback<void, Ptr<Packet>, const UanAddress&> cb) = 0;
87
  virtual void SetForwardUpCb (Callback<void, Ptr<Packet>, const UanAddress&, uint16_t> cb) = 0;
88
88
89
  /**
89
  /**
90
   * Attach PHY layer to this MAC.
90
   * Attach PHY layer to this MAC.
 Lines 124-130    Link Here 
124
   */
124
   */
125
  typedef void (* PacketModeTracedCallback)
125
  typedef void (* PacketModeTracedCallback)
126
    (Ptr<const Packet> packet, UanTxMode mode);
126
    (Ptr<const Packet> packet, UanTxMode mode);
127
127
  
128
};  // class UanMac
128
};  // class UanMac
129
129
130
} // namespace ns3
130
} // namespace ns3
(-)a/src/uan/model/uan-net-device.cc (-3 / +3 lines)
 Lines 316-322    Link Here 
316
bool
316
bool
317
UanNetDevice::NeedsArp () const
317
UanNetDevice::NeedsArp () const
318
{
318
{
319
  return false;
319
  return true;
320
}
320
}
321
321
322
void
322
void
 Lines 326-336    Link Here 
326
}
326
}
327
327
328
void
328
void
329
UanNetDevice::ForwardUp (Ptr<Packet> pkt, const UanAddress &src)
329
UanNetDevice::ForwardUp (Ptr<Packet> pkt, const UanAddress &src, uint16_t protocolNumber)
330
{
330
{
331
  NS_LOG_DEBUG ("Forwarding packet up to application");
331
  NS_LOG_DEBUG ("Forwarding packet up to application");
332
  m_rxLogger (pkt, src);
332
  m_rxLogger (pkt, src);
333
  m_forwardUp (this, pkt, 0, src);
333
  m_forwardUp (this, pkt, protocolNumber, src);
334
334
335
}
335
}
336
336
(-)a/src/uan/model/uan-net-device.h (-1 / +2 lines)
 Lines 162-169    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 Protocol Number
165
   */
166
   */
166
  virtual void ForwardUp (Ptr<Packet> pkt, const UanAddress &src);
167
  virtual void ForwardUp (Ptr<Packet> pkt, const UanAddress &src, uint16_t protocolNumber);
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;
(-)1f2769a4f8ec (+184 lines)
Added Link Here 
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
 * This program is free software; you can redistribute it and/or modify
4
 * it under the terms of the GNU General Public License version 2 as
5
 * published by the Free Software Foundation;
6
 *
7
 * This program is distributed in the hope that it will be useful,
8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
 * GNU General Public License for more details.
11
 *
12
 * You should have received a copy of the GNU General Public License
13
 * along with this program; if not, write to the Free Software
14
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
15
 * 
16
 * Author: Hossam Khader <hossamkhader@gmail.com>
17
 */
18
#include "uan-raw-application.h"
19
#include "ns3/log.h"
20
#include "ns3/socket-factory.h"
21
#include "ns3/packet-socket-address.h"
22
#include "ns3/packet-socket.h"
23
24
namespace ns3 {
25
26
NS_LOG_COMPONENT_DEFINE ("UanRawApplication");
27
28
NS_OBJECT_ENSURE_REGISTERED (UanRawApplication);
29
30
TypeId 
31
UanRawApplication::GetTypeId (void)
32
{
33
  static TypeId tid = TypeId ("ns3::UanRawApplication")
34
    .SetParent<Application> ()
35
    .SetGroupName ("Applications")
36
    .AddConstructor<UanRawApplication> ()
37
  ;
38
  return tid;
39
}
40
41
UanRawApplication::UanRawApplication ()
42
{
43
  NS_LOG_FUNCTION (this);
44
  m_socket = NULL;
45
  m_packetReceivedCallback.Nullify ();
46
}
47
UanRawApplication::~UanRawApplication ()
48
{
49
  NS_LOG_FUNCTION (this);
50
}
51
52
void
53
UanRawApplication::DoDispose (void)
54
{
55
  NS_LOG_FUNCTION (this);
56
  m_socket = NULL;
57
  m_packetReceivedCallback.Nullify ();
58
  Application::DoDispose ();
59
}
60
61
uint32_t
62
UanRawApplication::GetApplicationId (void) const
63
{
64
  NS_LOG_FUNCTION (this);
65
  Ptr<Node> node = GetNode ();
66
  for (uint32_t i = 0; i < node->GetNApplications (); ++i)
67
    {
68
      if (node->GetApplication (i) == this)
69
        {
70
          return i;
71
        }
72
    }
73
  NS_ASSERT_MSG (false, "forgot to add application to node");
74
  return 0;
75
}
76
77
78
void 
79
UanRawApplication::Send (Address dst, const Buffer dataBuffer)
80
{
81
  NS_LOG_FUNCTION (this);
82
  const uint8_t * data = dataBuffer.PeekData ();
83
84
  if(UanAddress::ConvertFrom (dst).GetAsInt () != 
85
     UanAddress::ConvertFrom (GetNode ()->GetDevice (0)->GetAddress ()).GetAsInt ())
86
    { 
87
      PacketSocketAddress socketAddress;
88
      socketAddress.SetSingleDevice (GetNode ()->GetDevice (0)->GetIfIndex ());
89
      socketAddress.SetPhysicalAddress (dst);
90
      socketAddress.SetProtocol (0);
91
      Ptr<Socket> socket = Socket::CreateSocket (GetNode (), TypeId::LookupByName ("ns3::PacketSocketFactory"));
92
      Ptr<Packet> packet = Create<Packet> (data, dataBuffer.GetSize ());
93
      NS_ASSERT (socket != NULL);
94
      socket->Bind ();
95
      socket->Connect (socketAddress);
96
      socket->Send (packet);
97
      socket->Close ();
98
    }
99
}
100
101
void
102
UanRawApplication::Receive (Ptr<Socket> socket)
103
{
104
  NS_LOG_FUNCTION (this << socket);
105
  NS_ASSERT (m_socket != NULL);
106
  while (m_socket->GetRxAvailable () > 0)
107
    {
108
      Ptr<Packet> packet = m_socket->Recv ();
109
      uint8_t *buffer = new uint8_t[packet->GetSize ()];
110
      packet->CopyData (buffer, packet->GetSize ());
111
      Address srcAddress;
112
      PacketTagIterator i = packet->GetPacketTagIterator ();
113
      while (i.HasNext ())
114
        {
115
          PacketTagIterator::Item item = i.Next ();
116
          if (item.GetTypeId () == TypeId::LookupByName ("ns3::SocketAddressTag"))
117
            {
118
              SocketAddressTag tag;
119
              item.GetTag (tag);
120
              Address address = tag.GetAddress ();
121
              uint8_t *addressBuffer = new uint8_t[address.GetLength ()];
122
              address.CopyTo (addressBuffer);
123
              srcAddress = UanAddress (addressBuffer[address.GetLength () -1]);
124
              delete [] addressBuffer;
125
            }
126
        }
127
      if(!m_packetReceivedCallback.IsNull ())
128
        {
129
          Buffer dataBuffer;
130
          dataBuffer.AddAtEnd ( packet->GetSize ());
131
          Buffer::Iterator iterator = dataBuffer.Begin ();
132
          iterator.Write (buffer, packet->GetSize ());
133
          m_packetReceivedCallback (srcAddress, dataBuffer);
134
        }
135
      delete[] buffer;
136
    }
137
138
} 
139
140
void 
141
UanRawApplication::StartApplication (void)
142
{
143
  NS_LOG_FUNCTION (this);
144
  PacketSocketAddress socketAddress;
145
  socketAddress.SetSingleDevice (GetNode ()->GetDevice (0)->GetIfIndex ());
146
  socketAddress.SetPhysicalAddress (UanAddress (UanAddress::GetBroadcast ()));
147
  socketAddress.SetProtocol (0);
148
  if (!m_socket)
149
    {
150
      m_socket = Socket::CreateSocket (GetNode (), TypeId::LookupByName ("ns3::PacketSocketFactory"));
151
    }
152
  m_socket->Bind ();
153
  m_socket->Connect (socketAddress);
154
  m_socket->SetRecvCallback (MakeCallback (&UanRawApplication::Receive, this));
155
}
156
 
157
void 
158
UanRawApplication::StopApplication (void)
159
{
160
  NS_LOG_FUNCTION (this);
161
  if(m_socket != NULL)
162
    {
163
      m_socket->Close ();
164
    }
165
  else
166
    {
167
      NS_LOG_WARN ("UanRawApplication found null socket to close in StopApplication");
168
    }
169
}
170
171
void
172
UanRawApplication::SetPacketReceivedCallback (PacketReceivedCallback callback)
173
{
174
  NS_LOG_FUNCTION (this);
175
  if (callback.IsNull ())
176
    {
177
      NS_LOG_DEBUG ("UanRawApplication:Setting NULL packet received callback!");
178
    }
179
  m_packetReceivedCallback = callback;
180
}
181
182
183
184
} // namespace ns3
(-)1f2769a4f8ec (+102 lines)
Added Link Here 
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
 * This program is free software; you can redistribute it and/or modify
4
 * it under the terms of the GNU General Public License version 2 as
5
 * published by the Free Software Foundation;
6
 *
7
 * This program is distributed in the hope that it will be useful,
8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
 * GNU General Public License for more details.
11
 *
12
 * You should have received a copy of the GNU General Public License
13
 * along with this program; if not, write to the Free Software
14
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
15
 * 
16
 * Author: Hossam Khader <hossamkhader@gmail.com>
17
 */
18
19
#ifndef UANRAWAPPLICATION_H
20
#define UANRAWAPPLICATION_H
21
22
23
#include "ns3/application.h"
24
#include "ns3/packet.h"
25
#include "ns3/uan-address.h"
26
#include "ns3/socket.h"
27
28
namespace ns3 {
29
30
/**
31
 * \ingroup uan
32
 * \brief a simple Raw application to be used in UAN networks
33
 * 
34
 * The Application runs directly on top of the UAN data link layer, so raw data
35
 * is sent in the payload of the UAN frame.
36
 * 
37
 * The user interacts with the application mainly through two functions:
38
 * Send () : Used to send the data in the buffer parameter to the
39
 * destination UAN address.
40
 * SetPacketReceivedCallback (): Used to set a receive callback where the raw 
41
 * packet payload, and the source UAN address will be passed as
42
 * parameters.
43
 */
44
45
class UanRawApplication : public Application
46
{
47
public:
48
49
  typedef Callback<void, Address, Buffer> PacketReceivedCallback;
50
51
  /**
52
   * \brief Get the type ID.
53
   * \return the object TypeId
54
   */
55
  static TypeId GetTypeId (void);
56
57
  /**
58
   * create a uan application
59
   */
60
  UanRawApplication ();
61
  virtual ~UanRawApplication ();
62
63
  /**
64
   * \brief Send a packet to the destination
65
   * \param dst the destination UAN address
66
   * \param dataBuffer the data to be sent
67
   */
68
  void Send (Address dst, const Buffer dataBuffer);
69
70
  /**
71
   * \brief Set a callback when a packet is received
72
   * \param callback the packet received callback
73
   */
74
  void SetPacketReceivedCallback (PacketReceivedCallback callback);
75
76
private:
77
78
  // inherited from Application base class.
79
  virtual void StartApplication (void);
80
  virtual void StopApplication (void);
81
  virtual void DoDispose (void);
82
  /**
83
   * \brief Return the application ID in the node.
84
   * \returns the application id
85
   */
86
  uint32_t GetApplicationId (void) const;
87
  /**
88
   * \brief Receive a packet
89
   * \param socket the receiving socket
90
   *
91
   * This function is called by lower layers through a callback.
92
   */
93
  void Receive (Ptr<Socket> socket);
94
95
  Ptr<Socket> m_socket; //!< Associated socket
96
  PacketReceivedCallback m_packetReceivedCallback;
97
98
};
99
100
} // namespace ns3
101
102
#endif /* UANRAWAPPLICATION_H */
(-)a/src/uan/wscript (-1 / +9 lines)
 Lines 25-32    Link Here 
25
        'model/uan-phy.cc',
25
        'model/uan-phy.cc',
26
        'model/uan-noise-model.cc',
26
        'model/uan-noise-model.cc',
27
        'model/acoustic-modem-energy-model.cc',
27
        'model/acoustic-modem-energy-model.cc',
28
        'model/uan-application.cc',
29
        'model/uan-raw-application.cc',
28
        'helper/uan-helper.cc',
30
        'helper/uan-helper.cc',
29
        'helper/acoustic-modem-energy-model-helper.cc',
31
        'helper/acoustic-modem-energy-model-helper.cc',
32
        'helper/uan-application-helper.cc',
33
        'helper/uan-raw-application-helper.cc',
30
        ]
34
        ]
31
35
32
    module_test = bld.create_ns3_module_test_library('uan')
36
    module_test = bld.create_ns3_module_test_library('uan')
 Lines 58-66    Link Here 
58
        'model/uan-header-rc.h',
62
        'model/uan-header-rc.h',
59
        'model/uan-mac-rc.h',
63
        'model/uan-mac-rc.h',
60
        'model/acoustic-modem-energy-model.h',
64
        'model/acoustic-modem-energy-model.h',
65
        'model/uan-mac-rc-gw.h',
66
        'model/uan-application.h',
67
        'model/uan-raw-application.h',
61
        'helper/uan-helper.h',
68
        'helper/uan-helper.h',
62
        'helper/acoustic-modem-energy-model-helper.h',
69
        'helper/acoustic-modem-energy-model-helper.h',
63
        'model/uan-mac-rc-gw.h',
70
        'helper/uan-application-helper.h',
71
        'helper/uan-raw-application-helper.h',
64
        ]
72
        ]
65
73
66
    if (bld.env['ENABLE_EXAMPLES']):
74
    if (bld.env['ENABLE_EXAMPLES']):

Return to bug 2410