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
flame-protocol-mac.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2009 IITP RAS
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: Kirill Andreev <andreev@iitp.ru>
19
*/
20
21
#include "
flame-protocol-mac.h
"
22
#include "
flame-protocol.h
"
23
#include "
flame-header.h
"
24
#include "ns3/log.h"
25
namespace
ns3 {
26
namespace
flame {
27
NS_LOG_COMPONENT_DEFINE
(
"FlameProtocolMac"
);
28
FlameProtocolMac::FlameProtocolMac
(
Ptr<FlameProtocol>
protocol) :
29
m_protocol (protocol)
30
{
31
}
32
FlameProtocolMac::~FlameProtocolMac
()
33
{
34
m_protocol
= 0;
35
m_parent
= 0;
36
}
37
void
38
FlameProtocolMac::SetParent
(
Ptr<MeshWifiInterfaceMac>
parent)
39
{
40
m_parent
= parent;
41
}
42
43
bool
44
FlameProtocolMac::Receive
(
Ptr<Packet>
packet,
const
WifiMacHeader
& header)
45
{
46
if
(!header.
IsData
())
47
{
48
return
true
;
49
}
50
FlameTag
tag;
51
if
(packet->
PeekPacketTag
(tag))
52
{
53
NS_FATAL_ERROR
(
"FLAME tag is not supposed to be received by network"
);
54
}
55
tag.
receiver
= header.
GetAddr1
();
56
tag.
transmitter
= header.
GetAddr2
();
57
if
(tag.
receiver
==
Mac48Address::GetBroadcast
())
58
{
59
m_stats
.
rxBroadcast
++;
60
}
61
else
62
{
63
m_stats
.
rxUnicast
++;
64
}
65
m_stats
.
rxBytes
+= packet->
GetSize
();
66
packet->
AddPacketTag
(tag);
67
return
true
;
68
}
69
bool
70
FlameProtocolMac::UpdateOutcomingFrame
(
Ptr<Packet>
packet,
WifiMacHeader
& header,
Mac48Address
from,
71
Mac48Address
to)
72
{
73
if
(!header.
IsData
())
74
{
75
return
true
;
76
}
77
FlameTag
tag;
78
if
(!packet->
RemovePacketTag
(tag))
79
{
80
NS_FATAL_ERROR
(
"FLAME tag must exist here"
);
81
}
82
header.
SetAddr1
(tag.
receiver
);
83
if
(tag.
receiver
==
Mac48Address::GetBroadcast
())
84
{
85
m_stats
.
txBroadcast
++;
86
}
87
else
88
{
89
m_stats
.
txUnicast
++;
90
}
91
m_stats
.
txBytes
+= packet->
GetSize
();
92
return
true
;
93
}
94
uint16_t
95
FlameProtocolMac::GetChannelId
()
const
96
{
97
return
m_parent
->GetFrequencyChannel ();
98
}
99
FlameProtocolMac::Statistics::Statistics
() :
100
txUnicast (0), txBroadcast (0), txBytes (0), rxUnicast (0), rxBroadcast (0), rxBytes (0)
101
{
102
}
103
void
104
FlameProtocolMac::Statistics::Print
(std::ostream &os)
const
105
{
106
os <<
"<Statistics "
107
"txUnicast=\""
<< txUnicast <<
"\" "
108
"txBroadcast=\""
<< txBroadcast <<
"\" "
109
"txBytes=\""
<< txBytes <<
"\" "
110
"rxUnicast=\""
<< rxUnicast <<
"\" "
111
"rxBroadcast=\""
<< rxBroadcast <<
"\" "
112
"rxBytes=\""
<< rxBytes <<
"\"/>"
<< std::endl;
113
}
114
void
115
FlameProtocolMac::Report
(std::ostream & os)
const
116
{
117
os <<
"<FlameProtocolMac"
<< std::endl <<
118
"address =\""
<<
m_parent
->GetAddress () <<
"\">"
<< std::endl;
119
m_stats
.
Print
(os);
120
os <<
"</FlameProtocolMac>"
<< std::endl;
121
122
}
123
void
124
FlameProtocolMac::ResetStats
()
125
{
126
m_stats
=
Statistics
();
127
}
128
129
}
// namespace flame
130
}
// namespace ns3
ns3::flame::FlameProtocolMac::Statistics::Statistics
Statistics()
Definition:
flame-protocol-mac.cc:99
ns3::Ptr
smart pointer class similar to boost::intrusive_ptr
Definition:
ptr.h:59
ns3::flame::FlameProtocolMac::Statistics::rxBytes
uint32_t rxBytes
Definition:
flame-protocol-mac.h:70
ns3::Packet::AddPacketTag
void AddPacketTag(const Tag &tag) const
Add a packet tag.
Definition:
packet.cc:841
ns3::flame::FlameProtocolMac::Statistics::Print
void Print(std::ostream &os) const
Definition:
flame-protocol-mac.cc:104
ns3::flame::FlameProtocolMac::Statistics::txBytes
uint32_t txBytes
Definition:
flame-protocol-mac.h:67
ns3::flame::FlameProtocolMac::Report
void Report(std::ostream &) const
Report statistics.
Definition:
flame-protocol-mac.cc:115
ns3::Packet::GetSize
uint32_t GetSize(void) const
Definition:
packet.h:650
ns3::flame::FlameProtocolMac::Statistics
Definition:
flame-protocol-mac.h:63
ns3::flame::FlameProtocolMac::m_stats
Statistics m_stats
Definition:
flame-protocol-mac.h:75
NS_FATAL_ERROR
#define NS_FATAL_ERROR(msg)
fatal error handling
Definition:
fatal-error.h:72
ns3::flame::FlameProtocolMac::ResetStats
void ResetStats()
Definition:
flame-protocol-mac.cc:124
ns3::Packet::PeekPacketTag
bool PeekPacketTag(Tag &tag) const
Search a matching tag and call Tag::Deserialize if it is found.
Definition:
packet.cc:863
ns3::WifiMacHeader::SetAddr1
void SetAddr1(Mac48Address address)
Fill the Address 1 field with the given address.
Definition:
wifi-mac-header.cc:83
ns3::flame::FlameProtocolMac::m_parent
Ptr< MeshWifiInterfaceMac > m_parent
Definition:
flame-protocol-mac.h:59
ns3::Mac48Address::GetBroadcast
static Mac48Address GetBroadcast(void)
Definition:
mac48-address.cc:165
ns3::flame::FlameProtocolMac::UpdateOutcomingFrame
bool UpdateOutcomingFrame(Ptr< Packet > packet, WifiMacHeader &header, Mac48Address from, Mac48Address to)
Update beacon is empty, because HWMP does not know anything about beacons.
Definition:
flame-protocol-mac.cc:70
flame-header.h
flame-protocol.h
flame-protocol-mac.h
ns3::flame::FlameProtocolMac::Statistics::txBroadcast
uint16_t txBroadcast
Definition:
flame-protocol-mac.h:66
ns3::Mac48Address
an EUI-48 address
Definition:
mac48-address.h:41
ns3::flame::FlameProtocolMac::Statistics::rxBroadcast
uint16_t rxBroadcast
Definition:
flame-protocol-mac.h:69
ns3::flame::FlameProtocolMac::~FlameProtocolMac
~FlameProtocolMac()
Definition:
flame-protocol-mac.cc:32
ns3::flame::FlameProtocolMac::FlameProtocolMac
FlameProtocolMac(Ptr< FlameProtocol >)
Definition:
flame-protocol-mac.cc:28
ns3::WifiMacHeader::IsData
bool IsData(void) const
Return true if the Type is DATA.
Definition:
wifi-mac-header.cc:575
ns3::flame::NS_LOG_COMPONENT_DEFINE
NS_LOG_COMPONENT_DEFINE("FlameProtocolMac")
ns3::Packet::RemovePacketTag
bool RemovePacketTag(Tag &tag)
Remove a packet tag.
Definition:
packet.cc:848
ns3::flame::FlameTag::receiver
Mac48Address receiver
Receiver of the packet:
Definition:
flame-protocol.h:60
ns3::flame::FlameProtocolMac::m_protocol
Ptr< FlameProtocol > m_protocol
Definition:
flame-protocol-mac.h:58
ns3::WifiMacHeader::GetAddr1
Mac48Address GetAddr1(void) const
Return the address in the Address 1 field.
Definition:
wifi-mac-header.cc:417
ns3::flame::FlameProtocolMac::SetParent
void SetParent(Ptr< MeshWifiInterfaceMac > parent)
Update beacon is empty, because HWMP does not know anything about beacons.
Definition:
flame-protocol-mac.cc:38
ns3::flame::FlameProtocolMac::Statistics::rxUnicast
uint16_t rxUnicast
Definition:
flame-protocol-mac.h:68
ns3::flame::FlameProtocolMac::Statistics::txUnicast
uint16_t txUnicast
Definition:
flame-protocol-mac.h:65
ns3::flame::FlameProtocolMac::GetChannelId
uint16_t GetChannelId() const
Definition:
flame-protocol-mac.cc:95
ns3::flame::FlameProtocolMac::Receive
bool Receive(Ptr< Packet > packet, const WifiMacHeader &header)
Update beacon is empty, because HWMP does not know anything about beacons.
Definition:
flame-protocol-mac.cc:44
ns3::WifiMacHeader
Implements the IEEE 802.11 MAC header.
Definition:
wifi-mac-header.h:80
ns3::WifiMacHeader::GetAddr2
Mac48Address GetAddr2(void) const
Return the address in the Address 2 field.
Definition:
wifi-mac-header.cc:422
ns3::flame::FlameTag
Transmitter and receiver addresses.
Definition:
flame-protocol.h:54
ns3::flame::FlameTag::transmitter
Mac48Address transmitter
transmitter for incoming:
Definition:
flame-protocol.h:58
src
mesh
model
flame
flame-protocol-mac.cc
Generated on Sat Apr 19 2014 14:07:03 for ns-3 by
1.8.6