author | Peter D. Barnes, Jr. <barnes26@llnl.gov> |
Fri, 26 Sep 2014 15:51:00 -0700 | |
changeset 10968 | 2d29fee2b7b8 |
parent 10218 | 97da49da2d6c |
permissions | -rw-r--r-- |
7385
10beb0e53130
standardize emacs c++ mode comments
Vedran Miletić <rivanvx@gmail.com>
parents:
7178
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
5079
245215e5e6ed
Added flame rtable, fixed DoDispose in HwmpRtable
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
2 |
/* |
245215e5e6ed
Added flame rtable, fixed DoDispose in HwmpRtable
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
3 |
* Copyright (c) 2009 IITP RAS |
245215e5e6ed
Added flame rtable, fixed DoDispose in HwmpRtable
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
4 |
* |
245215e5e6ed
Added flame rtable, fixed DoDispose in HwmpRtable
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
245215e5e6ed
Added flame rtable, fixed DoDispose in HwmpRtable
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License version 2 as |
245215e5e6ed
Added flame rtable, fixed DoDispose in HwmpRtable
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation; |
245215e5e6ed
Added flame rtable, fixed DoDispose in HwmpRtable
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
8 |
* |
245215e5e6ed
Added flame rtable, fixed DoDispose in HwmpRtable
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
245215e5e6ed
Added flame rtable, fixed DoDispose in HwmpRtable
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
245215e5e6ed
Added flame rtable, fixed DoDispose in HwmpRtable
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
245215e5e6ed
Added flame rtable, fixed DoDispose in HwmpRtable
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
245215e5e6ed
Added flame rtable, fixed DoDispose in HwmpRtable
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
13 |
* |
245215e5e6ed
Added flame rtable, fixed DoDispose in HwmpRtable
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
245215e5e6ed
Added flame rtable, fixed DoDispose in HwmpRtable
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
245215e5e6ed
Added flame rtable, fixed DoDispose in HwmpRtable
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
245215e5e6ed
Added flame rtable, fixed DoDispose in HwmpRtable
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
17 |
* |
245215e5e6ed
Added flame rtable, fixed DoDispose in HwmpRtable
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
18 |
* Author: Kirill Andreev <andreev@iitp.ru> |
245215e5e6ed
Added flame rtable, fixed DoDispose in HwmpRtable
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
19 |
*/ |
245215e5e6ed
Added flame rtable, fixed DoDispose in HwmpRtable
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
20 |
|
245215e5e6ed
Added flame rtable, fixed DoDispose in HwmpRtable
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
21 |
#include "flame-protocol-mac.h" |
5080 | 22 |
#include "flame-protocol.h" |
23 |
#include "flame-header.h" |
|
24 |
#include "ns3/log.h" |
|
10968
2d29fee2b7b8
[Bug 1551] Redux: NS_LOG_COMPONENT_DEFINE inside or outside of ns3 namespace?
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10218
diff
changeset
|
25 |
|
5132
aee541a30256
Restored newline at namespace
Kirill Andreev <andreev@iitp.ru>
parents:
5129
diff
changeset
|
26 |
namespace ns3 { |
10968
2d29fee2b7b8
[Bug 1551] Redux: NS_LOG_COMPONENT_DEFINE inside or outside of ns3 namespace?
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10218
diff
changeset
|
27 |
|
2d29fee2b7b8
[Bug 1551] Redux: NS_LOG_COMPONENT_DEFINE inside or outside of ns3 namespace?
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10218
diff
changeset
|
28 |
NS_LOG_COMPONENT_DEFINE ("FlameProtocolMac"); |
2d29fee2b7b8
[Bug 1551] Redux: NS_LOG_COMPONENT_DEFINE inside or outside of ns3 namespace?
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10218
diff
changeset
|
29 |
|
5132
aee541a30256
Restored newline at namespace
Kirill Andreev <andreev@iitp.ru>
parents:
5129
diff
changeset
|
30 |
namespace flame { |
10968
2d29fee2b7b8
[Bug 1551] Redux: NS_LOG_COMPONENT_DEFINE inside or outside of ns3 namespace?
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10218
diff
changeset
|
31 |
|
10218
97da49da2d6c
Fix compilation with Clang 3.2 and newer versions, including Apple Clang 5.0
Vedran Miletić <rivanvx@gmail.com>
parents:
7386
diff
changeset
|
32 |
FlameProtocolMac::FlameProtocolMac (Ptr<FlameProtocol> protocol) : |
97da49da2d6c
Fix compilation with Clang 3.2 and newer versions, including Apple Clang 5.0
Vedran Miletić <rivanvx@gmail.com>
parents:
7386
diff
changeset
|
33 |
m_protocol (protocol) |
5080 | 34 |
{ |
35 |
} |
|
5086
fccfd0073ea3
Fixed names: now protocols are called *-protocol.[h,cc], plugin is called
Kirill Andreev <andreev@iitp.ru>
parents:
5084
diff
changeset
|
36 |
FlameProtocolMac::~FlameProtocolMac () |
5080 | 37 |
{ |
5464
050630fcf15e
Mesh: fixed FLAME PATH_UPDATE procedure, fixed mesh.cc, valgrind errors in
Kirill Andreev <andreev@iitp.ru>
parents:
5157
diff
changeset
|
38 |
m_protocol = 0; |
050630fcf15e
Mesh: fixed FLAME PATH_UPDATE procedure, fixed mesh.cc, valgrind errors in
Kirill Andreev <andreev@iitp.ru>
parents:
5157
diff
changeset
|
39 |
m_parent = 0; |
5080 | 40 |
} |
41 |
void |
|
5086
fccfd0073ea3
Fixed names: now protocols are called *-protocol.[h,cc], plugin is called
Kirill Andreev <andreev@iitp.ru>
parents:
5084
diff
changeset
|
42 |
FlameProtocolMac::SetParent (Ptr<MeshWifiInterfaceMac> parent) |
5080 | 43 |
{ |
44 |
m_parent = parent; |
|
45 |
} |
|
46 |
||
47 |
bool |
|
5086
fccfd0073ea3
Fixed names: now protocols are called *-protocol.[h,cc], plugin is called
Kirill Andreev <andreev@iitp.ru>
parents:
5084
diff
changeset
|
48 |
FlameProtocolMac::Receive (Ptr<Packet> packet, const WifiMacHeader & header) |
5080 | 49 |
{ |
50 |
if (!header.IsData ()) |
|
5129 | 51 |
{ |
52 |
return true; |
|
53 |
} |
|
5080 | 54 |
FlameTag tag; |
5129 | 55 |
if (packet->PeekPacketTag (tag)) |
56 |
{ |
|
57 |
NS_FATAL_ERROR ("FLAME tag is not supposed to be received by network"); |
|
58 |
} |
|
5092 | 59 |
tag.receiver = header.GetAddr1 (); |
60 |
tag.transmitter = header.GetAddr2 (); |
|
5129 | 61 |
if (tag.receiver == Mac48Address::GetBroadcast ()) |
62 |
{ |
|
63 |
m_stats.rxBroadcast++; |
|
64 |
} |
|
5106
de6fe90556c8
Added comments and statistics to flame
Kirill Andreev <andreev@iitp.ru>
parents:
5092
diff
changeset
|
65 |
else |
5129 | 66 |
{ |
67 |
m_stats.rxUnicast++; |
|
68 |
} |
|
5106
de6fe90556c8
Added comments and statistics to flame
Kirill Andreev <andreev@iitp.ru>
parents:
5092
diff
changeset
|
69 |
m_stats.rxBytes += packet->GetSize (); |
5084
ddf23699f0b7
Initial flame implementation
Kirill Andreev <andreev@iitp.ru>
parents:
5082
diff
changeset
|
70 |
packet->AddPacketTag (tag); |
5080 | 71 |
return true; |
72 |
} |
|
73 |
bool |
|
5129 | 74 |
FlameProtocolMac::UpdateOutcomingFrame (Ptr<Packet> packet, WifiMacHeader & header, Mac48Address from, |
7178
1a07cbb68308
mesh coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6882
diff
changeset
|
75 |
Mac48Address to) |
5080 | 76 |
{ |
5129 | 77 |
if (!header.IsData ()) |
78 |
{ |
|
79 |
return true; |
|
80 |
} |
|
5082 | 81 |
FlameTag tag; |
5129 | 82 |
if (!packet->RemovePacketTag (tag)) |
83 |
{ |
|
84 |
NS_FATAL_ERROR ("FLAME tag must exist here"); |
|
85 |
} |
|
5092 | 86 |
header.SetAddr1 (tag.receiver); |
5129 | 87 |
if (tag.receiver == Mac48Address::GetBroadcast ()) |
88 |
{ |
|
89 |
m_stats.txBroadcast++; |
|
90 |
} |
|
5106
de6fe90556c8
Added comments and statistics to flame
Kirill Andreev <andreev@iitp.ru>
parents:
5092
diff
changeset
|
91 |
else |
5129 | 92 |
{ |
93 |
m_stats.txUnicast++; |
|
94 |
} |
|
5106
de6fe90556c8
Added comments and statistics to flame
Kirill Andreev <andreev@iitp.ru>
parents:
5092
diff
changeset
|
95 |
m_stats.txBytes += packet->GetSize (); |
5080 | 96 |
return true; |
97 |
} |
|
98 |
uint16_t |
|
5086
fccfd0073ea3
Fixed names: now protocols are called *-protocol.[h,cc], plugin is called
Kirill Andreev <andreev@iitp.ru>
parents:
5084
diff
changeset
|
99 |
FlameProtocolMac::GetChannelId () const |
5080 | 100 |
{ |
101 |
return m_parent->GetFrequencyChannel (); |
|
102 |
} |
|
5126
8e06088a785d
Statistics removed from headers
Kirill Andreev <andreev@iitp.ru>
parents:
5106
diff
changeset
|
103 |
FlameProtocolMac::Statistics::Statistics () : |
5129 | 104 |
txUnicast (0), txBroadcast (0), txBytes (0), rxUnicast (0), rxBroadcast (0), rxBytes (0) |
105 |
{ |
|
106 |
} |
|
5080 | 107 |
void |
5106
de6fe90556c8
Added comments and statistics to flame
Kirill Andreev <andreev@iitp.ru>
parents:
5092
diff
changeset
|
108 |
FlameProtocolMac::Statistics::Print (std::ostream &os) const |
de6fe90556c8
Added comments and statistics to flame
Kirill Andreev <andreev@iitp.ru>
parents:
5092
diff
changeset
|
109 |
{ |
de6fe90556c8
Added comments and statistics to flame
Kirill Andreev <andreev@iitp.ru>
parents:
5092
diff
changeset
|
110 |
os << "<Statistics " |
7178
1a07cbb68308
mesh coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6882
diff
changeset
|
111 |
"txUnicast=\"" << txUnicast << "\" " |
1a07cbb68308
mesh coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6882
diff
changeset
|
112 |
"txBroadcast=\"" << txBroadcast << "\" " |
1a07cbb68308
mesh coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6882
diff
changeset
|
113 |
"txBytes=\"" << txBytes << "\" " |
1a07cbb68308
mesh coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6882
diff
changeset
|
114 |
"rxUnicast=\"" << rxUnicast << "\" " |
1a07cbb68308
mesh coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6882
diff
changeset
|
115 |
"rxBroadcast=\"" << rxBroadcast << "\" " |
1a07cbb68308
mesh coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6882
diff
changeset
|
116 |
"rxBytes=\"" << rxBytes << "\"/>" << std::endl; |
5106
de6fe90556c8
Added comments and statistics to flame
Kirill Andreev <andreev@iitp.ru>
parents:
5092
diff
changeset
|
117 |
} |
de6fe90556c8
Added comments and statistics to flame
Kirill Andreev <andreev@iitp.ru>
parents:
5092
diff
changeset
|
118 |
void |
5086
fccfd0073ea3
Fixed names: now protocols are called *-protocol.[h,cc], plugin is called
Kirill Andreev <andreev@iitp.ru>
parents:
5084
diff
changeset
|
119 |
FlameProtocolMac::Report (std::ostream & os) const |
5080 | 120 |
{ |
5157
ace422ad12df
Cosmetics: '\n' was replaced with std::endl, Camel case for attributes
Kirill Andreev <andreev@iitp.ru>
parents:
5132
diff
changeset
|
121 |
os << "<FlameProtocolMac" << std::endl << |
7178
1a07cbb68308
mesh coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6882
diff
changeset
|
122 |
"address =\"" << m_parent->GetAddress () << "\">" << std::endl; |
5129 | 123 |
m_stats.Print (os); |
5157
ace422ad12df
Cosmetics: '\n' was replaced with std::endl, Camel case for attributes
Kirill Andreev <andreev@iitp.ru>
parents:
5132
diff
changeset
|
124 |
os << "</FlameProtocolMac>" << std::endl; |
5106
de6fe90556c8
Added comments and statistics to flame
Kirill Andreev <andreev@iitp.ru>
parents:
5092
diff
changeset
|
125 |
|
5080 | 126 |
} |
127 |
void |
|
5086
fccfd0073ea3
Fixed names: now protocols are called *-protocol.[h,cc], plugin is called
Kirill Andreev <andreev@iitp.ru>
parents:
5084
diff
changeset
|
128 |
FlameProtocolMac::ResetStats () |
5080 | 129 |
{ |
5106
de6fe90556c8
Added comments and statistics to flame
Kirill Andreev <andreev@iitp.ru>
parents:
5092
diff
changeset
|
130 |
m_stats = Statistics (); |
5080 | 131 |
} |
132 |
||
7386
2310ed220a61
standardize ns-3 namespace declaration format
Vedran Miletić <rivanvx@gmail.com>
parents:
7385
diff
changeset
|
133 |
} // namespace flame |
2310ed220a61
standardize ns-3 namespace declaration format
Vedran Miletić <rivanvx@gmail.com>
parents:
7385
diff
changeset
|
134 |
} // namespace ns3 |