equal
deleted
inserted
replaced
22 |
22 |
23 #include "net-device.h" |
23 #include "net-device.h" |
24 #include "mac48-address.h" |
24 #include "mac48-address.h" |
25 #include <stdint.h> |
25 #include <stdint.h> |
26 #include <string> |
26 #include <string> |
|
27 #include "ns3/traced-callback.h" |
27 |
28 |
28 namespace ns3 { |
29 namespace ns3 { |
29 |
30 |
30 class SimpleChannel; |
31 class SimpleChannel; |
31 class Node; |
32 class Node; |
|
33 class ErrorModel; |
32 |
34 |
33 /** |
35 /** |
34 * \ingroup netdevice |
36 * \ingroup netdevice |
|
37 * |
|
38 * This device does not have a helper and assumes 48-bit mac addressing; |
|
39 * the default address assigned to each device is zero, so you must |
|
40 * assign a real address to use it. There is also the possibility to |
|
41 * add an ErrorModel if you want to force losses on the device. |
35 * |
42 * |
36 * \brief simple net device for simple things and testing |
43 * \brief simple net device for simple things and testing |
37 */ |
44 */ |
38 class SimpleNetDevice : public NetDevice |
45 class SimpleNetDevice : public NetDevice |
39 { |
46 { |
41 static TypeId GetTypeId (void); |
48 static TypeId GetTypeId (void); |
42 SimpleNetDevice (); |
49 SimpleNetDevice (); |
43 |
50 |
44 void Receive (Ptr<Packet> packet, uint16_t protocol, Mac48Address to, Mac48Address from); |
51 void Receive (Ptr<Packet> packet, uint16_t protocol, Mac48Address to, Mac48Address from); |
45 void SetChannel (Ptr<SimpleChannel> channel); |
52 void SetChannel (Ptr<SimpleChannel> channel); |
|
53 |
|
54 /** |
|
55 * Attach a receive ErrorModel to the SimpleNetDevice. |
|
56 * |
|
57 * The SimpleNetDevice may optionally include an ErrorModel in |
|
58 * the packet receive chain. |
|
59 * |
|
60 * \see ErrorModel |
|
61 * \param em Ptr to the ErrorModel. |
|
62 */ |
|
63 void SetReceiveErrorModel(Ptr<ErrorModel> em); |
46 |
64 |
47 // inherited from NetDevice base class. |
65 // inherited from NetDevice base class. |
48 virtual void SetIfIndex(const uint32_t index); |
66 virtual void SetIfIndex(const uint32_t index); |
49 virtual uint32_t GetIfIndex(void) const; |
67 virtual uint32_t GetIfIndex(void) const; |
50 virtual Ptr<Channel> GetChannel (void) const; |
68 virtual Ptr<Channel> GetChannel (void) const; |
80 NetDevice::PromiscReceiveCallback m_promiscCallback; |
98 NetDevice::PromiscReceiveCallback m_promiscCallback; |
81 Ptr<Node> m_node; |
99 Ptr<Node> m_node; |
82 uint16_t m_mtu; |
100 uint16_t m_mtu; |
83 uint32_t m_ifIndex; |
101 uint32_t m_ifIndex; |
84 Mac48Address m_address; |
102 Mac48Address m_address; |
|
103 Ptr<ErrorModel> m_receiveErrorModel; |
|
104 /** |
|
105 * The trace source fired when the phy layer drops a packet it has received |
|
106 * due to the error model being active. Although SimpleNetDevice doesn't |
|
107 * really have a Phy model, we choose this trace source name for alignment |
|
108 * with other trace sources. |
|
109 * |
|
110 * \see class CallBackTraceSource |
|
111 */ |
|
112 TracedCallback<Ptr<const Packet> > m_phyRxDropTrace; |
85 }; |
113 }; |
86 |
114 |
87 } // namespace ns3 |
115 } // namespace ns3 |
88 |
116 |
89 #endif /* SIMPLE_NET_DEVICE_H */ |
117 #endif /* SIMPLE_NET_DEVICE_H */ |