20 #include "ns3/queue.h" 
   21 #include "ns3/simulator.h" 
   22 #include "ns3/mac48-address.h" 
   23 #include "ns3/llc-snap-header.h" 
   24 #include "ns3/error-model.h" 
   25 #include "ns3/trace-source-accessor.h" 
   26 #include "ns3/uinteger.h" 
   27 #include "ns3/pointer.h" 
   41   static TypeId tid = 
TypeId (
"ns3::PointToPointNetDevice")
 
   43     .AddConstructor<PointToPointNetDevice> ()
 
   44     .AddAttribute (
"Mtu", 
"The MAC-level Maximum Transmission Unit",
 
   48                    MakeUintegerChecker<uint16_t> ())
 
   49     .AddAttribute (
"Address", 
 
   50                    "The MAC address of this device.",
 
   54     .AddAttribute (
"DataRate", 
 
   55                    "The default data rate for point to point links",
 
   59     .AddAttribute (
"ReceiveErrorModel", 
 
   60                    "The receiver error model used to simulate packet loss",
 
   63                    MakePointerChecker<ErrorModel> ())
 
   64     .AddAttribute (
"InterframeGap", 
 
   65                    "The time to wait between packet (frame) transmissions",
 
   74     .AddAttribute (
"TxQueue", 
 
   75                    "A queue to use as the transmit queue in the device.",
 
   78                    MakePointerChecker<Queue> ())
 
   84     .AddTraceSource (
"MacTx", 
 
   85                      "Trace source indicating a packet has arrived " 
   86                      "for transmission by this device",
 
   88                      "ns3::Packet::TracedCallback")
 
   89     .AddTraceSource (
"MacTxDrop", 
 
   90                      "Trace source indicating a packet has been dropped " 
   91                      "by the device before transmission",
 
   93                      "ns3::Packet::TracedCallback")
 
   94     .AddTraceSource (
"MacPromiscRx", 
 
   95                      "A packet has been received by this device, " 
   96                      "has been passed up from the physical layer " 
   97                      "and is being forwarded up the local protocol stack.  " 
   98                      "This is a promiscuous trace,",
 
  100                      "ns3::Packet::TracedCallback")
 
  101     .AddTraceSource (
"MacRx", 
 
  102                      "A packet has been received by this device, " 
  103                      "has been passed up from the physical layer " 
  104                      "and is being forwarded up the local protocol stack.  " 
  105                      "This is a non-promiscuous trace,",
 
  107                      "ns3::Packet::TracedCallback")
 
  110     .AddTraceSource (
"MacRxDrop", 
 
  111                      "Trace source indicating a packet was dropped " 
  112                      "before being forwarded up the stack",
 
  114                      "ns3::Packet::TracedCallback")
 
  120     .AddTraceSource (
"PhyTxBegin", 
 
  121                      "Trace source indicating a packet has begun " 
  122                      "transmitting over the channel",
 
  124                      "ns3::Packet::TracedCallback")
 
  125     .AddTraceSource (
"PhyTxEnd", 
 
  126                      "Trace source indicating a packet has been " 
  127                      "completely transmitted over the channel",
 
  129                      "ns3::Packet::TracedCallback")
 
  130     .AddTraceSource (
"PhyTxDrop", 
 
  131                      "Trace source indicating a packet has been " 
  132                      "dropped by the device during transmission",
 
  134                      "ns3::Packet::TracedCallback")
 
  137     .AddTraceSource (
"PhyRxBegin", 
 
  138                      "Trace source indicating a packet has begun " 
  139                      "being received by the device",
 
  141                      "ns3::Packet::TracedCallback")
 
  143     .AddTraceSource (
"PhyRxEnd", 
 
  144                      "Trace source indicating a packet has been " 
  145                      "completely received by the device",
 
  147                      "ns3::Packet::TracedCallback")
 
  148     .AddTraceSource (
"PhyRxDrop", 
 
  149                      "Trace source indicating a packet has been " 
  150                      "dropped by the device during reception",
 
  152                      "ns3::Packet::TracedCallback")
 
  159     .AddTraceSource (
"Sniffer", 
 
  160                     "Trace source simulating a non-promiscuous packet sniffer " 
  161                      "attached to the device",
 
  163                      "ns3::Packet::TracedCallback")
 
  164     .AddTraceSource (
"PromiscSniffer", 
 
  165                      "Trace source simulating a promiscuous packet sniffer " 
  166                      "attached to the device",
 
  168                      "ns3::Packet::TracedCallback")
 
  176     m_txMachineState (READY),
 
  255   bool result = 
m_channel->TransmitStart (p, 
this, txTime);
 
  335   uint16_t protocol = 0;
 
  510   uint16_t protocolNumber)
 
  561                                  uint16_t protocolNumber)
 
  618   for (uint32_t i = 0; i < 
m_channel->GetNDevices (); ++i)
 
  623           return tmp->GetAddress ();
 
  652     case 0x0021: 
return 0x0800;   
 
  653     case 0x0057: 
return 0x86DD;   
 
  654     default: 
NS_ASSERT_MSG (
false, 
"PPP Protocol number not defined!");
 
  665     case 0x0800: 
return 0x0021;   
 
  666     case 0x86DD: 
return 0x0057;   
 
  667     default: 
NS_ASSERT_MSG (
false, 
"PPP Protocol number not defined!");
 
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer. 
void SetReceiveErrorModel(Ptr< ErrorModel > em)
Attach a receive ErrorModel to the PointToPointNetDevice. 
PointToPointNetDevice()
Construct a PointToPointNetDevice. 
Simulation virtual time values and global simulation resolution. 
NetDevice::ReceiveCallback m_rxCallback
Receive callback. 
void NotifyLinkUp(void)
Make the link up and running. 
virtual bool IsLinkUp(void) const 
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
static TypeId GetTypeId(void)
Get the TypeId. 
Ptr< Queue > GetQueue(void) const 
Get a copy of the attached Queue. 
The transmitter is busy transmitting a packet. 
TracedCallback< Ptr< const Packet > > m_phyTxDropTrace
The trace source fired when the phy layer drops a packet before it tries to transmit it...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system. 
uint32_t m_mtu
The Maximum Transmission Unit. 
Address GetRemote(void) const 
virtual bool SupportsSendFrom(void) const 
virtual ~PointToPointNetDevice()
Destroy a PointToPointNetDevice. 
static const uint16_t DEFAULT_MTU
Default MTU. 
TracedCallback< Ptr< const Packet > > m_phyRxEndTrace
The trace source fired when a packet ends the reception process from the medium. 
Ptr< Node > m_node
Node owning this NetDevice. 
TracedCallback< Ptr< const Packet > > m_phyRxDropTrace
The trace source fired when the phy layer drops a packet it has received. 
uint64_t GetUid(void) const 
Returns the packet's Uid. 
bool IsNull(void) const 
Check for null implementation. 
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
TracedCallback< Ptr< const Packet > > m_phyTxBeginTrace
The trace source fired when a packet begins the transmission process on the medium. 
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name. 
Ptr< Packet > m_currentPkt
Current packet processed. 
static uint16_t EtherToPpp(uint16_t protocol)
Ethernet to PPP protocol number mapping. 
uint32_t GetSize(void) const 
Returns the the size in bytes of the packet (including the zero-filled initial payload). 
virtual void DoDispose(void)
Destructor implementation. 
Ptr< const AttributeChecker > MakeMac48AddressChecker(void)
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function. 
virtual Ptr< Node > GetNode(void) const 
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Schedule an event to expire at the relative time "time" is reached. 
TracedCallback< Ptr< const Packet > > m_macRxTrace
The trace source fired for packets successfully received by the device immediately before being forwa...
Ptr< const AttributeAccessor > MakeMac48AddressAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
The transmitter is ready to begin transmission of a packet. 
bool ProcessHeader(Ptr< Packet > p, uint16_t ¶m)
Removes, from a packet of data, all headers and trailers that relate to the protocol implemented by t...
a polymophic address class 
Ptr< const AttributeChecker > MakeDataRateChecker(void)
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source. 
virtual Address GetMulticast(Ipv4Address multicastGroup) const 
Make and return a MAC multicast address using the provided multicast group. 
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range. 
static uint16_t PppToEther(uint16_t protocol)
PPP to Ethernet protocol number mapping. 
Class for representing data rates. 
virtual bool IsPointToPoint(void) const 
Return true if the net device is on a point-to-point link. 
double GetSeconds(void) const 
Get an approximation of the time stored in this instance in the indicated unit. 
double CalculateTxTime(uint32_t bytes) const 
Calculate transmission time. 
virtual void SetPromiscReceiveCallback(PromiscReceiveCallback cb)
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
virtual void SetAddress(Address address)
Set the address of this interface. 
AttributeValue implementation for Time. 
Hold an unsigned integer type. 
void TransmitComplete(void)
Stop Sending a Packet Down the Wire and Begin the Interframe Gap. 
TracedCallback m_linkChangeCallbacks
Callback for the link change event. 
TracedCallback< Ptr< const Packet > > m_snifferTrace
A trace source that emulates a non-promiscuous protocol sniffer connected to the device. 
bool TransmitStart(Ptr< Packet > p)
Start Sending a Packet Down the Wire. 
void SetInterframeGap(Time t)
Set the interframe gap used to separate packets. 
NetDevice::PromiscReceiveCallback m_promiscCallback
Receive callback. 
Mac48Address m_address
Mac48Address of this NetDevice. 
Ptr< const AttributeAccessor > MakeDataRateAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC. 
Time m_tInterframeGap
The interframe gap that the Net Device uses to throttle packet transmission. 
virtual void AddLinkChangeCallback(Callback< void > callback)
static Mac48Address ConvertFrom(const Address &address)
virtual bool NeedsArp(void) const 
Ptr< Packet > Copy(void) const 
performs a COW copy of the packet. 
virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb)
Every class exported by the ns3 library is enclosed in the ns3 namespace. 
virtual uint32_t GetIfIndex(void) const 
Hold objects of type Ptr. 
virtual Ptr< Channel > GetChannel(void) const 
virtual Address GetAddress(void) const 
virtual bool IsBridge(void) const 
Return true if the net device is acting as a bridge. 
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
void DoMpiReceive(Ptr< Packet > p)
Handler for MPI receive event. 
DataRate m_bps
The data rate that the Net Device uses to simulate packet transmission timing. 
Ptr< PointToPointChannel > m_channel
The PointToPointChannel to which this PointToPointNetDevice has been attached. 
TracedCallback< Ptr< const Packet > > m_promiscSnifferTrace
A trace source that emulates a promiscuous mode protocol sniffer connected to the device...
Ptr< ErrorModel > m_receiveErrorModel
Error model for receive packet events. 
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
virtual bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
Describes an IPv6 address. 
Ipv4 addresses are stored in host order in this class. 
uint32_t m_ifIndex
Index of the interface. 
TracedCallback< Ptr< const Packet > > m_macPromiscRxTrace
The trace source fired for packets successfully received by the device immediately before being forwa...
TracedCallback< Ptr< const Packet > > m_phyRxBeginTrace
The trace source fired when a packet begins the reception process from the medium – when the simulat...
void ConnectWithoutContext(const CallbackBase &callback)
Append a Callback to the chain (without a context). 
TxMachineState m_txMachineState
The state of the Net Device transmit state machine. 
TracedCallback< Ptr< const Packet > > m_macTxDropTrace
The trace source fired when packets coming into the "top" of the device at the L3/L2 transition are d...
Network layer to device interface. 
virtual bool SetMtu(const uint16_t mtu)
virtual void SetIfIndex(const uint32_t index)
AttributeValue implementation for DataRate. 
AttributeValue implementation for Mac48Address. 
void SetDataRate(DataRate bps)
Set the Data Rate used for transmission of packets. 
TracedCallback< Ptr< const Packet > > m_macRxDropTrace
The trace source fired for packets successfully received by the device but are dropped before being f...
void Receive(Ptr< Packet > p)
Receive a packet from a connected PointToPointChannel. 
virtual bool IsBroadcast(void) const 
Time Seconds(double value)
Construct a Time in the indicated unit. 
bool Attach(Ptr< PointToPointChannel > ch)
Attach the device to a channel. 
Ptr< Queue > m_queue
The Queue which this PointToPointNetDevice uses as a packet source. 
virtual void DoDispose(void)
Dispose of the object. 
virtual void SetNode(Ptr< Node > node)
bool m_linkUp
Identify if the link is up or not. 
void AddHeader(Ptr< Packet > p, uint16_t protocolNumber)
Adds the necessary headers and trailers to a packet of data in order to respect the protocol implemen...
virtual uint16_t GetMtu(void) const 
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
virtual bool IsMulticast(void) const 
a unique identifier for an interface. 
TracedCallback< Ptr< const Packet > > m_macTxTrace
The trace source fired when packets come into the "top" of the device at the L3/L2 transition...
TypeId SetParent(TypeId tid)
virtual Address GetBroadcast(void) const 
void AddHeader(const Header &header)
Add header to this packet. 
void SetQueue(Ptr< Queue > queue)
Attach a queue to the PointToPointNetDevice. 
TracedCallback< Ptr< const Packet > > m_phyTxEndTrace
The trace source fired when a packet ends the transmission process on the medium. ...