A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
error-net-device.h
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2011 Universita' di Firenze, Italy
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: Tommaso Pecorella <tommaso.pecorella@unifi.it>
19  */
20 #ifndef ERROR_NET_DEVICE_H
21 #define ERROR_NET_DEVICE_H
22 
23 #include "ns3/net-device.h"
24 #include "ns3/mac48-address.h"
25 #include <stdint.h>
26 #include <string>
27 #include "ns3/traced-callback.h"
28 
29 namespace ns3 {
30 
31 class ErrorChannel;
32 class Node;
33 class ErrorModel;
34 
45 class ErrorNetDevice : public NetDevice
46 {
47 public:
48  static TypeId GetTypeId (void);
49  ErrorNetDevice ();
50 
51  void Receive (Ptr<Packet> packet, uint16_t protocol, Mac48Address to, Mac48Address from);
52  void SetChannel (Ptr<ErrorChannel> channel);
53 
64 
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;
87 
88  virtual Address GetMulticast (Ipv6Address addr) const;
89 
91  virtual bool SupportsSendFrom (void) const;
92 
93 protected:
94  virtual void DoDispose (void);
95 private:
96  Ptr<ErrorChannel> 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 };
114 
115 } // namespace ns3
116 
117 #endif /* Error_NET_DEVICE_H */
virtual uint32_t GetIfIndex(void) const
virtual Address GetBroadcast(void) const
virtual void SetPromiscReceiveCallback(PromiscReceiveCallback cb)
virtual Address GetMulticast(Ipv4Address multicastGroup) const
Make and return a MAC multicast address using the provided multicast group.
forward calls to a chain of CallbackAn ns3::TracedCallback has almost exactly the same API as a norma...
virtual bool SetMtu(const uint16_t mtu)
virtual bool IsBroadcast(void) const
virtual bool IsLinkUp(void) const
virtual Address GetAddress(void) const
virtual void SetIfIndex(const uint32_t index)
a polymophic address class
Definition: address.h:86
virtual bool IsPointToPoint(void) const
Return true if the net device is on a point-to-point link.
virtual bool SupportsSendFrom(void) const
Error net device for Error things and testing.
virtual Ptr< Channel > GetChannel(void) const
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
virtual bool IsBridge(void) const
Return true if the net device is acting as a bridge.
virtual uint16_t GetMtu(void) const
virtual void SetNode(Ptr< Node > node)
void SetReceiveErrorModel(Ptr< ErrorModel > em)
an EUI-48 address
Definition: mac48-address.h:41
virtual void SetAddress(Address address)
TracedCallback< Ptr< const Packet > > m_phyRxDropTrace
virtual bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
Describes an IPv6 address.
Definition: ipv6-address.h:44
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:38
Network layer to device interface.
Definition: net-device.h:75
virtual Ptr< Node > GetNode(void) const
virtual bool NeedsArp(void) const
virtual void DoDispose(void)
virtual void AddLinkChangeCallback(Callback< void > callback)
virtual bool IsMulticast(void) const
a unique identifier for an interface.
Definition: type-id.h:44
virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb)