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
NS_LOG_FUNCTION
(
this
);
46
}
47
48
void
49
SimpleChannel::Send
(
Ptr<Packet>
p, uint16_t protocol,
50
Mac48Address
to,
Mac48Address
from,
51
Ptr<SimpleNetDevice>
sender)
52
{
53
NS_LOG_FUNCTION
(
this
<< p << protocol << to << from << sender);
54
for
(std::vector<
Ptr<SimpleNetDevice>
>::const_iterator i =
m_devices
.begin (); i !=
m_devices
.end (); ++i)
55
{
56
Ptr<SimpleNetDevice>
tmp = *i;
57
if
(tmp == sender)
58
{
59
continue
;
60
}
61
Simulator::ScheduleWithContext
(tmp->
GetNode
()->
GetId
(),
Seconds
(0),
62
&
SimpleNetDevice::Receive
, tmp, p->
Copy
(), protocol, to, from);
63
}
64
}
65
66
void
67
SimpleChannel::Add
(
Ptr<SimpleNetDevice>
device)
68
{
69
NS_LOG_FUNCTION
(
this
<< device);
70
m_devices
.push_back (device);
71
}
72
73
uint32_t
74
SimpleChannel::GetNDevices
(
void
)
const
75
{
76
NS_LOG_FUNCTION
(
this
);
77
return
m_devices
.size ();
78
}
79
Ptr<NetDevice>
80
SimpleChannel::GetDevice
(uint32_t i)
const
81
{
82
NS_LOG_FUNCTION
(
this
<< i);
83
return
m_devices
[i];
84
}
85
86
}
// namespace ns3
src
network
utils
simple-channel.cc
Generated on Tue May 14 2013 11:08:31 for ns-3 by
1.8.1.2