Code review fixes

This commit is contained in:
Kirill Andreev
2009-08-25 17:21:34 +04:00
parent bf8d1de536
commit c29a242067
5 changed files with 45 additions and 55 deletions

View File

@@ -123,11 +123,18 @@ MeshTest::CreateNodes ()
wifiPhy.SetChannel (wifiChannel.Create ());
// Install mesh point devices & protocols
mesh.SetStackInstaller (m_stack, "Root", Mac48AddressValue (Mac48Address (m_root.c_str ())));
mesh.SetSpreadInterfaceChannels (m_chan);
if (m_chan)
{
mesh.SetSpreadInterfaceChannels (MeshHelper::SPREAD_CHANNELS);
}
else
{
mesh.SetSpreadInterfaceChannels (MeshHelper::ZERO_CHANNEL);
}
MeshInterfaceHelper interface = MeshInterfaceHelper::Default ();
interface.SetType ("RandomStart", TimeValue (Seconds(m_randomStart)));
meshDevices = mesh.Install (wifiPhy, interface, nodes, m_nIfaces);
mesh.SetNumberOfInterfaces (m_nIfaces);
meshDevices = mesh.Install (wifiPhy, interface, nodes);
// Setup mobility
MobilityHelper mobility;
mobility.SetPositionAllocator ("ns3::GridPositionAllocator",

View File

@@ -96,7 +96,7 @@ MeshPointDevice::ReceiveFromDevice (Ptr<NetDevice> incomingPort, Ptr<const Packe
if (dst48.IsGroup ())
{
Ptr<Packet> packet_copy = packet->Copy ();
if (m_removeRoutingStuff (incomingPort->GetIfIndex (), src48, dst48, packet_copy, realProtocol))
if (m_routingProtocol->RemoveRoutingStuff (incomingPort->GetIfIndex (), src48, dst48, packet_copy, realProtocol))
{
m_rxCallback (this, packet_copy, realProtocol, src);
Forward (incomingPort, packet, protocol, src48, dst48);
@@ -109,10 +109,9 @@ MeshPointDevice::ReceiveFromDevice (Ptr<NetDevice> incomingPort, Ptr<const Packe
if (dst48 == m_address)
{
Ptr<Packet> packet_copy = packet->Copy ();
if (m_removeRoutingStuff (incomingPort->GetIfIndex (), src48, dst48, packet_copy, realProtocol))
if (m_routingProtocol->RemoveRoutingStuff (incomingPort->GetIfIndex (), src48, dst48, packet_copy, realProtocol))
{
m_rxCallback (this, packet_copy, realProtocol, src);
m_rxStats.unicastData++;
m_rxStats.unicastDataBytes += packet->GetSize ();
}
@@ -127,7 +126,8 @@ MeshPointDevice::Forward (Ptr<NetDevice> inport, Ptr<const Packet> packet, uint1
const Mac48Address src, const Mac48Address dst)
{
// pass through routing protocol
m_requestRoute (inport->GetIfIndex (), src, dst, packet, protocol, m_myResponse);
m_routingProtocol->RequestRoute (inport->GetIfIndex (), src, dst, packet, protocol, MakeCallback (
&MeshPointDevice::DoSend, this));
}
void
@@ -240,7 +240,8 @@ bool
MeshPointDevice::Send (Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber)
{
const Mac48Address dst48 = Mac48Address::ConvertFrom (dest);
return m_requestRoute (m_ifIndex, m_address, dst48, packet, protocolNumber, m_myResponse);
return m_routingProtocol->RequestRoute (m_ifIndex, m_address, dst48, packet, protocolNumber, MakeCallback (
&MeshPointDevice::DoSend, this));
}
bool
@@ -249,7 +250,8 @@ MeshPointDevice::SendFrom (Ptr<Packet> packet, const Address& src, const Address
{
const Mac48Address src48 = Mac48Address::ConvertFrom (src);
const Mac48Address dst48 = Mac48Address::ConvertFrom (dest);
return m_requestRoute (m_ifIndex, src48, dst48, packet, protocolNumber, m_myResponse);
return m_routingProtocol->RequestRoute (m_ifIndex, src48, dst48, packet, protocolNumber, MakeCallback (
&MeshPointDevice::DoSend, this));
}
Ptr<Node>
@@ -377,14 +379,9 @@ void
MeshPointDevice::SetRoutingProtocol (Ptr<MeshL2RoutingProtocol> protocol)
{
NS_LOG_FUNCTION_NOARGS ();
NS_ASSERT_MSG (PeekPointer (protocol->GetMeshPoint ()) == this,
"Routing protocol must be installed on mesh point to be useful.");
m_routingProtocol = protocol;
m_requestRoute = MakeCallback (&MeshL2RoutingProtocol::RequestRoute, protocol);
m_removeRoutingStuff = MakeCallback (&MeshL2RoutingProtocol::RemoveRoutingStuff, protocol);
m_myResponse = MakeCallback (&MeshPointDevice::DoSend, this);
}
Ptr<MeshL2RoutingProtocol>

View File

@@ -163,18 +163,6 @@ private:
uint16_t m_mtu;
/// Virtual channel for upper layers
Ptr<BridgeChannel> m_channel;
/// Routing request callback
Callback<bool,
uint32_t,
Mac48Address,
Mac48Address,
Ptr<const Packet>,
uint16_t,
MeshL2RoutingProtocol::RouteReplyCallback> m_requestRoute;
Callback<bool, uint32_t, Mac48Address, Mac48Address, Ptr<Packet>, uint16_t&> m_removeRoutingStuff;
/// Routing response callback, this is supplied to mesh routing protocol
MeshL2RoutingProtocol::RouteReplyCallback m_myResponse;
/// Current routing protocol, used mainly by GetRoutingProtocol
Ptr<MeshL2RoutingProtocol> m_routingProtocol;

View File

@@ -27,13 +27,14 @@ NS_LOG_COMPONENT_DEFINE ("MeshHelper");
namespace ns3
{
MeshHelper::MeshHelper () :
m_spreadInterfaceChannels (false), m_stack (0)
m_nInterfaces (1),
m_spreadChannelPolicy (ZERO_CHANNEL), m_stack (0)
{
}
void
MeshHelper::SetSpreadInterfaceChannels (bool s)
MeshHelper::SetSpreadInterfaceChannels (enum ChannelPolicy policy)
{
m_spreadInterfaceChannels = s;
m_spreadChannelPolicy = policy;
}
void
MeshHelper::SetStackInstaller (std::string type,
@@ -64,9 +65,14 @@ MeshHelper::SetStackInstaller (std::string type,
}
}
void
MeshHelper::SetNumberOfInterfaces (uint32_t nInterfaces)
{
m_nInterfaces = nInterfaces;
}
NetDeviceContainer
MeshHelper::Install (const WifiPhyHelper &phyHelper, const MeshInterfaceHelper &interfaceHelper,
NodeContainer c, uint32_t nInterfaces) const
NodeContainer c) const
{
NetDeviceContainer devices;
NS_ASSERT (m_stack != 0);
@@ -80,11 +86,10 @@ MeshHelper::Install (const WifiPhyHelper &phyHelper, const MeshInterfaceHelper &
node->AddDevice (mp);
// Create wifi interfaces (single interface by default)
for (uint32_t i = 0; i < nInterfaces; ++i)
for (uint32_t i = 0; i < m_nInterfaces; ++i)
{
uint32_t channel = i * 5;
Ptr<WifiNetDevice> iface = interfaceHelper.CreateInterface (phyHelper, node,
(m_spreadInterfaceChannels ? channel : 0));
Ptr<WifiNetDevice> iface = interfaceHelper.CreateInterface (phyHelper, node, channel);
mp->AddInterface (iface);
}
if (!m_stack->InstallStack (mp))
@@ -96,13 +101,6 @@ MeshHelper::Install (const WifiPhyHelper &phyHelper, const MeshInterfaceHelper &
}
return devices;
}
NetDeviceContainer
MeshHelper::Install (const WifiPhyHelper &phy, const MeshInterfaceHelper &interfaceHelper, Ptr<Node> node,
uint32_t nInterfaces) const
{
return Install (phy, interfaceHelper, NodeContainer (node), nInterfaces);
}
void
MeshHelper::Report (const ns3::Ptr<ns3::NetDevice>& device, std::ostream& os)
{

View File

@@ -46,8 +46,17 @@ public:
*
* If set to true different non-overlaping 20MHz frequency
* channels will be assigned to different mesh point interfaces.
*/
void SetSpreadInterfaceChannels (bool);
*/
enum ChannelPolicy {
SPREAD_CHANNELS,
ZERO_CHANNEL
};
void SetSpreadInterfaceChannels (ChannelPolicy);
/**
* \brief Set a number of interfaces in a mesh network
* \param nInterfaces is the number of interfaces
*/
void SetNumberOfInterfaces (uint32_t nInterfaces);
/**
* \brief Install 802.11s mesh device & protocols on given node list
@@ -59,18 +68,8 @@ public:
*
* \return list of created mesh point devices, see MeshPointDevice
*/
NetDeviceContainer Install (const WifiPhyHelper &phyHelper, const MeshInterfaceHelper &interfaceHelper, NodeContainer c, uint32_t nInterfaces = 1) const;
/**
* \brief Install 802.11s mesh device & protocols on given node
*
* \param phy Wifi PHY helper
* \param node Node to install
* \param roots List of root mesh points
* \param nInterfaces Number of mesh point radio interfaces (= WiFi NICs)
*
* \return list of created mesh point devices, see MeshPointDevice
*/
NetDeviceContainer Install (const WifiPhyHelper &phy, const MeshInterfaceHelper &interfaceHelper, Ptr<Node> node, uint32_t nInterfaces = 1) const;
NetDeviceContainer
Install (const WifiPhyHelper &phyHelper, const MeshInterfaceHelper &interfaceHelper, NodeContainer c) const;
/**
* \param type the type of ns3::MeshStack.
*
@@ -89,7 +88,8 @@ public:
void Report (const ns3::Ptr<ns3::NetDevice>&, std::ostream&);
void ResetStats (const ns3::Ptr<ns3::NetDevice>&);
private:
bool m_spreadInterfaceChannels;
uint32_t m_nInterfaces;
ChannelPolicy m_spreadChannelPolicy;
Ptr<MeshStack> m_stack;
ObjectFactory m_stackFactory;
};