A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
simple-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) 2008 INRIA
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  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19  */
20 #ifndef SIMPLE_NET_DEVICE_H
21 #define SIMPLE_NET_DEVICE_H
22 
23 #include "ns3/net-device.h"
24 #include "mac48-address.h"
25 #include <stdint.h>
26 #include <string>
27 #include "ns3/traced-callback.h"
28 
29 namespace ns3 {
30 
31 class SimpleChannel;
32 class Node;
33 class ErrorModel;
34 
45 class SimpleNetDevice : public NetDevice
46 {
47 public:
52  static TypeId GetTypeId (void);
53  SimpleNetDevice ();
54 
65  void Receive (Ptr<Packet> packet, uint16_t protocol, Mac48Address to, Mac48Address from);
66 
75  void SetChannel (Ptr<SimpleChannel> channel);
76 
87 
88  // inherited from NetDevice base class.
89  virtual void SetIfIndex (const uint32_t index);
90  virtual uint32_t GetIfIndex (void) const;
91  virtual Ptr<Channel> GetChannel (void) const;
92  virtual void SetAddress (Address address);
93  virtual Address GetAddress (void) const;
94  virtual bool SetMtu (const uint16_t mtu);
95  virtual uint16_t GetMtu (void) const;
96  virtual bool IsLinkUp (void) const;
97  virtual void AddLinkChangeCallback (Callback<void> callback);
98  virtual bool IsBroadcast (void) const;
99  virtual Address GetBroadcast (void) const;
100  virtual bool IsMulticast (void) const;
101  virtual Address GetMulticast (Ipv4Address multicastGroup) const;
102  virtual bool IsPointToPoint (void) const;
103  virtual bool IsBridge (void) const;
104  virtual bool Send (Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber);
105  virtual bool SendFrom (Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber);
106  virtual Ptr<Node> GetNode (void) const;
107  virtual void SetNode (Ptr<Node> node);
108  virtual bool NeedsArp (void) const;
110 
111  virtual Address GetMulticast (Ipv6Address addr) const;
112 
114  virtual bool SupportsSendFrom (void) const;
115 
116 protected:
117  virtual void DoDispose (void);
118 private:
123  uint16_t m_mtu;
124  uint32_t m_ifIndex;
127 
136 };
137 
138 } // namespace ns3
139 
140 #endif /* SIMPLE_NET_DEVICE_H */
virtual Address GetAddress(void) const
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
Ptr< Node > m_node
Node this netDevice is associated to.
virtual Ptr< Channel > GetChannel(void) const
forward calls to a chain of CallbackAn ns3::TracedCallback has almost exactly the same API as a norma...
void Receive(Ptr< Packet > packet, uint16_t protocol, Mac48Address to, Mac48Address from)
Receive a packet from a connected SimpleChannel.
virtual void SetIfIndex(const uint32_t index)
virtual bool IsBroadcast(void) const
virtual bool NeedsArp(void) const
virtual bool IsMulticast(void) const
a polymophic address class
Definition: address.h:86
virtual void SetNode(Ptr< Node > node)
virtual void SetPromiscReceiveCallback(PromiscReceiveCallback cb)
virtual bool SetMtu(const uint16_t mtu)
This device does not have a helper and assumes 48-bit mac addressing; the default address assigned to...
virtual bool IsPointToPoint(void) const
Return true if the net device is on a point-to-point link.
Mac48Address m_address
MAC address.
virtual Address GetMulticast(Ipv4Address multicastGroup) const
Make and return a MAC multicast address using the provided multicast group.
virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb)
an EUI-48 address
Definition: mac48-address.h:41
virtual uint16_t GetMtu(void) const
void SetReceiveErrorModel(Ptr< ErrorModel > em)
Attach a receive ErrorModel to the SimpleNetDevice.
virtual Ptr< Node > GetNode(void) const
NetDevice::PromiscReceiveCallback m_promiscCallback
Promiscuous receive callback.
Describes an IPv6 address.
Definition: ipv6-address.h:46
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:38
TracedCallback< Ptr< const Packet > > m_phyRxDropTrace
The trace source fired when the phy layer drops a packet it has received due to the error model being...
Network layer to device interface.
Definition: net-device.h:75
virtual void AddLinkChangeCallback(Callback< void > callback)
virtual void SetAddress(Address address)
Set the address of this interface.
Ptr< ErrorModel > m_receiveErrorModel
Receive error model.
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
virtual bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
NetDevice::ReceiveCallback m_rxCallback
Receive callback.
Ptr< SimpleChannel > m_channel
the channel the device is connected to
tuple address
Definition: first.py:37
virtual bool IsBridge(void) const
Return true if the net device is acting as a bridge.
void SetChannel(Ptr< SimpleChannel > channel)
Attach a channel to this net device.
a unique identifier for an interface.
Definition: type-id.h:49
virtual Address GetBroadcast(void) const
virtual uint32_t GetIfIndex(void) const
static TypeId GetTypeId(void)
Get the type ID.
virtual bool SupportsSendFrom(void) const
virtual bool IsLinkUp(void) const
uint32_t m_ifIndex
Interface index.