A Discrete-Event Network Simulator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
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
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  */
23 #include "ns3/net-device.h"
24 #include "mac48-address.h"
25 #include <stdint.h>
26 #include <string>
27 #include "ns3/traced-callback.h"
29 namespace ns3 {
31 class SimpleChannel;
32 class Node;
33 class ErrorModel;
45 class SimpleNetDevice : public NetDevice
46 {
47 public:
48  static TypeId GetTypeId (void);
49  SimpleNetDevice ();
51  void Receive (Ptr<Packet> packet, uint16_t protocol, Mac48Address to, Mac48Address from);
52  void SetChannel (Ptr<SimpleChannel> channel);
65  // inherited from NetDevice base class.
66  virtual void SetIfIndex (const uint32_t index);
67  virtual uint32_t GetIfIndex (void) const;
68  virtual Ptr<Channel> GetChannel (void) const;
69  virtual void SetAddress (Address address);
70  virtual Address GetAddress (void) const;
71  virtual bool SetMtu (const uint16_t mtu);
72  virtual uint16_t GetMtu (void) const;
73  virtual bool IsLinkUp (void) const;
74  virtual void AddLinkChangeCallback (Callback<void> callback);
75  virtual bool IsBroadcast (void) const;
76  virtual Address GetBroadcast (void) const;
77  virtual bool IsMulticast (void) const;
78  virtual Address GetMulticast (Ipv4Address multicastGroup) const;
79  virtual bool IsPointToPoint (void) const;
80  virtual bool IsBridge (void) const;
81  virtual bool Send (Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber);
82  virtual bool SendFrom (Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber);
83  virtual Ptr<Node> GetNode (void) const;
84  virtual void SetNode (Ptr<Node> node);
85  virtual bool NeedsArp (void) const;
88  virtual Address GetMulticast (Ipv6Address addr) const;
91  virtual bool SupportsSendFrom (void) const;
93 protected:
94  virtual void DoDispose (void);
95 private:
96  Ptr<SimpleChannel> m_channel;
97  NetDevice::ReceiveCallback m_rxCallback;
98  NetDevice::PromiscReceiveCallback m_promiscCallback;
99  Ptr<Node> m_node;
100  uint16_t m_mtu;
101  uint32_t m_ifIndex;
102  Mac48Address m_address;
103  Ptr<ErrorModel> m_receiveErrorModel;
113 };
115 } // namespace ns3
117 #endif /* SIMPLE_NET_DEVICE_H */
virtual Address GetAddress(void) const
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
virtual Ptr< Channel > GetChannel(void) const
forward calls to a chain of CallbackAn ns3::TracedCallback has almost exactly the same API as a norma...
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)
simple net device for simple things and testing
virtual bool IsPointToPoint(void) const
Return true if the net device is on a point-to-point link.
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)
virtual Ptr< Node > GetNode(void) const
Describes an IPv6 address.
Definition: ipv6-address.h:44
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:38
TracedCallback< Ptr< const Packet > > m_phyRxDropTrace
Network layer to device interface.
Definition: net-device.h:75
virtual void AddLinkChangeCallback(Callback< void > callback)
virtual void SetAddress(Address address)
virtual void DoDispose(void)
virtual bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
virtual bool IsBridge(void) const
Return true if the net device is acting as a bridge.
a unique identifier for an interface.
Definition: type-id.h:44
virtual Address GetBroadcast(void) const
virtual uint32_t GetIfIndex(void) const
virtual bool SupportsSendFrom(void) const
virtual bool IsLinkUp(void) const