merge
This commit is contained in:
@@ -49,7 +49,7 @@
|
||||
#include "ns3/csma-net-device.h"
|
||||
#include "ns3/csma-topology.h"
|
||||
#include "ns3/csma-ipv4-topology.h"
|
||||
#include "ns3/eui48-address.h"
|
||||
#include "ns3/mac48-address.h"
|
||||
#include "ns3/ipv4-address.h"
|
||||
#include "ns3/inet-socket-address.h"
|
||||
#include "ns3/ipv4.h"
|
||||
@@ -115,13 +115,13 @@ int main (int argc, char *argv[])
|
||||
DataRate(5000000), MilliSeconds(2));
|
||||
|
||||
uint32_t n0ifIndex0 = CsmaIpv4Topology::AddIpv4CsmaNetDevice (n0, channel0,
|
||||
Eui48Address("10:54:23:54:0:50"));
|
||||
Mac48Address("10:54:23:54:0:50"));
|
||||
uint32_t n0ifIndex1 = CsmaIpv4Topology::AddIpv4CsmaNetDevice (n0, channel1,
|
||||
Eui48Address("10:54:23:54:0:51"));
|
||||
Mac48Address("10:54:23:54:0:51"));
|
||||
uint32_t n1ifIndex = CsmaIpv4Topology::AddIpv4CsmaNetDevice (n1, channel0,
|
||||
Eui48Address("10:54:23:54:23:51"));
|
||||
Mac48Address("10:54:23:54:23:51"));
|
||||
uint32_t n2ifIndex = CsmaIpv4Topology::AddIpv4CsmaNetDevice (n2, channel1,
|
||||
Eui48Address("10:54:23:54:23:52"));
|
||||
Mac48Address("10:54:23:54:23:52"));
|
||||
|
||||
// Later, we add IP addresses.
|
||||
CsmaIpv4Topology::AddIpv4Address (
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
#include "ns3/csma-net-device.h"
|
||||
#include "ns3/csma-topology.h"
|
||||
#include "ns3/csma-ipv4-topology.h"
|
||||
#include "ns3/eui48-address.h"
|
||||
#include "ns3/mac48-address.h"
|
||||
#include "ns3/ipv4-address.h"
|
||||
#include "ns3/inet-socket-address.h"
|
||||
#include "ns3/ipv4.h"
|
||||
@@ -129,19 +129,19 @@ main (int argc, char *argv[])
|
||||
// connect to Lan0.
|
||||
//
|
||||
uint32_t nd0 = CsmaIpv4Topology::AddIpv4CsmaNetDevice (n0, lan0,
|
||||
Eui48Address("08:00:2e:00:00:00"));
|
||||
Mac48Address("08:00:2e:00:00:00"));
|
||||
uint32_t nd1 = CsmaIpv4Topology::AddIpv4CsmaNetDevice (n1, lan0,
|
||||
Eui48Address("08:00:2e:00:00:01"));
|
||||
Mac48Address("08:00:2e:00:00:01"));
|
||||
uint32_t nd2Lan0 = CsmaIpv4Topology::AddIpv4CsmaNetDevice (n2, lan0,
|
||||
Eui48Address("08:00:2e:00:00:02"));
|
||||
Mac48Address("08:00:2e:00:00:02"));
|
||||
|
||||
uint32_t nd2Lan1 = CsmaIpv4Topology::AddIpv4CsmaNetDevice (n2, lan1,
|
||||
Eui48Address("08:00:2e:00:00:03"));
|
||||
Mac48Address("08:00:2e:00:00:03"));
|
||||
uint32_t nd3 __attribute__ ((unused)) =
|
||||
CsmaIpv4Topology::AddIpv4CsmaNetDevice (n3, lan1,
|
||||
Eui48Address("08:00:2e:00:00:04"));
|
||||
Mac48Address("08:00:2e:00:00:04"));
|
||||
uint32_t nd4 = CsmaIpv4Topology::AddIpv4CsmaNetDevice (n4, lan1,
|
||||
Eui48Address("08:00:2e:00:00:05"));
|
||||
Mac48Address("08:00:2e:00:00:05"));
|
||||
|
||||
NS_DEBUG ("nd0 = " << nd0);
|
||||
NS_DEBUG ("nd1 = " << nd1);
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
#include "ns3/csma-net-device.h"
|
||||
#include "ns3/csma-topology.h"
|
||||
#include "ns3/csma-ipv4-topology.h"
|
||||
#include "ns3/eui48-address.h"
|
||||
#include "ns3/mac48-address.h"
|
||||
#include "ns3/ipv4-address.h"
|
||||
#include "ns3/inet-socket-address.h"
|
||||
#include "ns3/ipv4.h"
|
||||
@@ -119,16 +119,16 @@ main (int argc, char *argv[])
|
||||
// zero.
|
||||
//
|
||||
uint32_t nd0 = CsmaIpv4Topology::AddIpv4CsmaNetDevice (n0, lan,
|
||||
Eui48Address("08:00:2e:00:00:00"));
|
||||
Mac48Address("08:00:2e:00:00:00"));
|
||||
|
||||
uint32_t nd1 = CsmaIpv4Topology::AddIpv4CsmaNetDevice (n1, lan,
|
||||
Eui48Address("08:00:2e:00:00:01"));
|
||||
Mac48Address("08:00:2e:00:00:01"));
|
||||
|
||||
uint32_t nd2 = CsmaIpv4Topology::AddIpv4CsmaNetDevice (n2, lan,
|
||||
Eui48Address("08:00:2e:00:00:02"));
|
||||
Mac48Address("08:00:2e:00:00:02"));
|
||||
|
||||
uint32_t nd3 = CsmaIpv4Topology::AddIpv4CsmaNetDevice (n3, lan,
|
||||
Eui48Address("08:00:2e:00:00:03"));
|
||||
Mac48Address("08:00:2e:00:00:03"));
|
||||
|
||||
NS_DEBUG ("nd0 = " << nd0);
|
||||
NS_DEBUG ("nd1 = " << nd1);
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
#include "ns3/internet-node.h"
|
||||
#include "ns3/csma-channel.h"
|
||||
#include "ns3/csma-net-device.h"
|
||||
#include "ns3/eui48-address.h"
|
||||
#include "ns3/mac48-address.h"
|
||||
#include "ns3/packet-socket-address.h"
|
||||
#include "ns3/socket.h"
|
||||
#include "ns3/onoff-application.h"
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
#include "ns3/csma-net-device.h"
|
||||
#include "ns3/csma-topology.h"
|
||||
#include "ns3/csma-ipv4-topology.h"
|
||||
#include "ns3/eui48-address.h"
|
||||
#include "ns3/mac48-address.h"
|
||||
#include "ns3/ipv4-address.h"
|
||||
#include "ns3/ipv4.h"
|
||||
#include "ns3/socket.h"
|
||||
@@ -129,13 +129,13 @@ int main (int argc, char *argv[])
|
||||
DataRate(5000000), MilliSeconds(2));
|
||||
|
||||
uint32_t n2ifIndex = CsmaIpv4Topology::AddIpv4CsmaNetDevice (n2, channelc0,
|
||||
Eui48Address("10:54:23:54:23:50"));
|
||||
Mac48Address("10:54:23:54:23:50"));
|
||||
uint32_t n3ifIndex = CsmaIpv4Topology::AddIpv4CsmaNetDevice (n3, channelc0,
|
||||
Eui48Address("10:54:23:54:23:51"));
|
||||
Mac48Address("10:54:23:54:23:51"));
|
||||
uint32_t n4ifIndex = CsmaIpv4Topology::AddIpv4CsmaNetDevice (n4, channelc0,
|
||||
Eui48Address("10:54:23:54:23:52"));
|
||||
Mac48Address("10:54:23:54:23:52"));
|
||||
uint32_t n5ifIndex = CsmaIpv4Topology::AddIpv4CsmaNetDevice (n5, channelc0,
|
||||
Eui48Address("10:54:23:54:23:53"));
|
||||
Mac48Address("10:54:23:54:23:53"));
|
||||
|
||||
// Later, we add IP addresses.
|
||||
PointToPointTopology::AddIpv4Addresses (
|
||||
|
||||
@@ -64,7 +64,7 @@
|
||||
|
||||
using namespace ns3;
|
||||
|
||||
NS_DEBUG_COMPONENT_DEFINE ("Me");
|
||||
NS_DEBUG_COMPONENT_DEFINE ("SimplePointToPoint");
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
@@ -74,7 +74,7 @@ main (int argc, char *argv[])
|
||||
// for selected modules; the below lines suggest how to do this
|
||||
// remember to add #include "ns3/debug.h" before enabling these
|
||||
#if 0
|
||||
DebugComponentEnable("Me");
|
||||
DebugComponentEnable("SimplePointToPoint");
|
||||
DebugComponentEnable("Object");
|
||||
DebugComponentEnable("Queue");
|
||||
DebugComponentEnable("DropTailQueue");
|
||||
|
||||
@@ -38,7 +38,7 @@ uint32_t
|
||||
CsmaIpv4Topology::AddIpv4CsmaNetDevice(
|
||||
Ptr<Node> node,
|
||||
Ptr<CsmaChannel> channel,
|
||||
Eui48Address addr)
|
||||
Mac48Address addr)
|
||||
{
|
||||
Ptr<Queue> q = Queue::CreateDefault ();
|
||||
|
||||
@@ -55,7 +55,7 @@ CsmaIpv4Topology::AddIpv4CsmaNetDevice(
|
||||
void
|
||||
CsmaIpv4Topology::AddIpv4LlcCsmaNode(Ptr<Node> n1,
|
||||
Ptr<CsmaChannel> ch,
|
||||
Eui48Address addr)
|
||||
Mac48Address addr)
|
||||
{
|
||||
Ptr<Queue> q = Queue::CreateDefault ();
|
||||
|
||||
@@ -75,7 +75,7 @@ CsmaIpv4Topology::AddIpv4LlcCsmaNode(Ptr<Node> n1,
|
||||
void
|
||||
CsmaIpv4Topology::AddIpv4RawCsmaNode(Ptr<Node> n1,
|
||||
Ptr<CsmaChannel> ch,
|
||||
Eui48Address addr)
|
||||
Mac48Address addr)
|
||||
{
|
||||
Ptr<Queue> q = Queue::CreateDefault ();
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ public:
|
||||
*/
|
||||
static uint32_t AddIpv4CsmaNetDevice(Ptr<Node> node,
|
||||
Ptr<CsmaChannel> channel,
|
||||
Eui48Address addr);
|
||||
Mac48Address addr);
|
||||
|
||||
/**
|
||||
* \param n1 Node to be attached to the Csma channel
|
||||
@@ -76,7 +76,7 @@ public:
|
||||
*/
|
||||
static void AddIpv4RawCsmaNode( Ptr<Node> n1,
|
||||
Ptr<CsmaChannel> ch,
|
||||
Eui48Address addr);
|
||||
Mac48Address addr);
|
||||
|
||||
/**
|
||||
* \param n1 Node to be attached to the Csma channel
|
||||
@@ -89,7 +89,7 @@ public:
|
||||
*/
|
||||
static void AddIpv4LlcCsmaNode( Ptr<Node> n1,
|
||||
Ptr<CsmaChannel> ch,
|
||||
Eui48Address addr);
|
||||
Mac48Address addr);
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ CsmaTraceType::Get (void) const
|
||||
}
|
||||
|
||||
CsmaNetDevice::CsmaNetDevice (Ptr<Node> node)
|
||||
: NetDevice (node, Eui48Address::Allocate ()),
|
||||
: NetDevice (node, Mac48Address::Allocate ()),
|
||||
m_bps (DataRate (0xffffffff))
|
||||
{
|
||||
NS_DEBUG ("CsmaNetDevice::CsmaNetDevice (" << node << ")");
|
||||
@@ -77,7 +77,7 @@ CsmaNetDevice::CsmaNetDevice (Ptr<Node> node)
|
||||
Init(true, true);
|
||||
}
|
||||
|
||||
CsmaNetDevice::CsmaNetDevice (Ptr<Node> node, Eui48Address addr,
|
||||
CsmaNetDevice::CsmaNetDevice (Ptr<Node> node, Mac48Address addr,
|
||||
CsmaEncapsulationMode encapMode)
|
||||
: NetDevice(node, addr),
|
||||
m_bps (DataRate (0xffffffff))
|
||||
@@ -88,7 +88,7 @@ CsmaNetDevice::CsmaNetDevice (Ptr<Node> node, Eui48Address addr,
|
||||
Init(true, true);
|
||||
}
|
||||
|
||||
CsmaNetDevice::CsmaNetDevice (Ptr<Node> node, Eui48Address addr,
|
||||
CsmaNetDevice::CsmaNetDevice (Ptr<Node> node, Mac48Address addr,
|
||||
CsmaEncapsulationMode encapMode,
|
||||
bool sendEnable, bool receiveEnable)
|
||||
: NetDevice(node, addr),
|
||||
@@ -138,8 +138,8 @@ CsmaNetDevice::Init(bool sendEnable, bool receiveEnable)
|
||||
m_channel = 0;
|
||||
m_queue = 0;
|
||||
|
||||
EnableBroadcast (Eui48Address ("ff:ff:ff:ff:ff:ff"));
|
||||
EnableMulticast (Eui48Address ("01:00:5e:00:00:00"));
|
||||
EnableBroadcast (Mac48Address ("ff:ff:ff:ff:ff:ff"));
|
||||
EnableMulticast (Mac48Address ("01:00:5e:00:00:00"));
|
||||
|
||||
SetSendEnable (sendEnable);
|
||||
SetReceiveEnable (receiveEnable);
|
||||
@@ -192,7 +192,7 @@ CsmaNetDevice::SetBackoffParams (Time slotTime, uint32_t minSlots,
|
||||
m_backoff.m_maxRetries = maxRetries;
|
||||
}
|
||||
void
|
||||
CsmaNetDevice::AddHeader (Packet& p, Eui48Address dest,
|
||||
CsmaNetDevice::AddHeader (Packet& p, Mac48Address dest,
|
||||
uint16_t protocolNumber)
|
||||
{
|
||||
if (m_encapMode == RAW)
|
||||
@@ -201,7 +201,7 @@ CsmaNetDevice::AddHeader (Packet& p, Eui48Address dest,
|
||||
}
|
||||
EthernetHeader header (false);
|
||||
EthernetTrailer trailer;
|
||||
Eui48Address source = Eui48Address::ConvertFrom (GetAddress ());
|
||||
Mac48Address source = Mac48Address::ConvertFrom (GetAddress ());
|
||||
header.SetSource(source);
|
||||
header.SetDestination(dest);
|
||||
|
||||
@@ -295,7 +295,7 @@ CsmaNetDevice::SendTo (
|
||||
if (!IsSendEnabled())
|
||||
return false;
|
||||
|
||||
Eui48Address destination = Eui48Address::ConvertFrom (dest);
|
||||
Mac48Address destination = Mac48Address::ConvertFrom (dest);
|
||||
AddHeader(p, destination, protocolNumber);
|
||||
|
||||
// Place the packet to be sent on the send queue
|
||||
@@ -509,9 +509,9 @@ CsmaNetDevice::Receive (const Packet& packet)
|
||||
{
|
||||
EthernetHeader header (false);
|
||||
EthernetTrailer trailer;
|
||||
Eui48Address broadcast;
|
||||
Eui48Address multicast;
|
||||
Eui48Address destination;
|
||||
Mac48Address broadcast;
|
||||
Mac48Address multicast;
|
||||
Mac48Address destination;
|
||||
Packet p = packet;
|
||||
|
||||
NS_DEBUG ("CsmaNetDevice::Receive (): UID is " << p.GetUid());
|
||||
@@ -543,7 +543,7 @@ CsmaNetDevice::Receive (const Packet& packet)
|
||||
// We are going to receive all packets destined to any multicast address,
|
||||
// which means clearing the low-order 23 bits the header destination
|
||||
//
|
||||
Eui48Address mcDest;
|
||||
Mac48Address mcDest;
|
||||
uint8_t mcBuf[6];
|
||||
|
||||
header.GetDestination ().CopyTo (mcBuf);
|
||||
@@ -552,9 +552,9 @@ CsmaNetDevice::Receive (const Packet& packet)
|
||||
mcBuf[5] = 0;
|
||||
mcDest.CopyFrom (mcBuf);
|
||||
|
||||
multicast = Eui48Address::ConvertFrom (GetMulticast ());
|
||||
broadcast = Eui48Address::ConvertFrom (GetBroadcast ());
|
||||
destination = Eui48Address::ConvertFrom (GetAddress ());
|
||||
multicast = Mac48Address::ConvertFrom (GetMulticast ());
|
||||
broadcast = Mac48Address::ConvertFrom (GetBroadcast ());
|
||||
destination = Mac48Address::ConvertFrom (GetAddress ());
|
||||
|
||||
if ((header.GetDestination () != broadcast) &&
|
||||
(mcDest != multicast) &&
|
||||
@@ -609,7 +609,7 @@ CsmaNetDevice::MakeMulticastAddress(Ipv4Address multicastGroup) const
|
||||
// primarily since we know that by construction, but also since the parameter
|
||||
// is an Ipv4Address.
|
||||
//
|
||||
Eui48Address etherAddr = Eui48Address::ConvertFrom (hardwareDestination);
|
||||
Mac48Address etherAddr = Mac48Address::ConvertFrom (hardwareDestination);
|
||||
//
|
||||
// We now have the multicast address in an abstract 48-bit container. We
|
||||
// need to pull it out so we can play with it. When we're done, we have the
|
||||
@@ -633,11 +633,11 @@ CsmaNetDevice::MakeMulticastAddress(Ipv4Address multicastGroup) const
|
||||
etherBuffer[5] = ipBuffer[3];
|
||||
//
|
||||
// Now, etherBuffer has the desired ethernet multicast address. We have to
|
||||
// suck these bits back into the Eui48Address,
|
||||
// suck these bits back into the Mac48Address,
|
||||
//
|
||||
etherAddr.CopyFrom (etherBuffer);
|
||||
//
|
||||
// Implicit conversion (operator Address ()) is defined for Eui48Address, so
|
||||
// Implicit conversion (operator Address ()) is defined for Mac48Address, so
|
||||
// use it by just returning the EUI-48 address which is automagically converted
|
||||
// to an Address.
|
||||
//
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
#include "ns3/data-rate.h"
|
||||
#include "ns3/ptr.h"
|
||||
#include "ns3/random-variable.h"
|
||||
#include "ns3/eui48-address.h"
|
||||
#include "ns3/mac48-address.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
@@ -109,7 +109,7 @@ enum CsmaEncapsulationMode {
|
||||
* \param addr The source MAC address of the net device.
|
||||
* \param pktType the type of encapsulation
|
||||
*/
|
||||
CsmaNetDevice (Ptr<Node> node, Eui48Address addr, CsmaEncapsulationMode pktType);
|
||||
CsmaNetDevice (Ptr<Node> node, Mac48Address addr, CsmaEncapsulationMode pktType);
|
||||
|
||||
/**
|
||||
* Construct a CsmaNetDevice
|
||||
@@ -124,7 +124,7 @@ enum CsmaEncapsulationMode {
|
||||
* \param sendEnable whether this device is able to send
|
||||
* \param receiveEnable whether this device is able to receive
|
||||
*/
|
||||
CsmaNetDevice (Ptr<Node> node, Eui48Address addr,
|
||||
CsmaNetDevice (Ptr<Node> node, Mac48Address addr,
|
||||
CsmaEncapsulationMode pktType,
|
||||
bool sendEnable, bool receiveEnable);
|
||||
/**
|
||||
@@ -231,7 +231,7 @@ enum CsmaEncapsulationMode {
|
||||
* multicast group.
|
||||
*
|
||||
* @see Ipv4Address
|
||||
* @see Eui48Address
|
||||
* @see Mac48Address
|
||||
* @see Address
|
||||
*/
|
||||
Address MakeMulticastAddress (Ipv4Address multicastGroup) const;
|
||||
@@ -279,7 +279,7 @@ protected:
|
||||
* \param protocolNumber In some protocols, identifies the type of
|
||||
* payload contained in this packet.
|
||||
*/
|
||||
void AddHeader (Packet& p, Eui48Address dest,
|
||||
void AddHeader (Packet& p, Mac48Address dest,
|
||||
uint16_t protocolNumber);
|
||||
/**
|
||||
* Removes, from a packet of data, all headers and trailers that
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#include "ns3/queue.h"
|
||||
#include "ns3/simulator.h"
|
||||
#include "ns3/composite-trace-resolver.h"
|
||||
#include "ns3/eui48-address.h"
|
||||
#include "ns3/mac48-address.h"
|
||||
#include "ns3/llc-snap-header.h"
|
||||
#include "point-to-point-net-device.h"
|
||||
#include "point-to-point-channel.h"
|
||||
@@ -61,7 +61,7 @@ PointToPointTraceType::GetTypeName (void) const
|
||||
PointToPointNetDevice::PointToPointNetDevice (Ptr<Node> node,
|
||||
const DataRate& rate)
|
||||
:
|
||||
NetDevice(node, Eui48Address::Allocate ()),
|
||||
NetDevice(node, Mac48Address::Allocate ()),
|
||||
m_txMachineState (READY),
|
||||
m_bps (rate),
|
||||
m_tInterframeGap (Seconds(0)),
|
||||
@@ -74,11 +74,11 @@ PointToPointNetDevice::PointToPointNetDevice (Ptr<Node> node,
|
||||
// BUGBUG FIXME
|
||||
//
|
||||
// You _must_ support broadcast to get any sort of packet from the ARP layer.
|
||||
EnableBroadcast (Eui48Address ("ff:ff:ff:ff:ff:ff"));
|
||||
EnableBroadcast (Mac48Address ("ff:ff:ff:ff:ff:ff"));
|
||||
//
|
||||
// We want to allow multicast packets to flow across this link
|
||||
//
|
||||
EnableMulticast (Eui48Address ("01:00:5e:00:00:00"));
|
||||
EnableMulticast (Mac48Address ("01:00:5e:00:00:00"));
|
||||
EnablePointToPoint();
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
#include "ipv4-interface.h"
|
||||
#include "ns3/ptr.h"
|
||||
#include "ns3/eui48-address.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include "ns3/debug.h"
|
||||
#include "ns3/net-device.h"
|
||||
#include "ns3/node.h"
|
||||
#include "ns3/eui48-address.h"
|
||||
#include "ns3/mac48-address.h"
|
||||
#include "ipv4-loopback-interface.h"
|
||||
#include "ipv4-l3-protocol.h"
|
||||
|
||||
@@ -52,8 +52,8 @@ Ipv4LoopbackInterface::SendTo (Packet packet, Ipv4Address dest)
|
||||
Ptr<Ipv4L3Protocol> ipv4 =
|
||||
m_node->QueryInterface<Ipv4L3Protocol> (Ipv4L3Protocol::iid);
|
||||
|
||||
ipv4->Receive (GetDevice (), packet, Ipv4L3Protocol::PROT_NUMBER,
|
||||
Eui48Address ("ff:ff:ff:ff:ff:ff"));
|
||||
ipv4->Receive (0, packet, Ipv4L3Protocol::PROT_NUMBER,
|
||||
Mac48Address ("ff:ff:ff:ff:ff:ff"));
|
||||
}
|
||||
|
||||
}//namespace ns3
|
||||
|
||||
@@ -32,7 +32,7 @@ void WriteTo (Buffer::Iterator &i, const Address &ad)
|
||||
ad.CopyTo (mac);
|
||||
i.Write (mac, ad.GetLength ());
|
||||
}
|
||||
void WriteTo (Buffer::Iterator &i, Eui48Address ad)
|
||||
void WriteTo (Buffer::Iterator &i, Mac48Address ad)
|
||||
{
|
||||
uint8_t mac[6];
|
||||
ad.CopyTo (mac);
|
||||
@@ -49,7 +49,7 @@ void ReadFrom (Buffer::Iterator &i, Address &ad, uint32_t len)
|
||||
i.Read (mac, len);
|
||||
ad.CopyFrom (mac, len);
|
||||
}
|
||||
void ReadFrom (Buffer::Iterator &i, Eui48Address &ad)
|
||||
void ReadFrom (Buffer::Iterator &i, Mac48Address &ad)
|
||||
{
|
||||
uint8_t mac[6];
|
||||
i.Read (mac, 6);
|
||||
|
||||
@@ -24,17 +24,17 @@
|
||||
#include "ns3/buffer.h"
|
||||
#include "ipv4-address.h"
|
||||
#include "address.h"
|
||||
#include "eui48-address.h"
|
||||
#include "mac48-address.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
void WriteTo (Buffer::Iterator &i, Ipv4Address ad);
|
||||
void WriteTo (Buffer::Iterator &i, const Address &ad);
|
||||
void WriteTo (Buffer::Iterator &i, Eui48Address ad);
|
||||
void WriteTo (Buffer::Iterator &i, Mac48Address ad);
|
||||
|
||||
void ReadFrom (Buffer::Iterator &i, Ipv4Address &ad);
|
||||
void ReadFrom (Buffer::Iterator &i, Address &ad, uint32_t len);
|
||||
void ReadFrom (Buffer::Iterator &i, Eui48Address &ad);
|
||||
void ReadFrom (Buffer::Iterator &i, Mac48Address &ad);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -73,22 +73,22 @@ EthernetHeader::GetPreambleSfd (void) const
|
||||
}
|
||||
|
||||
void
|
||||
EthernetHeader::SetSource (Eui48Address source)
|
||||
EthernetHeader::SetSource (Mac48Address source)
|
||||
{
|
||||
m_source = source;
|
||||
}
|
||||
Eui48Address
|
||||
Mac48Address
|
||||
EthernetHeader::GetSource (void) const
|
||||
{
|
||||
return m_source;
|
||||
}
|
||||
|
||||
void
|
||||
EthernetHeader::SetDestination (Eui48Address dst)
|
||||
EthernetHeader::SetDestination (Mac48Address dst)
|
||||
{
|
||||
m_destination = dst;
|
||||
}
|
||||
Eui48Address
|
||||
Mac48Address
|
||||
EthernetHeader::GetDestination (void) const
|
||||
{
|
||||
return m_destination;
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
#include "ns3/header.h"
|
||||
#include <string>
|
||||
#include "ns3/eui48-address.h"
|
||||
#include "ns3/mac48-address.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
@@ -69,11 +69,11 @@ public:
|
||||
/**
|
||||
* \param source The source address of this packet
|
||||
*/
|
||||
void SetSource (Eui48Address source);
|
||||
void SetSource (Mac48Address source);
|
||||
/**
|
||||
* \param destination The destination address of this packet.
|
||||
*/
|
||||
void SetDestination (Eui48Address destination);
|
||||
void SetDestination (Mac48Address destination);
|
||||
/**
|
||||
* \param preambleSfd The value that the preambleSfd field should take
|
||||
*/
|
||||
@@ -89,11 +89,11 @@ public:
|
||||
/**
|
||||
* \return The source address of this packet
|
||||
*/
|
||||
Eui48Address GetSource (void) const;
|
||||
Mac48Address GetSource (void) const;
|
||||
/**
|
||||
* \return The destination address of this packet
|
||||
*/
|
||||
Eui48Address GetDestination (void) const;
|
||||
Mac48Address GetDestination (void) const;
|
||||
/**
|
||||
* \return The value of the PreambleSfd field
|
||||
*/
|
||||
@@ -119,8 +119,8 @@ private:
|
||||
bool m_enPreambleSfd;
|
||||
uint64_t m_preambleSfd; /// Value of the Preamble/SFD fields
|
||||
uint16_t m_lengthType; /// Length or type of the packet
|
||||
Eui48Address m_source; /// Source address
|
||||
Eui48Address m_destination; /// Destination address
|
||||
Mac48Address m_source; /// Source address
|
||||
Mac48Address m_destination; /// Destination address
|
||||
};
|
||||
|
||||
}; // namespace ns3
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
#include "eui48-address.h"
|
||||
#include "mac48-address.h"
|
||||
#include "address.h"
|
||||
#include "ns3/assert.h"
|
||||
#include <iomanip>
|
||||
@@ -45,11 +45,11 @@ AsciiToLowCase (char c)
|
||||
}
|
||||
|
||||
|
||||
Eui48Address::Eui48Address ()
|
||||
Mac48Address::Mac48Address ()
|
||||
{
|
||||
memset (m_address, 0, 6);
|
||||
}
|
||||
Eui48Address::Eui48Address (const char *str)
|
||||
Mac48Address::Mac48Address (const char *str)
|
||||
{
|
||||
int i = 0;
|
||||
while (*str != 0 && i < 6)
|
||||
@@ -80,44 +80,44 @@ Eui48Address::Eui48Address (const char *str)
|
||||
NS_ASSERT (i == 6);
|
||||
}
|
||||
void
|
||||
Eui48Address::CopyFrom (const uint8_t buffer[6])
|
||||
Mac48Address::CopyFrom (const uint8_t buffer[6])
|
||||
{
|
||||
memcpy (m_address, buffer, 6);
|
||||
}
|
||||
void
|
||||
Eui48Address::CopyTo (uint8_t buffer[6]) const
|
||||
Mac48Address::CopyTo (uint8_t buffer[6]) const
|
||||
{
|
||||
memcpy (buffer, m_address, 6);
|
||||
}
|
||||
|
||||
bool
|
||||
Eui48Address::IsMatchingType (const Address &address)
|
||||
Mac48Address::IsMatchingType (const Address &address)
|
||||
{
|
||||
return address.CheckCompatible (GetType (), 6);
|
||||
}
|
||||
Eui48Address::operator Address ()
|
||||
Mac48Address::operator Address ()
|
||||
{
|
||||
return ConvertTo ();
|
||||
}
|
||||
Address
|
||||
Eui48Address::ConvertTo (void) const
|
||||
Mac48Address::ConvertTo (void) const
|
||||
{
|
||||
return Address (GetType (), m_address, 6);
|
||||
}
|
||||
Eui48Address
|
||||
Eui48Address::ConvertFrom (const Address &address)
|
||||
Mac48Address
|
||||
Mac48Address::ConvertFrom (const Address &address)
|
||||
{
|
||||
NS_ASSERT (address.CheckCompatible (GetType (), 6));
|
||||
Eui48Address retval;
|
||||
Mac48Address retval;
|
||||
address.CopyTo (retval.m_address);
|
||||
return retval;
|
||||
}
|
||||
Eui48Address
|
||||
Eui48Address::Allocate (void)
|
||||
Mac48Address
|
||||
Mac48Address::Allocate (void)
|
||||
{
|
||||
static uint64_t id = 0;
|
||||
id++;
|
||||
Eui48Address address;
|
||||
Mac48Address address;
|
||||
address.m_address[0] = (id >> 40) & 0xff;
|
||||
address.m_address[1] = (id >> 32) & 0xff;
|
||||
address.m_address[2] = (id >> 24) & 0xff;
|
||||
@@ -127,13 +127,13 @@ Eui48Address::Allocate (void)
|
||||
return address;
|
||||
}
|
||||
uint8_t
|
||||
Eui48Address::GetType (void)
|
||||
Mac48Address::GetType (void)
|
||||
{
|
||||
static uint8_t type = Address::Register ();
|
||||
return type;
|
||||
}
|
||||
|
||||
bool operator == (const Eui48Address &a, const Eui48Address &b)
|
||||
bool operator == (const Mac48Address &a, const Mac48Address &b)
|
||||
{
|
||||
uint8_t ada[6];
|
||||
uint8_t adb[6];
|
||||
@@ -141,12 +141,12 @@ bool operator == (const Eui48Address &a, const Eui48Address &b)
|
||||
b.CopyTo (adb);
|
||||
return memcmp (ada, adb, 6) == 0;
|
||||
}
|
||||
bool operator != (const Eui48Address &a, const Eui48Address &b)
|
||||
bool operator != (const Mac48Address &a, const Mac48Address &b)
|
||||
{
|
||||
return ! (a == b);
|
||||
}
|
||||
|
||||
std::ostream& operator<< (std::ostream& os, const Eui48Address & address)
|
||||
std::ostream& operator<< (std::ostream& os, const Mac48Address & address)
|
||||
{
|
||||
uint8_t ad[6];
|
||||
address.CopyTo (ad);
|
||||
@@ -32,16 +32,16 @@ class Address;
|
||||
*
|
||||
* This class can contain 48 bit IEEE addresses.
|
||||
*/
|
||||
class Eui48Address
|
||||
class Mac48Address
|
||||
{
|
||||
public:
|
||||
Eui48Address ();
|
||||
Mac48Address ();
|
||||
/**
|
||||
* \param str a string representing the new Eui48Address
|
||||
* \param str a string representing the new Mac48Address
|
||||
*
|
||||
* The format of the string is "xx:xx:xx:xx:xx:xx"
|
||||
*/
|
||||
Eui48Address (const char *str);
|
||||
Mac48Address (const char *str);
|
||||
|
||||
/**
|
||||
* \param buffer address in network order
|
||||
@@ -64,21 +64,21 @@ public:
|
||||
operator Address ();
|
||||
/**
|
||||
* \param address a polymorphic address
|
||||
* \returns a new Eui48Address from the polymorphic address
|
||||
* \returns a new Mac48Address from the polymorphic address
|
||||
*
|
||||
* This function performs a type check and asserts if the
|
||||
* type of the input address is not compatible with an
|
||||
* Eui48Address.
|
||||
* Mac48Address.
|
||||
*/
|
||||
static Eui48Address ConvertFrom (const Address &address);
|
||||
static Mac48Address ConvertFrom (const Address &address);
|
||||
/**
|
||||
* \returns true if the address matches, false otherwise.
|
||||
*/
|
||||
static bool IsMatchingType (const Address &address);
|
||||
/**
|
||||
* Allocate a new Eui48Address.
|
||||
* Allocate a new Mac48Address.
|
||||
*/
|
||||
static Eui48Address Allocate (void);
|
||||
static Mac48Address Allocate (void);
|
||||
private:
|
||||
/**
|
||||
* \returns a new Address instance
|
||||
@@ -90,9 +90,9 @@ private:
|
||||
uint8_t m_address[6];
|
||||
};
|
||||
|
||||
bool operator == (const Eui48Address &a, const Eui48Address &b);
|
||||
bool operator != (const Eui48Address &a, const Eui48Address &b);
|
||||
std::ostream& operator<< (std::ostream& os, const Eui48Address & address);
|
||||
bool operator == (const Mac48Address &a, const Mac48Address &b);
|
||||
bool operator != (const Mac48Address &a, const Mac48Address &b);
|
||||
std::ostream& operator<< (std::ostream& os, const Mac48Address & address);
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
#include "eui64-address.h"
|
||||
#include "mac64-address.h"
|
||||
#include "address.h"
|
||||
#include "ns3/assert.h"
|
||||
#include <iomanip>
|
||||
@@ -45,11 +45,11 @@ AsciiToLowCase (char c)
|
||||
}
|
||||
|
||||
|
||||
Eui64Address::Eui64Address ()
|
||||
Mac64Address::Mac64Address ()
|
||||
{
|
||||
memset (m_address, 0, 8);
|
||||
}
|
||||
Eui64Address::Eui64Address (const char *str)
|
||||
Mac64Address::Mac64Address (const char *str)
|
||||
{
|
||||
int i = 0;
|
||||
while (*str != 0 && i < 8)
|
||||
@@ -80,45 +80,45 @@ Eui64Address::Eui64Address (const char *str)
|
||||
NS_ASSERT (i == 6);
|
||||
}
|
||||
void
|
||||
Eui64Address::CopyFrom (const uint8_t buffer[8])
|
||||
Mac64Address::CopyFrom (const uint8_t buffer[8])
|
||||
{
|
||||
memcpy (m_address, buffer, 8);
|
||||
}
|
||||
void
|
||||
Eui64Address::CopyTo (uint8_t buffer[8]) const
|
||||
Mac64Address::CopyTo (uint8_t buffer[8]) const
|
||||
{
|
||||
memcpy (buffer, m_address, 8);
|
||||
}
|
||||
|
||||
bool
|
||||
Eui64Address::IsMatchingType (const Address &address)
|
||||
Mac64Address::IsMatchingType (const Address &address)
|
||||
{
|
||||
return address.CheckCompatible (GetType (), 8);
|
||||
}
|
||||
Eui64Address::operator Address ()
|
||||
Mac64Address::operator Address ()
|
||||
{
|
||||
return ConvertTo ();
|
||||
}
|
||||
Eui64Address
|
||||
Eui64Address::ConvertFrom (const Address &address)
|
||||
Mac64Address
|
||||
Mac64Address::ConvertFrom (const Address &address)
|
||||
{
|
||||
NS_ASSERT (address.CheckCompatible (GetType (), 8));
|
||||
Eui64Address retval;
|
||||
Mac64Address retval;
|
||||
address.CopyTo (retval.m_address);
|
||||
return retval;
|
||||
}
|
||||
Address
|
||||
Eui64Address::ConvertTo (void) const
|
||||
Mac64Address::ConvertTo (void) const
|
||||
{
|
||||
return Address (GetType (), m_address, 8);
|
||||
}
|
||||
|
||||
Eui64Address
|
||||
Eui64Address::Allocate (void)
|
||||
Mac64Address
|
||||
Mac64Address::Allocate (void)
|
||||
{
|
||||
static uint64_t id = 0;
|
||||
id++;
|
||||
Eui64Address address;
|
||||
Mac64Address address;
|
||||
address.m_address[0] = (id >> 56) & 0xff;
|
||||
address.m_address[1] = (id >> 48) & 0xff;
|
||||
address.m_address[2] = (id >> 40) & 0xff;
|
||||
@@ -130,13 +130,13 @@ Eui64Address::Allocate (void)
|
||||
return address;
|
||||
}
|
||||
uint8_t
|
||||
Eui64Address::GetType (void)
|
||||
Mac64Address::GetType (void)
|
||||
{
|
||||
static uint8_t type = Address::Register ();
|
||||
return type;
|
||||
}
|
||||
|
||||
bool operator == (const Eui64Address &a, const Eui64Address &b)
|
||||
bool operator == (const Mac64Address &a, const Mac64Address &b)
|
||||
{
|
||||
uint8_t ada[8];
|
||||
uint8_t adb[8];
|
||||
@@ -144,12 +144,12 @@ bool operator == (const Eui64Address &a, const Eui64Address &b)
|
||||
b.CopyTo (adb);
|
||||
return memcmp (ada, adb, 8) == 0;
|
||||
}
|
||||
bool operator != (const Eui64Address &a, const Eui64Address &b)
|
||||
bool operator != (const Mac64Address &a, const Mac64Address &b)
|
||||
{
|
||||
return ! (a == b);
|
||||
}
|
||||
|
||||
std::ostream& operator<< (std::ostream& os, const Eui64Address & address)
|
||||
std::ostream& operator<< (std::ostream& os, const Mac64Address & address)
|
||||
{
|
||||
uint8_t ad[8];
|
||||
address.CopyTo (ad);
|
||||
@@ -32,16 +32,16 @@ class Address;
|
||||
*
|
||||
* This class can contain 64 bit IEEE addresses.
|
||||
*/
|
||||
class Eui64Address
|
||||
class Mac64Address
|
||||
{
|
||||
public:
|
||||
Eui64Address ();
|
||||
Mac64Address ();
|
||||
/**
|
||||
* \param str a string representing the new Eui64Address
|
||||
* \param str a string representing the new Mac64Address
|
||||
*
|
||||
* The format of the string is "xx:xx:xx:xx:xx:xx"
|
||||
*/
|
||||
Eui64Address (const char *str);
|
||||
Mac64Address (const char *str);
|
||||
|
||||
/**
|
||||
* \param buffer address in network order
|
||||
@@ -63,21 +63,21 @@ public:
|
||||
operator Address ();
|
||||
/**
|
||||
* \param address a polymorphic address
|
||||
* \returns a new Eui64Address from the polymorphic address
|
||||
* \returns a new Mac64Address from the polymorphic address
|
||||
*
|
||||
* This function performs a type check and asserts if the
|
||||
* type of the input address is not compatible with an
|
||||
* Eui64Address.
|
||||
* Mac64Address.
|
||||
*/
|
||||
static Eui64Address ConvertFrom (const Address &address);
|
||||
static Mac64Address ConvertFrom (const Address &address);
|
||||
/**
|
||||
* \returns true if the address matches, false otherwise.
|
||||
*/
|
||||
static bool IsMatchingType (const Address &address);
|
||||
/**
|
||||
* Allocate a new Eui64Address.
|
||||
* Allocate a new Mac64Address.
|
||||
*/
|
||||
static Eui64Address Allocate (void);
|
||||
static Mac64Address Allocate (void);
|
||||
private:
|
||||
/**
|
||||
* \returns a new Address instance
|
||||
@@ -89,9 +89,9 @@ private:
|
||||
uint8_t m_address[8];
|
||||
};
|
||||
|
||||
bool operator == (const Eui64Address &a, const Eui64Address &b);
|
||||
bool operator != (const Eui64Address &a, const Eui64Address &b);
|
||||
std::ostream& operator<< (std::ostream& os, const Eui64Address & address);
|
||||
bool operator == (const Mac64Address &a, const Mac64Address &b);
|
||||
bool operator != (const Mac64Address &a, const Mac64Address &b);
|
||||
std::ostream& operator<< (std::ostream& os, const Mac64Address & address);
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
|
||||
#include "ns3/ptr.h"
|
||||
#include "address.h"
|
||||
#include "eui48-address.h"
|
||||
#include "eui64-address.h"
|
||||
#include "mac48-address.h"
|
||||
#include "mac64-address.h"
|
||||
#include "net-device.h"
|
||||
|
||||
namespace ns3 {
|
||||
@@ -54,7 +54,7 @@ class PacketSocketAddress
|
||||
/**
|
||||
* \param address a polymorphic address
|
||||
*
|
||||
* Convert a polymorphic address to an Eui48Address instance.
|
||||
* Convert a polymorphic address to an Mac48Address instance.
|
||||
* The conversion performs a type check.
|
||||
*/
|
||||
static PacketSocketAddress ConvertFrom (const Address &address);
|
||||
|
||||
@@ -4,8 +4,8 @@ def build(bld):
|
||||
node = bld.create_ns3_module('node', ['core', 'common', 'simulator'])
|
||||
node.source = [
|
||||
'address.cc',
|
||||
'eui48-address.cc',
|
||||
'eui64-address.cc',
|
||||
'mac48-address.cc',
|
||||
'mac64-address.cc',
|
||||
'inet-socket-address.cc',
|
||||
'packet-socket-address.cc',
|
||||
'node.cc',
|
||||
@@ -32,8 +32,8 @@ def build(bld):
|
||||
headers = bld.create_obj('ns3header')
|
||||
headers.source = [
|
||||
'address.h',
|
||||
'eui48-address.h',
|
||||
'eui64-address.h',
|
||||
'mac48-address.h',
|
||||
'mac64-address.h',
|
||||
'inet-socket-address.h',
|
||||
'packet-socket-address.h',
|
||||
'node.h',
|
||||
|
||||
Reference in New Issue
Block a user