strawman connectors and channel
This commit is contained in:
1 parent
d04cfa6579
commit
11b1337054
6 files changed
+498
-23
No files matched your search
+27
-10
@@ -30,32 +30,49 @@ namespace ns3 {
|
||||
|
||||
Channel::Channel ()
|
||||
{
|
||||
NS_DEBUG ("Channel::Channel ()")
|
||||
NS_DEBUG("Channel::Channel ()")
|
||||
}
|
||||
|
||||
Channel::~Channel ()
|
||||
{
|
||||
NS_DEBUG ("Channel::~Channel ()")
|
||||
NS_DEBUG("Channel::~Channel ()")
|
||||
}
|
||||
|
||||
bool
|
||||
Channel::Connect (PhysicalLayer &phys)
|
||||
Channel::DoConnectToUpper (LayerConnectorUpper &upper)
|
||||
{
|
||||
NS_DEBUG ("Channel::Connect (" << &phys << ")")
|
||||
m_physList.push_back(static_cast<PhysicalLayer *>(&phys));
|
||||
NS_DEBUG("Channel::DoConnectToUpper (" << &upper << ")")
|
||||
m_connectorList.push_back(&upper);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
Channel::Propagate (Propagator &propagator)
|
||||
Channel::LowerDoNotify (LayerConnectorUpper *upper)
|
||||
{
|
||||
NS_DEBUG ("Channel::Propagate (" << &propagator << ")")
|
||||
NS_DEBUG("Channel::LowerDoNotify ()")
|
||||
|
||||
for (PhysicalLayerList::const_iterator i = m_physList.begin ();
|
||||
i != m_physList.end ();
|
||||
Packet p;
|
||||
|
||||
NS_DEBUG("Channel::LowerDoNotify (): Starting pull")
|
||||
|
||||
upper->UpperPull(p);
|
||||
|
||||
NS_DEBUG("Channel::LowerDoNotify (): Got bits, Propagate()")
|
||||
|
||||
return Propagate(p);
|
||||
}
|
||||
|
||||
bool
|
||||
Channel::Propagate (Packet &p)
|
||||
{
|
||||
NS_DEBUG("Channel::Propagate (" << &p << ")")
|
||||
|
||||
for (ConnectorList::const_iterator i = m_connectorList.begin ();
|
||||
i != m_connectorList.end ();
|
||||
i++)
|
||||
{
|
||||
(*i)->Receive (propagator);
|
||||
(*i)->UpperSendUp (p);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
+9
-12
@@ -22,36 +22,33 @@
|
||||
*/
|
||||
|
||||
#include <list>
|
||||
#include "physical-layer.h"
|
||||
#include "ns3/packet.h"
|
||||
#include "layer-connector.h"
|
||||
|
||||
#ifndef CHANNEL_H
|
||||
#define CHANNEL_H
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
class Propagator;
|
||||
|
||||
class Channel
|
||||
class Channel : public LayerConnectorLower
|
||||
{
|
||||
public:
|
||||
Channel ();
|
||||
virtual ~Channel ();
|
||||
|
||||
// called by the builderto introduce the channel and the physical layer
|
||||
// of the node.
|
||||
bool Connect (PhysicalLayer &phys);
|
||||
|
||||
// Called by the physical layer to cause bits to propagate along the channel
|
||||
// The channel will call Receive on each of the phys.
|
||||
bool Propagate (Propagator &p);
|
||||
bool Propagate (Packet &p);
|
||||
bool DoConnectToUpper (LayerConnectorUpper &upper);
|
||||
bool LowerDoNotify (LayerConnectorUpper *upper);
|
||||
|
||||
protected:
|
||||
typedef std::list<PhysicalLayer *> PhysicalLayerList;
|
||||
PhysicalLayerList m_physList;
|
||||
typedef std::list<LayerConnectorUpper *> ConnectorList;
|
||||
ConnectorList m_connectorList;
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
}; // namespace ns3
|
||||
|
||||
#endif /* SERIAL_PHY_H */
|
||||
#endif /* CHANNEL_H */
|
||||
@@ -0,0 +1,137 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2007 University of Washington
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Author: Craig Dowell <craigdo@ee.washingon.edu>
|
||||
*
|
||||
* Fri Feb 16 12:18:11 PST 2007 craigdo: created
|
||||
*/
|
||||
|
||||
#include "ns3/debug.h"
|
||||
#include "layer-connector.h"
|
||||
|
||||
NS_DEBUG_COMPONENT_DEFINE ("LayerConnector");
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
LayerConnectorUpper::LayerConnectorUpper ()
|
||||
{
|
||||
NS_DEBUG("LayerConnectorUpper::LayerConnectorUpper ()")
|
||||
}
|
||||
|
||||
LayerConnectorUpper::~LayerConnectorUpper ()
|
||||
{
|
||||
NS_DEBUG("LayerConnectorUpper::~LayerConnectorUpper ()")
|
||||
}
|
||||
|
||||
bool
|
||||
LayerConnectorUpper::ConnectToLower (LayerConnectorLower &partner)
|
||||
{
|
||||
NS_DEBUG("LayerConnectorUpper::ConnectToLower (" << &partner << ")")
|
||||
|
||||
return DoConnectToLower(partner);
|
||||
}
|
||||
|
||||
bool
|
||||
LayerConnectorUpper::DoConnectToLower (LayerConnectorLower &partner)
|
||||
{
|
||||
NS_DEBUG("LayerConnectorUpper::DoConnectToLower (" << &partner << ")")
|
||||
|
||||
m_lowerPartner = &partner;
|
||||
assert(m_lowerPartner);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
LayerConnectorUpper::UpperSendUp (Packet &p)
|
||||
{
|
||||
NS_DEBUG("LayerConnectorUpper::UpperSendUp (" << &p << ")")
|
||||
|
||||
return UpperDoSendUp(p);
|
||||
}
|
||||
|
||||
bool
|
||||
LayerConnectorUpper::UpperPull (Packet &p)
|
||||
{
|
||||
NS_DEBUG("LayerConnectorUpper::UpperPull (" << &p << ")")
|
||||
|
||||
return UpperDoPull(p);
|
||||
}
|
||||
|
||||
bool
|
||||
LayerConnectorUpper::UpperNotify ()
|
||||
{
|
||||
NS_DEBUG("LayerConnectorUpper::UpperNotify ()")
|
||||
|
||||
assert(m_lowerPartner);
|
||||
return m_lowerPartner->LowerNotify(this);
|
||||
}
|
||||
|
||||
LayerConnectorLower::LayerConnectorLower ()
|
||||
{
|
||||
NS_DEBUG("LayerConnectorLower::LayerConnectorLower ()")
|
||||
}
|
||||
|
||||
LayerConnectorLower::~LayerConnectorLower ()
|
||||
{
|
||||
NS_DEBUG("LayerConnectorLower::~LayerConnectorLower ()")
|
||||
}
|
||||
|
||||
bool
|
||||
LayerConnectorLower::ConnectToUpper (LayerConnectorUpper &partner)
|
||||
{
|
||||
NS_DEBUG("LayerConnectorLower::ConnectToUpper (" << &partner << ")")
|
||||
|
||||
return DoConnectToUpper(partner);
|
||||
}
|
||||
|
||||
bool
|
||||
LayerConnectorLower::DoConnectToUpper (LayerConnectorUpper &partner)
|
||||
{
|
||||
NS_DEBUG("LayerConnectorLower::DoConnectToUpper (" << &partner << ")")
|
||||
|
||||
m_upperPartner = &partner;
|
||||
assert(m_upperPartner);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
LayerConnectorLower::LowerSendUp (Packet &p)
|
||||
{
|
||||
NS_DEBUG("LayerConnectorLower::LowerSendUp (" << &p << ")")
|
||||
|
||||
assert(m_upperPartner);
|
||||
return m_upperPartner->UpperSendUp(p);
|
||||
}
|
||||
|
||||
bool
|
||||
LayerConnectorLower::LowerPull (Packet &p)
|
||||
{
|
||||
NS_DEBUG("LayerConnectorLower::LowerPull (" << &p << ")")
|
||||
|
||||
assert(m_upperPartner);
|
||||
return m_upperPartner->UpperPull(p);
|
||||
}
|
||||
|
||||
bool
|
||||
LayerConnectorLower::LowerNotify (LayerConnectorUpper *upper)
|
||||
{
|
||||
NS_DEBUG("LayerConnectorLower::LowerNotify ()")
|
||||
return LowerDoNotify(upper);
|
||||
}
|
||||
|
||||
} // namespace ns3
|
||||
@@ -0,0 +1,97 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2007 University of Washington
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Author: Craig Dowell <craigdo@ee.washingon.edu>
|
||||
*
|
||||
* Wed Feb 14 16:05:46 PST 2007 craigdo: created
|
||||
*/
|
||||
|
||||
#include "ns3/packet.h"
|
||||
|
||||
#ifndef LAYER_CONNECTOR_H
|
||||
#define LAYER_CONNECTOR_H
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
class LayerConnectorLower;
|
||||
|
||||
class LayerConnectorUpper {
|
||||
public:
|
||||
LayerConnectorUpper ();
|
||||
virtual ~LayerConnectorUpper ();
|
||||
|
||||
// called by the layer connector to introduce the lower interface to us here
|
||||
bool ConnectToLower (LayerConnectorLower &lower);
|
||||
|
||||
// called by the lower layer to send a received packet on up the protocol
|
||||
// stack to us here.
|
||||
bool UpperSendUp (Packet &p);
|
||||
|
||||
// Call this function to tell a lower layer that there is data available
|
||||
// here. It is expected that the lower layer will call pull as soon as
|
||||
// possible to get the data.
|
||||
bool UpperNotify ();
|
||||
|
||||
// called by the lower layer to get available packet data that was implied
|
||||
// by a previous Notify() call.
|
||||
bool UpperPull(Packet &p);
|
||||
|
||||
protected:
|
||||
virtual bool DoConnectToLower (LayerConnectorLower &lower);
|
||||
virtual bool UpperDoSendUp (Packet &p) = 0;
|
||||
virtual bool UpperDoPull (Packet &p) = 0;
|
||||
|
||||
LayerConnectorLower *m_lowerPartner;
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
class LayerConnectorLower
|
||||
{
|
||||
public:
|
||||
LayerConnectorLower ();
|
||||
virtual ~LayerConnectorLower ();
|
||||
|
||||
// This function is called by the layer connector to introduce the upper
|
||||
// layer interface to us here
|
||||
bool ConnectToUpper (LayerConnectorUpper &upper);
|
||||
|
||||
// Notify is called by the upper layer connector to tell us that there
|
||||
// is data available. It is expected that we will call pull (below) as
|
||||
// soon as possible to get the data.
|
||||
bool LowerNotify (LayerConnectorUpper *upper);
|
||||
|
||||
// The lower connector calls this method to send a received packet on up
|
||||
// the protocol stack
|
||||
bool LowerSendUp (Packet &p);
|
||||
|
||||
// Call this function to get available packet data from the upper connector
|
||||
// that was implied by a previous Notify() call.
|
||||
bool LowerPull(Packet &p);
|
||||
|
||||
protected:
|
||||
virtual bool DoConnectToUpper (LayerConnectorUpper &upper);
|
||||
virtual bool LowerDoNotify (LayerConnectorUpper *upper) = 0;
|
||||
LayerConnectorUpper *m_upperPartner;
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
}; // namespace ns3
|
||||
|
||||
#endif /* LAYER_CONNECTOR_H */
|
||||
Reference in new issue
Block a user