A Discrete-Event Network Simulator
API
point-to-point-net-device.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2007, 2008 University of Washington
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  */
18 
19 #ifndef POINT_TO_POINT_NET_DEVICE_H
20 #define POINT_TO_POINT_NET_DEVICE_H
21 
22 #include <cstring>
23 #include "ns3/address.h"
24 #include "ns3/node.h"
25 #include "ns3/net-device.h"
26 #include "ns3/callback.h"
27 #include "ns3/packet.h"
28 #include "ns3/traced-callback.h"
29 #include "ns3/nstime.h"
30 #include "ns3/data-rate.h"
31 #include "ns3/ptr.h"
32 #include "ns3/mac48-address.h"
33 
34 namespace ns3 {
35 
36 template <typename Item> class Queue;
37 class PointToPointChannel;
38 class ErrorModel;
39 
63 {
64 public:
70  static TypeId GetTypeId (void);
71 
80 
86  virtual ~PointToPointNetDevice ();
87 
95  void SetDataRate (DataRate bps);
96 
103  void SetInterframeGap (Time t);
104 
112 
121  void SetQueue (Ptr<Queue<Packet> > queue);
122 
128  Ptr<Queue<Packet> > GetQueue (void) const;
129 
139 
150  void Receive (Ptr<Packet> p);
151 
152  // The remaining methods are documented in ns3::NetDevice*
153 
154  virtual void SetIfIndex (const uint32_t index);
155  virtual uint32_t GetIfIndex (void) const;
156 
157  virtual Ptr<Channel> GetChannel (void) const;
158 
159  virtual void SetAddress (Address address);
160  virtual Address GetAddress (void) const;
161 
162  virtual bool SetMtu (const uint16_t mtu);
163  virtual uint16_t GetMtu (void) const;
164 
165  virtual bool IsLinkUp (void) const;
166 
167  virtual void AddLinkChangeCallback (Callback<void> callback);
168 
169  virtual bool IsBroadcast (void) const;
170  virtual Address GetBroadcast (void) const;
171 
172  virtual bool IsMulticast (void) const;
173  virtual Address GetMulticast (Ipv4Address multicastGroup) const;
174 
175  virtual bool IsPointToPoint (void) const;
176  virtual bool IsBridge (void) const;
177 
178  virtual bool Send (Ptr<Packet> packet, const Address &dest, uint16_t protocolNumber);
179  virtual bool SendFrom (Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber);
180 
181  virtual Ptr<Node> GetNode (void) const;
182  virtual void SetNode (Ptr<Node> node);
183 
184  virtual bool NeedsArp (void) const;
185 
187 
188  virtual Address GetMulticast (Ipv6Address addr) const;
189 
191  virtual bool SupportsSendFrom (void) const;
192 
193 protected:
199  void DoMpiReceive (Ptr<Packet> p);
200 
201 private:
202 
212 
221 
225  virtual void DoDispose (void);
226 
227 private:
228 
233  Address GetRemote (void) const;
234 
241  void AddHeader (Ptr<Packet> p, uint16_t protocolNumber);
242 
251  bool ProcessHeader (Ptr<Packet> p, uint16_t& param);
252 
268  bool TransmitStart (Ptr<Packet> p);
269 
276  void TransmitComplete (void);
277 
283  void NotifyLinkUp (void);
284 
289  {
291  BUSY
292  };
297 
303 
309 
315 
323 
328 
334 
340 
348 
356 
363 
369 
375 
381 
387 
393 
400 
418 
436 
441  // (promisc data)
442  uint32_t m_ifIndex;
443  bool m_linkUp;
445 
446  static const uint16_t DEFAULT_MTU = 1500;
447 
456  uint32_t m_mtu;
457 
459 
465  static uint16_t PppToEther (uint16_t protocol);
466 
472  static uint16_t EtherToPpp (uint16_t protocol);
473 };
474 
475 } // namespace ns3
476 
477 #endif /* POINT_TO_POINT_NET_DEVICE_H */
ns3::TypeId
a unique identifier for an interface.
Definition: type-id.h:59
ns3::PointToPointNetDevice::PppToEther
static uint16_t PppToEther(uint16_t protocol)
PPP to Ethernet protocol number mapping.
Definition: point-to-point-net-device.cc:649
ns3::PointToPointNetDevice::m_snifferTrace
TracedCallback< Ptr< const Packet > > m_snifferTrace
A trace source that emulates a non-promiscuous protocol sniffer connected to the device.
Definition: point-to-point-net-device.h:417
ns3::PointToPointNetDevice::m_promiscCallback
NetDevice::PromiscReceiveCallback m_promiscCallback
Receive callback.
Definition: point-to-point-net-device.h:440
ns3::PointToPointNetDevice::DEFAULT_MTU
static const uint16_t DEFAULT_MTU
Default MTU.
Definition: point-to-point-net-device.h:446
ns3::PointToPointNetDevice::IsPointToPoint
virtual bool IsPointToPoint(void) const
Return true if the net device is on a point-to-point link.
Definition: point-to-point-net-device.cc:493
ns3::PointToPointNetDevice::m_phyTxEndTrace
TracedCallback< Ptr< const Packet > > m_phyTxEndTrace
The trace source fired when a packet ends the transmission process on the medium.
Definition: point-to-point-net-device.h:374
ns3::Callback< void >
ns3::PointToPointNetDevice::PointToPointNetDevice
PointToPointNetDevice(const PointToPointNetDevice &o)
Copy constructor.
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::PointToPointNetDevice::EtherToPpp
static uint16_t EtherToPpp(uint16_t protocol)
Ethernet to PPP protocol number mapping.
Definition: point-to-point-net-device.cc:662
ns3::PointToPointNetDevice::GetRemote
Address GetRemote(void) const
Definition: point-to-point-net-device.cc:616
ns3::PointToPointNetDevice::READY
@ READY
The transmitter is ready to begin transmission of a packet.
Definition: point-to-point-net-device.h:290
ns3::PointToPointNetDevice::PointToPointNetDevice
PointToPointNetDevice()
Construct a PointToPointNetDevice.
Definition: point-to-point-net-device.cc:175
ns3::PointToPointNetDevice::SendFrom
virtual bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
Definition: point-to-point-net-device.cc:560
ns3::PointToPointNetDevice::m_mtu
uint32_t m_mtu
The Maximum Transmission Unit.
Definition: point-to-point-net-device.h:456
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:41
ns3::Ipv6Address
Describes an IPv6 address.
Definition: ipv6-address.h:50
ns3::PointToPointNetDevice::m_phyRxEndTrace
TracedCallback< Ptr< const Packet > > m_phyRxEndTrace
The trace source fired when a packet ends the reception process from the medium.
Definition: point-to-point-net-device.h:392
ns3::Mac48Address
an EUI-48 address
Definition: mac48-address.h:44
ns3::PointToPointNetDevice::IsBridge
virtual bool IsBridge(void) const
Return true if the net device is acting as a bridge.
Definition: point-to-point-net-device.cc:500
ns3::PointToPointNetDevice::m_phyTxDropTrace
TracedCallback< Ptr< const Packet > > m_phyTxDropTrace
The trace source fired when the phy layer drops a packet before it tries to transmit it.
Definition: point-to-point-net-device.h:380
ns3::PointToPointNetDevice::DoDispose
virtual void DoDispose(void)
Dispose of the object.
Definition: point-to-point-net-device.cc:210
ns3::PointToPointNetDevice::m_txMachineState
TxMachineState m_txMachineState
The state of the Net Device transmit state machine.
Definition: point-to-point-net-device.h:296
ns3::PointToPointNetDevice::operator=
PointToPointNetDevice & operator=(const PointToPointNetDevice &o)
Assign operator.
ns3::PointToPointNetDevice::m_tInterframeGap
Time m_tInterframeGap
The interframe gap that the Net Device uses to throttle packet transmission.
Definition: point-to-point-net-device.h:308
ns3::PointToPointNetDevice::NeedsArp
virtual bool NeedsArp(void) const
Definition: point-to-point-net-device.cc:583
ns3::PointToPointNetDevice::TransmitComplete
void TransmitComplete(void)
Stop Sending a Packet Down the Wire and Begin the Interframe Gap.
Definition: point-to-point-net-device.cc:266
ns3::PointToPointNetDevice::m_queue
Ptr< Queue< Packet > > m_queue
The Queue which this PointToPointNetDevice uses as a packet source.
Definition: point-to-point-net-device.h:322
ns3::PointToPointNetDevice::m_phyRxDropTrace
TracedCallback< Ptr< const Packet > > m_phyRxDropTrace
The trace source fired when the phy layer drops a packet it has received.
Definition: point-to-point-net-device.h:399
ns3::PointToPointNetDevice::m_linkUp
bool m_linkUp
Identify if the link is up or not.
Definition: point-to-point-net-device.h:443
ns3::PointToPointNetDevice::BUSY
@ BUSY
The transmitter is busy transmitting a packet.
Definition: point-to-point-net-device.h:291
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:74
ns3::DataRate
Class for representing data rates.
Definition: data-rate.h:89
ns3::PointToPointNetDevice::SetInterframeGap
void SetInterframeGap(Time t)
Set the interframe gap used to separate packets.
Definition: point-to-point-net-device.cc:229
ns3::Address
a polymophic address class
Definition: address.h:91
ns3::PointToPointNetDevice::GetMulticast
virtual Address GetMulticast(Ipv4Address multicastGroup) const
Make and return a MAC multicast address using the provided multicast group.
Definition: point-to-point-net-device.cc:479
ns3::PointToPointNetDevice::m_phyRxBeginTrace
TracedCallback< Ptr< const Packet > > m_phyRxBeginTrace
The trace source fired when a packet begins the reception process from the medium – when the simulate...
Definition: point-to-point-net-device.h:386
ns3::PointToPointNetDevice::IsLinkUp
virtual bool IsLinkUp(void) const
Definition: point-to-point-net-device.cc:435
ns3::PointToPointNetDevice::m_rxCallback
NetDevice::ReceiveCallback m_rxCallback
Receive callback.
Definition: point-to-point-net-device.h:439
first.address
address
Definition: first.py:44
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:104
ns3::PointToPointNetDevice::AddLinkChangeCallback
virtual void AddLinkChangeCallback(Callback< void > callback)
Definition: point-to-point-net-device.cc:442
ns3::PointToPointNetDevice::m_address
Mac48Address m_address
Mac48Address of this NetDevice.
Definition: point-to-point-net-device.h:438
ns3::PointToPointNetDevice::m_currentPkt
Ptr< Packet > m_currentPkt
Current packet processed.
Definition: point-to-point-net-device.h:458
ns3::PointToPointNetDevice::Attach
bool Attach(Ptr< PointToPointChannel > ch)
Attach the device to a channel.
Definition: point-to-point-net-device.cc:300
ns3::PointToPointNetDevice::SetReceiveErrorModel
void SetReceiveErrorModel(Ptr< ErrorModel > em)
Attach a receive ErrorModel to the PointToPointNetDevice.
Definition: point-to-point-net-device.cc:325
Queue< Packet >
ns3::PointToPointNetDevice::m_macTxTrace
TracedCallback< Ptr< const Packet > > m_macTxTrace
The trace source fired when packets come into the "top" of the device at the L3/L2 transition,...
Definition: point-to-point-net-device.h:333
ns3::PointToPointNetDevice::Receive
void Receive(Ptr< Packet > p)
Receive a packet from a connected PointToPointChannel.
Definition: point-to-point-net-device.cc:332
ns3::PointToPointNetDevice::GetTypeId
static TypeId GetTypeId(void)
Get the TypeId.
Definition: point-to-point-net-device.cc:39
ns3::PointToPointNetDevice::Send
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
Definition: point-to-point-net-device.cc:507
ns3::PointToPointNetDevice::GetBroadcast
virtual Address GetBroadcast(void) const
Definition: point-to-point-net-device.cc:465
ns3::PointToPointNetDevice::SetPromiscReceiveCallback
virtual void SetPromiscReceiveCallback(PromiscReceiveCallback cb)
Definition: point-to-point-net-device.cc:596
ns3::PointToPointNetDevice::GetQueue
Ptr< Queue< Packet > > GetQueue(void) const
Get a copy of the attached Queue.
Definition: point-to-point-net-device.cc:382
ns3::PointToPointNetDevice::m_macRxTrace
TracedCallback< Ptr< const Packet > > m_macRxTrace
The trace source fired for packets successfully received by the device immediately before being forwa...
Definition: point-to-point-net-device.h:355
ns3::PointToPointNetDevice::m_macRxDropTrace
TracedCallback< Ptr< const Packet > > m_macRxDropTrace
The trace source fired for packets successfully received by the device but are dropped before being f...
Definition: point-to-point-net-device.h:362
ns3::PointToPointNetDevice::SetMtu
virtual bool SetMtu(const uint16_t mtu)
Definition: point-to-point-net-device.cc:634
ns3::PointToPointNetDevice::GetMtu
virtual uint16_t GetMtu(void) const
Definition: point-to-point-net-device.cc:642
ns3::PointToPointNetDevice::m_phyTxBeginTrace
TracedCallback< Ptr< const Packet > > m_phyTxBeginTrace
The trace source fired when a packet begins the transmission process on the medium.
Definition: point-to-point-net-device.h:368
ns3::PointToPointNetDevice::IsMulticast
virtual bool IsMulticast(void) const
Definition: point-to-point-net-device.cc:472
ns3::PointToPointNetDevice::GetIfIndex
virtual uint32_t GetIfIndex(void) const
Definition: point-to-point-net-device.cc:404
ns3::PointToPointNetDevice::m_macPromiscRxTrace
TracedCallback< Ptr< const Packet > > m_macPromiscRxTrace
The trace source fired for packets successfully received by the device immediately before being forwa...
Definition: point-to-point-net-device.h:347
ns3::PointToPointNetDevice::m_bps
DataRate m_bps
The data rate that the Net Device uses to simulate packet transmission timing.
Definition: point-to-point-net-device.h:302
ns3::PointToPointNetDevice::SetAddress
virtual void SetAddress(Address address)
Set the address of this interface.
Definition: point-to-point-net-device.cc:422
ns3::PointToPointNetDevice::SetNode
virtual void SetNode(Ptr< Node > node)
Definition: point-to-point-net-device.cc:576
ns3::PointToPointNetDevice
A Device for a Point to Point Network Link.
Definition: point-to-point-net-device.h:63
ns3::PointToPointNetDevice::m_promiscSnifferTrace
TracedCallback< Ptr< const Packet > > m_promiscSnifferTrace
A trace source that emulates a promiscuous mode protocol sniffer connected to the device.
Definition: point-to-point-net-device.h:435
ns3::PointToPointNetDevice::m_ifIndex
uint32_t m_ifIndex
Index of the interface.
Definition: point-to-point-net-device.h:442
ns3::PointToPointNetDevice::IsBroadcast
virtual bool IsBroadcast(void) const
Definition: point-to-point-net-device.cc:453
ns3::PointToPointNetDevice::SetQueue
void SetQueue(Ptr< Queue< Packet > > queue)
Attach a queue to the PointToPointNetDevice.
Definition: point-to-point-net-device.cc:318
ns3::PointToPointNetDevice::DoMpiReceive
void DoMpiReceive(Ptr< Packet > p)
Handler for MPI receive event.
Definition: point-to-point-net-device.cc:609
ns3::PointToPointNetDevice::AddHeader
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...
Definition: point-to-point-net-device.cc:191
ns3::PointToPointNetDevice::m_node
Ptr< Node > m_node
Node owning this NetDevice.
Definition: point-to-point-net-device.h:437
ns3::TracedCallback
Forward calls to a chain of Callback.
Definition: traced-callback.h:53
ns3::PointToPointNetDevice::GetAddress
virtual Address GetAddress(void) const
Definition: point-to-point-net-device.cc:429
ns3::PointToPointNetDevice::SetIfIndex
virtual void SetIfIndex(const uint32_t index)
Definition: point-to-point-net-device.cc:397
ns3::PointToPointNetDevice::m_linkChangeCallbacks
TracedCallback m_linkChangeCallbacks
Callback for the link change event.
Definition: point-to-point-net-device.h:444
ns3::PointToPointNetDevice::m_receiveErrorModel
Ptr< ErrorModel > m_receiveErrorModel
Error model for receive packet events.
Definition: point-to-point-net-device.h:327
ns3::PointToPointNetDevice::SetReceiveCallback
virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb)
Definition: point-to-point-net-device.cc:590
ns3::PointToPointNetDevice::~PointToPointNetDevice
virtual ~PointToPointNetDevice()
Destroy a PointToPointNetDevice.
Definition: point-to-point-net-device.cc:185
ns3::PointToPointNetDevice::NotifyLinkUp
void NotifyLinkUp(void)
Make the link up and running.
Definition: point-to-point-net-device.cc:389
ns3::PointToPointNetDevice::m_channel
Ptr< PointToPointChannel > m_channel
The PointToPointChannel to which this PointToPointNetDevice has been attached.
Definition: point-to-point-net-device.h:314
ns3::PointToPointNetDevice::TransmitStart
bool TransmitStart(Ptr< Packet > p)
Start Sending a Packet Down the Wire.
Definition: point-to-point-net-device.cc:236
ns3::PointToPointNetDevice::TxMachineState
TxMachineState
Enumeration of the states of the transmit machine of the net device.
Definition: point-to-point-net-device.h:289
ns3::PointToPointNetDevice::GetNode
virtual Ptr< Node > GetNode(void) const
Definition: point-to-point-net-device.cc:570
ns3::PointToPointNetDevice::SupportsSendFrom
virtual bool SupportsSendFrom(void) const
Definition: point-to-point-net-device.cc:602
ns3::PointToPointNetDevice::GetChannel
virtual Ptr< Channel > GetChannel(void) const
Definition: point-to-point-net-device.cc:410
ns3::PointToPointNetDevice::ProcessHeader
bool ProcessHeader(Ptr< Packet > p, uint16_t &param)
Removes, from a packet of data, all headers and trailers that relate to the protocol implemented by t...
Definition: point-to-point-net-device.cc:200
ns3::PointToPointNetDevice::SetDataRate
void SetDataRate(DataRate bps)
Set the Data Rate used for transmission of packets.
Definition: point-to-point-net-device.cc:222
ns3::NetDevice
Network layer to device interface.
Definition: net-device.h:96
ns3::PointToPointNetDevice::m_macTxDropTrace
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...
Definition: point-to-point-net-device.h:339