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
simple-channel.cc
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
#include "
simple-channel.h
"
21
#include "
simple-net-device.h
"
22
#include "ns3/simulator.h"
23
#include "ns3/packet.h"
24
#include "ns3/node.h"
25
#include "ns3/log.h"
26
27
NS_LOG_COMPONENT_DEFINE
(
"SimpleChannel"
);
28
29
namespace
ns3 {
30
31
NS_OBJECT_ENSURE_REGISTERED
(SimpleChannel);
32
33
TypeId
34
SimpleChannel::GetTypeId
(
void
)
35
{
36
static
TypeId
tid =
TypeId
(
"ns3::SimpleChannel"
)
37
.
SetParent
<
Channel
> ()
38
.AddConstructor<SimpleChannel> ()
39
;
40
return
tid;
41
}
42
43
SimpleChannel::SimpleChannel
()
44
{
45
}
46
47
void
48
SimpleChannel::Send
(
Ptr<Packet>
p, uint16_t protocol,
49
Mac48Address
to,
Mac48Address
from,
50
Ptr<SimpleNetDevice>
sender)
51
{
52
NS_LOG_FUNCTION
(p << protocol << to << from << sender);
53
for
(std::vector<
Ptr<SimpleNetDevice>
>::const_iterator i =
m_devices
.begin (); i !=
m_devices
.end (); ++i)
54
{
55
Ptr<SimpleNetDevice>
tmp = *i;
56
if
(tmp == sender)
57
{
58
continue
;
59
}
60
Simulator::ScheduleWithContext
(tmp->
GetNode
()->
GetId
(),
Seconds
(0),
61
&
SimpleNetDevice::Receive
, tmp, p->
Copy
(), protocol, to, from);
62
}
63
}
64
65
void
66
SimpleChannel::Add
(
Ptr<SimpleNetDevice>
device)
67
{
68
m_devices
.push_back (device);
69
}
70
71
uint32_t
72
SimpleChannel::GetNDevices
(
void
)
const
73
{
74
return
m_devices
.size ();
75
}
76
Ptr<NetDevice>
77
SimpleChannel::GetDevice
(uint32_t i)
const
78
{
79
return
m_devices
[i];
80
}
81
82
}
// namespace ns3
src
network
utils
simple-channel.cc
Generated on Tue Oct 9 2012 16:45:45 for ns-3 by
1.8.1.2