move serial code to src/devices/serial
--HG-- rename : src/node/channel.cc => src/devices/serial/channel.cc rename : src/node/channel.h => src/devices/serial/channel.h rename : src/node/layer-connector.cc => src/devices/serial/layer-connector.cc rename : src/node/layer-connector.h => src/devices/serial/layer-connector.h rename : src/node/propagator.h => src/devices/serial/propagator.h rename : src/node/serial-channel.cc => src/devices/serial/serial-channel.cc rename : src/node/serial-channel.h => src/devices/serial/serial-channel.h rename : src/node/serial-net-device.cc => src/devices/serial/serial-net-device.cc rename : src/node/serial-net-device.h => src/devices/serial/serial-net-device.h rename : src/node/serial-phy.cc => src/devices/serial/serial-phy.cc rename : src/node/serial-phy.h => src/devices/serial/serial-phy.h
This commit is contained in:
1 parent
9ec32873a1
commit
2be9fab00d
12 files changed
+30
-25
No files matched your search
@@ -1,81 +0,0 @@
|
||||
/* -*- 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>
|
||||
*
|
||||
* Thu Feb 15 14:50:46 PST 2007 craigdo: Created.
|
||||
*/
|
||||
|
||||
#include "ns3/debug.h"
|
||||
#include "channel.h"
|
||||
|
||||
NS_DEBUG_COMPONENT_DEFINE ("Channel");
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
Channel::Channel ()
|
||||
{
|
||||
NS_DEBUG("Channel::Channel ()");
|
||||
}
|
||||
|
||||
Channel::~Channel ()
|
||||
{
|
||||
NS_DEBUG("Channel::~Channel ()");
|
||||
}
|
||||
|
||||
bool
|
||||
Channel::DoConnectToUpper (LayerConnectorUpper &upper)
|
||||
{
|
||||
NS_DEBUG("Channel::DoConnectToUpper (" << &upper << ")");
|
||||
m_connectorList.push_back(&upper);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
Channel::LowerDoNotify (LayerConnectorUpper *upper)
|
||||
{
|
||||
NS_DEBUG("Channel::LowerDoNotify ()");
|
||||
|
||||
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)->UpperSendUp (p);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace ns3
|
||||
@@ -1,54 +0,0 @@
|
||||
/* -*- 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 <list>
|
||||
#include "ns3/packet.h"
|
||||
#include "layer-connector.h"
|
||||
|
||||
#ifndef CHANNEL_H
|
||||
#define CHANNEL_H
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
class Channel : public LayerConnectorLower
|
||||
{
|
||||
public:
|
||||
Channel ();
|
||||
virtual ~Channel ();
|
||||
|
||||
// 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 (Packet &p);
|
||||
bool DoConnectToUpper (LayerConnectorUpper &upper);
|
||||
bool LowerDoNotify (LayerConnectorUpper *upper);
|
||||
|
||||
protected:
|
||||
typedef std::list<LayerConnectorUpper *> ConnectorList;
|
||||
ConnectorList m_connectorList;
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
}; // namespace ns3
|
||||
|
||||
#endif /* CHANNEL_H */
|
||||
@@ -1,138 +0,0 @@
|
||||
/* -*- 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 "ns3/assert.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;
|
||||
NS_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 ()");
|
||||
|
||||
NS_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;
|
||||
NS_ASSERT (m_upperPartner);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
LayerConnectorLower::LowerSendUp (Packet &p)
|
||||
{
|
||||
NS_DEBUG("LayerConnectorLower::LowerSendUp (" << &p << ")");
|
||||
|
||||
NS_ASSERT (m_upperPartner);
|
||||
return m_upperPartner->UpperSendUp(p);
|
||||
}
|
||||
|
||||
bool
|
||||
LayerConnectorLower::LowerPull (Packet &p)
|
||||
{
|
||||
NS_DEBUG("LayerConnectorLower::LowerPull (" << &p << ")");
|
||||
|
||||
NS_ASSERT (m_upperPartner);
|
||||
return m_upperPartner->UpperPull(p);
|
||||
}
|
||||
|
||||
bool
|
||||
LayerConnectorLower::LowerNotify (LayerConnectorUpper *upper)
|
||||
{
|
||||
NS_DEBUG("LayerConnectorLower::LowerNotify ()");
|
||||
return LowerDoNotify(upper);
|
||||
}
|
||||
|
||||
} // namespace ns3
|
||||
@@ -1,97 +0,0 @@
|
||||
/* -*- 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 */
|
||||
@@ -1,49 +0,0 @@
|
||||
/* -*- 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>
|
||||
*
|
||||
* Thu Feb 15 15:06:15 PST 2007 craigdo: Created
|
||||
*/
|
||||
|
||||
#ifndef PROPAGATOR_H
|
||||
#define PROPAGATOR_H
|
||||
|
||||
#include "ns3/packet.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
class Propagator
|
||||
{
|
||||
public:
|
||||
Propagator () : m_packet(0) {}
|
||||
virtual ~Propagator () {}
|
||||
|
||||
void SetPacket (Packet &p) {DoSetPacket(p);}
|
||||
|
||||
protected:
|
||||
virtual void DoSetPacket (Packet &p) {m_packet = static_cast<Packet *>(&p);}
|
||||
|
||||
Packet *m_packet;
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
}; // namespace ns3
|
||||
|
||||
#endif /* SERIAL_PHY_H */
|
||||
@@ -1,45 +0,0 @@
|
||||
/* -*- 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
|
||||
*/
|
||||
|
||||
#include "serial-channel.h"
|
||||
#include "serial-net-device.h"
|
||||
#include "ns3/packet.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
void
|
||||
SerialChannel::Attach(SerialNetDevice* nd)
|
||||
{
|
||||
nd->Attach(this);
|
||||
m_devices.push_back (nd);
|
||||
}
|
||||
|
||||
bool
|
||||
SerialChannel::Send(Packet& p, SerialNetDevice* caller)
|
||||
{
|
||||
for (NetDevicesCI i = m_devices.begin (); i != m_devices.end (); i++) {
|
||||
if (caller != (*i)) {
|
||||
(*i)->Receive (p);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace ns3
|
||||
@@ -1,47 +0,0 @@
|
||||
/* -*- 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
|
||||
*/
|
||||
|
||||
// The queue base class does not have any limit based on the number
|
||||
// of packets or number of bytes. It is, conceptually, infinite
|
||||
// by default. Only subclasses define limitations.
|
||||
// The base class implements tracing and basic statistics calculations.
|
||||
|
||||
#ifndef CHANNEL_SERIAL_H
|
||||
#define CHANNEL_SERIAL_H
|
||||
|
||||
#include <list>
|
||||
#include "serial-net-device.h"
|
||||
#include "ns3/packet.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
// Simple SerialChannel class
|
||||
class SerialChannel {
|
||||
public:
|
||||
bool Send(Packet& p, SerialNetDevice *caller);
|
||||
void Attach (SerialNetDevice* nd);
|
||||
private:
|
||||
typedef std::list<SerialNetDevice *> NetDevices;
|
||||
typedef std::list<SerialNetDevice *>::const_iterator NetDevicesCI;
|
||||
NetDevices m_devices;
|
||||
};
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
#endif /* CHANNEL_SERIAL__H */
|
||||
@@ -1,146 +0,0 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2005,2006 INRIA
|
||||
* 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: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <cassert>
|
||||
#include "ns3/debug.h"
|
||||
#include "protocol.h"
|
||||
#include "demux.h"
|
||||
#include "queue.h"
|
||||
#include "serial-net-device.h"
|
||||
#include "serial-channel.h"
|
||||
#include "serial-phy.h"
|
||||
|
||||
NS_DEBUG_COMPONENT_DEFINE ("SerialNetDevice");
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
|
||||
SerialNetDevice::SerialNetDevice(Node* node, const MacAddress& addr) :
|
||||
NetDevice(node, addr)
|
||||
{
|
||||
NS_DEBUG ("SerialNetDevice::SerialNetDevice (" << node << ", " << &addr << ")");
|
||||
|
||||
// BUGBUG FIXME
|
||||
//
|
||||
// You _must_ support broadcast to get any sort of packet from the ARP layer.
|
||||
EnableBroadcast (MacAddress ("ff:ff:ff:ff:ff:ff"));
|
||||
EnableMulticast();
|
||||
EnablePointToPoint();
|
||||
SetMtu(512); // bytes
|
||||
|
||||
m_phy = new SerialPhy(node, this);
|
||||
}
|
||||
|
||||
SerialNetDevice::~SerialNetDevice()
|
||||
{
|
||||
NS_DEBUG ("SerialNetDevice::~SerialNetDevice ()");
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
SerialNetDevice::SendTo (Packet& p, const MacAddress& dest)
|
||||
{
|
||||
NS_DEBUG ("SerialNetDevice::SendTo (" << &p << ", " << &dest << ")");
|
||||
|
||||
assert (IsLinkUp ());
|
||||
|
||||
#ifdef NOTYET
|
||||
struct NetDevicePacketDestAddress tag;
|
||||
tag.address = address;
|
||||
p.AddTag (tag);
|
||||
#endif
|
||||
if (m_queue->Enque(p) )
|
||||
{
|
||||
NotifyDataAvailable ();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
SerialNetDevice::Attach (SerialChannel* ch)
|
||||
{
|
||||
NS_DEBUG ("SerialNetDevice::Attach (" << &ch << ")");
|
||||
|
||||
m_channel = ch;
|
||||
/*
|
||||
* For now, this device is up whenever a channel is attached to it.
|
||||
* In fact, it should become up only when the second device
|
||||
* is attached to the channel. So, there should be a way for
|
||||
* a SerialChannel to notify both of its attached devices
|
||||
* that the channel is 'complete', hence that the devices are
|
||||
* up, hence that they can call NotifyLinkUp.
|
||||
*/
|
||||
NotifyLinkUp ();
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
SerialNetDevice::AddQueue (Queue* q)
|
||||
{
|
||||
NS_DEBUG ("SerialNetDevice::AddQueue (" << q << ")");
|
||||
|
||||
m_queue = q;
|
||||
}
|
||||
|
||||
void
|
||||
SerialNetDevice::Receive (Packet& p)
|
||||
{
|
||||
// ignore return value for now.
|
||||
NS_DEBUG ("SerialNetDevice::Receive (" << &p << ")");
|
||||
|
||||
// Dispatch this to SerialPhy::Receive
|
||||
m_phy->Receive (p);
|
||||
}
|
||||
|
||||
void
|
||||
SerialNetDevice::NotifyDataAvailable(void)
|
||||
{
|
||||
NS_DEBUG ("SerialNetDevice::NotifyDataAvailable ()");
|
||||
|
||||
Packet p;
|
||||
bool found = GetQueue ()->Deque (p);
|
||||
if (found)
|
||||
{
|
||||
#ifdef NOTYET
|
||||
struct NetDevicePacketDestAddress tag;
|
||||
p.PeekTag (tag);
|
||||
// send packet to address tag.address
|
||||
#endif
|
||||
NS_DEBUG ("SerialNetDevice::NotifyDataAvailable (): Dequeued");
|
||||
m_channel->Send(p, this);
|
||||
}
|
||||
}
|
||||
|
||||
Queue*
|
||||
SerialNetDevice::GetQueue(void) const
|
||||
{
|
||||
return m_queue;
|
||||
}
|
||||
|
||||
SerialChannel*
|
||||
SerialNetDevice::GetChannel(void) const
|
||||
{
|
||||
return m_channel;
|
||||
}
|
||||
|
||||
} // namespace ns3
|
||||
@@ -1,72 +0,0 @@
|
||||
/* -*- 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.washington.edu>
|
||||
*/
|
||||
|
||||
#ifndef SERIAL_NET_DEVICE_H
|
||||
#define SERIAL_NET_DEVICE_H
|
||||
|
||||
#include <string.h>
|
||||
#include "mac-address.h"
|
||||
#include "internet-node.h"
|
||||
#include "net-device.h"
|
||||
#include "ns3/callback.h"
|
||||
#include "ns3/packet.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
class SerialChannel;
|
||||
class SerialPhy;
|
||||
class Queue;
|
||||
|
||||
class SerialNetDevice : public NetDevice {
|
||||
friend class SerialPhy;
|
||||
public:
|
||||
SerialNetDevice(Node* node, const MacAddress& addr);
|
||||
virtual ~SerialNetDevice();
|
||||
|
||||
private:
|
||||
// Don't let the compiler slip in copy and assignment construction
|
||||
SerialNetDevice(const SerialNetDevice&);
|
||||
SerialNetDevice&operator=(const SerialNetDevice&);
|
||||
|
||||
public:
|
||||
bool Attach(SerialChannel* ch);
|
||||
void AddQueue(Queue *);
|
||||
// called by ChannelSerial
|
||||
void Receive (Packet& p);
|
||||
|
||||
protected:
|
||||
Queue* GetQueue(void) const;
|
||||
SerialChannel* GetChannel(void) const;
|
||||
|
||||
private:
|
||||
virtual void NotifyDataAvailable (void);
|
||||
virtual bool SendTo (Packet& p, const MacAddress& dest);
|
||||
|
||||
SerialPhy* m_phy;
|
||||
SerialChannel* m_channel;
|
||||
Queue* m_queue;
|
||||
|
||||
};
|
||||
|
||||
}; // namespace ns3
|
||||
|
||||
#endif // SERIAL_NET_DEVICE_H
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2005,2006 INRIA
|
||||
* 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: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
|
||||
#include "ns3/debug.h"
|
||||
#include "serial-phy.h"
|
||||
#include "serial-net-device.h"
|
||||
#include "serial-channel.h"
|
||||
#include "queue.h"
|
||||
|
||||
NS_DEBUG_COMPONENT_DEFINE ("SerialPhy");
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
SerialPhy::SerialPhy(Node* node, SerialNetDevice* netdevice) :
|
||||
m_node(node), m_netdevice(netdevice)
|
||||
{
|
||||
NS_DEBUG ("SerialPhy::SerialPhy (" << node << ", " << netdevice << ")");
|
||||
}
|
||||
|
||||
SerialPhy::~SerialPhy()
|
||||
{
|
||||
NS_DEBUG ("SerialPhy::~SerialPhy ()");
|
||||
}
|
||||
|
||||
void
|
||||
SerialPhy::NotifyDataAvailable(void)
|
||||
{
|
||||
NS_DEBUG ("SerialPhy::NotifyDataAvailable ()");
|
||||
|
||||
Packet p;
|
||||
bool found = m_netdevice->GetQueue ()->Deque (p);
|
||||
if (found)
|
||||
{
|
||||
#ifdef NOTYET
|
||||
struct NetDevicePacketDestAddress tag;
|
||||
p.PeekTag (tag);
|
||||
// send packet to address tag.address
|
||||
#endif
|
||||
NS_DEBUG ("SerialPhy::NotifyDataAvailable (): Dequeued");
|
||||
m_netdevice->GetChannel()->Send(p, m_netdevice);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SerialPhy::Receive (Packet& p)
|
||||
{
|
||||
NS_DEBUG ("SerialPhy::Receive (" << &p << ")");
|
||||
|
||||
m_netdevice->ForwardUp (p);
|
||||
}
|
||||
|
||||
} // namespace ns3
|
||||
@@ -1,46 +0,0 @@
|
||||
/* -*- 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.washington.edu>
|
||||
*/
|
||||
|
||||
#ifndef SERIAL_PHY_H
|
||||
#define SERIAL_PHY_H
|
||||
|
||||
#include <string.h>
|
||||
#include "internet-node.h"
|
||||
#include "serial-net-device.h"
|
||||
#include "ns3/packet.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
class SerialPhy {
|
||||
public:
|
||||
SerialPhy(Node* node, SerialNetDevice* netdevice);
|
||||
virtual ~SerialPhy();
|
||||
virtual void NotifyDataAvailable (void);
|
||||
void Receive (Packet& p);
|
||||
|
||||
private:
|
||||
Node* m_node;
|
||||
SerialNetDevice* m_netdevice;
|
||||
};
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
#endif // SERIAL_PHY_H
|
||||
Reference in new issue
Block a user