A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
bridge-net-device.h
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* This program is free software; you can redistribute it and/or modify
4
* it under the terms of the GNU General Public License version 2 as
5
* published by the Free Software Foundation;
6
*
7
* This program is distributed in the hope that it will be useful,
8
* but WITHOUT ANY WARRANTY; without even the implied warranty of
9
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
* GNU General Public License for more details.
11
*
12
* You should have received a copy of the GNU General Public License
13
* along with this program; if not, write to the Free Software
14
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15
*
16
* Author: Gustavo Carneiro <gjc@inescporto.pt>
17
*/
18
#ifndef BRIDGE_NET_DEVICE_H
19
#define BRIDGE_NET_DEVICE_H
20
21
#include "ns3/net-device.h"
22
#include "ns3/mac48-address.h"
23
#include "ns3/nstime.h"
24
#include "ns3/bridge-channel.h"
25
#include <stdint.h>
26
#include <string>
27
#include <map>
28
29
namespace
ns3 {
30
31
class
Node;
32
65
class
BridgeNetDevice
:
public
NetDevice
66
{
67
public
:
68
static
TypeId
GetTypeId
(
void
);
69
BridgeNetDevice
();
70
virtual
~BridgeNetDevice
();
71
85
void
AddBridgePort
(
Ptr<NetDevice>
bridgePort);
86
87
uint32_t
GetNBridgePorts
(
void
)
const
;
88
89
Ptr<NetDevice>
GetBridgePort
(uint32_t n)
const
;
90
91
// inherited from NetDevice base class.
92
virtual
void
SetIfIndex
(
const
uint32_t index);
93
virtual
uint32_t
GetIfIndex
(
void
)
const
;
94
virtual
Ptr<Channel>
GetChannel
(
void
)
const
;
95
virtual
void
SetAddress
(
Address
address);
96
virtual
Address
GetAddress
(
void
)
const
;
97
virtual
bool
SetMtu
(
const
uint16_t mtu);
98
virtual
uint16_t
GetMtu
(
void
)
const
;
99
virtual
bool
IsLinkUp
(
void
)
const
;
100
virtual
void
AddLinkChangeCallback
(
Callback<void>
callback);
101
virtual
bool
IsBroadcast
(
void
)
const
;
102
virtual
Address
GetBroadcast
(
void
)
const
;
103
virtual
bool
IsMulticast
(
void
)
const
;
104
virtual
Address
GetMulticast
(
Ipv4Address
multicastGroup)
const
;
105
virtual
bool
IsPointToPoint
(
void
)
const
;
106
virtual
bool
IsBridge
(
void
)
const
;
107
virtual
bool
Send
(
Ptr<Packet>
packet,
const
Address
& dest, uint16_t protocolNumber);
108
virtual
bool
SendFrom
(
Ptr<Packet>
packet,
const
Address
& source,
const
Address
& dest, uint16_t protocolNumber);
109
virtual
Ptr<Node>
GetNode
(
void
)
const
;
110
virtual
void
SetNode
(
Ptr<Node>
node);
111
virtual
bool
NeedsArp
(
void
)
const
;
112
virtual
void
SetReceiveCallback
(
NetDevice::ReceiveCallback
cb);
113
virtual
void
SetPromiscReceiveCallback
(
NetDevice::PromiscReceiveCallback
cb);
114
virtual
bool
SupportsSendFrom
()
const
;
115
virtual
Address
GetMulticast
(
Ipv6Address
addr)
const
;
116
117
protected
:
118
virtual
void
DoDispose
(
void
);
119
120
void
ReceiveFromDevice
(
Ptr<NetDevice>
device,
Ptr<const Packet>
packet, uint16_t protocol,
121
Address
const
&source,
Address
const
&destination,
PacketType
packetType);
122
void
ForwardUnicast
(
Ptr<NetDevice>
incomingPort,
Ptr<const Packet>
packet,
123
uint16_t protocol,
Mac48Address
src,
Mac48Address
dst);
124
void
ForwardBroadcast
(
Ptr<NetDevice>
incomingPort,
Ptr<const Packet>
packet,
125
uint16_t protocol,
Mac48Address
src,
Mac48Address
dst);
126
void
Learn
(
Mac48Address
source,
Ptr<NetDevice>
port
);
127
Ptr<NetDevice>
GetLearnedState
(
Mac48Address
source);
128
129
private
:
130
BridgeNetDevice
(
const
BridgeNetDevice
&);
131
BridgeNetDevice
&
operator =
(
const
BridgeNetDevice
&);
132
133
NetDevice::ReceiveCallback
m_rxCallback
;
134
NetDevice::PromiscReceiveCallback
m_promiscRxCallback
;
135
136
Mac48Address
m_address
;
137
Time
m_expirationTime
;
// time it takes for learned MAC state to expire
138
struct
LearnedState
139
{
140
Ptr<NetDevice>
associatedPort
;
141
Time
expirationTime
;
142
};
143
std::map<Mac48Address, LearnedState>
m_learnState
;
144
Ptr<Node>
m_node
;
145
Ptr<BridgeChannel>
m_channel
;
146
std::vector< Ptr<NetDevice> >
m_ports
;
147
uint32_t
m_ifIndex
;
148
uint16_t
m_mtu
;
149
bool
m_enableLearning
;
150
};
151
152
}
// namespace ns3
153
154
#endif
/* BRIDGE_NET_DEVICE_H */
src
bridge
model
bridge-net-device.h
Generated on Fri Dec 21 2012 19:00:31 for ns-3 by
1.8.1.2