OLD | NEW |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2004 Francisco J. Ros· | 3 * Copyright (c) 2004 Francisco J. Ros· |
4 * Copyright (c) 2007 INESC Porto | 4 * Copyright (c) 2007 INESC Porto |
5 * | 5 * |
6 * This program is free software; you can redistribute it and/or modify | 6 * This program is free software; you can redistribute it and/or modify |
7 * it under the terms of the GNU General Public License version 2 as | 7 * it under the terms of the GNU General Public License version 2 as |
8 * published by the Free Software Foundation; | 8 * published by the Free Software Foundation; |
9 * | 9 * |
10 * This program is distributed in the hope that it will be useful, | 10 * This program is distributed in the hope that it will be useful, |
(...skipping 20 matching lines...) Expand all Loading... |
31 #define NS_LOG_APPEND_CONTEXT \ | 31 #define NS_LOG_APPEND_CONTEXT \ |
32 if (GetObject<Node> ()) { std::clog << "[node " << GetObject<Node> ()->GetId (
) << "] "; } | 32 if (GetObject<Node> ()) { std::clog << "[node " << GetObject<Node> ()->GetId (
) << "] "; } |
33 | 33 |
34 | 34 |
35 #include "olsr-routing-protocol.h" | 35 #include "olsr-routing-protocol.h" |
36 #include "ns3/socket-factory.h" | 36 #include "ns3/socket-factory.h" |
37 #include "ns3/udp-socket-factory.h" | 37 #include "ns3/udp-socket-factory.h" |
38 #include "ns3/simulator.h" | 38 #include "ns3/simulator.h" |
39 #include "ns3/log.h" | 39 #include "ns3/log.h" |
40 #include "ns3/names.h" | 40 #include "ns3/names.h" |
41 #include "ns3/random-variable.h" | |
42 #include "ns3/inet-socket-address.h" | 41 #include "ns3/inet-socket-address.h" |
43 #include "ns3/ipv4-routing-protocol.h" | 42 #include "ns3/ipv4-routing-protocol.h" |
44 #include "ns3/ipv4-routing-table-entry.h" | 43 #include "ns3/ipv4-routing-table-entry.h" |
45 #include "ns3/ipv4-route.h" | 44 #include "ns3/ipv4-route.h" |
46 #include "ns3/boolean.h" | 45 #include "ns3/boolean.h" |
47 #include "ns3/uinteger.h" | 46 #include "ns3/uinteger.h" |
48 #include "ns3/enum.h" | 47 #include "ns3/enum.h" |
49 #include "ns3/trace-source-accessor.h" | 48 #include "ns3/trace-source-accessor.h" |
50 #include "ns3/ipv4-header.h" | 49 #include "ns3/ipv4-header.h" |
51 | 50 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 #define OLSR_WILL_ALWAYS 7 | 117 #define OLSR_WILL_ALWAYS 7 |
119 | 118 |
120 | 119 |
121 /********** Miscellaneous constants **********/ | 120 /********** Miscellaneous constants **********/ |
122 | 121 |
123 /// Maximum allowed jitter. | 122 /// Maximum allowed jitter. |
124 #define OLSR_MAXJITTER (m_helloInterval.GetSeconds () / 4) | 123 #define OLSR_MAXJITTER (m_helloInterval.GetSeconds () / 4) |
125 /// Maximum allowed sequence number. | 124 /// Maximum allowed sequence number. |
126 #define OLSR_MAX_SEQ_NUM 65535 | 125 #define OLSR_MAX_SEQ_NUM 65535 |
127 /// Random number between [0-OLSR_MAXJITTER] used to jitter OLSR packet transmis
sion. | 126 /// Random number between [0-OLSR_MAXJITTER] used to jitter OLSR packet transmis
sion. |
128 #define JITTER (Seconds (UniformVariable ().GetValue (0, OLSR_MAXJITTER))) | 127 #define JITTER (Seconds (m_uniformRandomVariable->GetValue (0, OLSR_MAXJITTER))) |
129 | 128 |
130 | 129 |
131 #define OLSR_PORT_NUMBER 698 | 130 #define OLSR_PORT_NUMBER 698 |
132 /// Maximum number of messages per packet. | 131 /// Maximum number of messages per packet. |
133 #define OLSR_MAX_MSGS 64 | 132 #define OLSR_MAX_MSGS 64 |
134 | 133 |
135 /// Maximum number of hellos per message (4 possible link types * 3 possible nb
types). | 134 /// Maximum number of hellos per message (4 possible link types * 3 possible nb
types). |
136 #define OLSR_MAX_HELLOS 12 | 135 #define OLSR_MAX_HELLOS 12 |
137 | 136 |
138 /// Maximum number of addresses advertised on a message. | 137 /// Maximum number of addresses advertised on a message. |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 | 191 |
193 RoutingProtocol::RoutingProtocol () | 192 RoutingProtocol::RoutingProtocol () |
194 : m_routingTableAssociation (0), | 193 : m_routingTableAssociation (0), |
195 m_ipv4 (0), | 194 m_ipv4 (0), |
196 m_helloTimer (Timer::CANCEL_ON_DESTROY), | 195 m_helloTimer (Timer::CANCEL_ON_DESTROY), |
197 m_tcTimer (Timer::CANCEL_ON_DESTROY), | 196 m_tcTimer (Timer::CANCEL_ON_DESTROY), |
198 m_midTimer (Timer::CANCEL_ON_DESTROY), | 197 m_midTimer (Timer::CANCEL_ON_DESTROY), |
199 m_hnaTimer (Timer::CANCEL_ON_DESTROY), | 198 m_hnaTimer (Timer::CANCEL_ON_DESTROY), |
200 m_queuedMessagesTimer (Timer::CANCEL_ON_DESTROY) | 199 m_queuedMessagesTimer (Timer::CANCEL_ON_DESTROY) |
201 { | 200 { |
| 201 m_uniformRandomVariable = CreateObject<UniformRandomVariable> (); |
| 202 |
202 m_hnaRoutingTable = Create<Ipv4StaticRouting> (); | 203 m_hnaRoutingTable = Create<Ipv4StaticRouting> (); |
203 } | 204 } |
204 | 205 |
205 RoutingProtocol::~RoutingProtocol () | 206 RoutingProtocol::~RoutingProtocol () |
206 { | 207 { |
207 } | 208 } |
208 | 209 |
209 void | 210 void |
210 RoutingProtocol::SetIpv4 (Ptr<Ipv4> ipv4) | 211 RoutingProtocol::SetIpv4 (Ptr<Ipv4> ipv4) |
211 { | 212 { |
(...skipping 3081 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3293 { | 3294 { |
3294 std::vector<RoutingTableEntry> retval; | 3295 std::vector<RoutingTableEntry> retval; |
3295 for (std::map<Ipv4Address, RoutingTableEntry>::const_iterator iter = m_table.b
egin (); | 3296 for (std::map<Ipv4Address, RoutingTableEntry>::const_iterator iter = m_table.b
egin (); |
3296 iter != m_table.end (); iter++) | 3297 iter != m_table.end (); iter++) |
3297 { | 3298 { |
3298 retval.push_back (iter->second); | 3299 retval.push_back (iter->second); |
3299 } | 3300 } |
3300 return retval; | 3301 return retval; |
3301 } | 3302 } |
3302 | 3303 |
| 3304 int64_t |
| 3305 RoutingProtocol::AssignStreams (int64_t stream) |
| 3306 { |
| 3307 NS_LOG_FUNCTION (this << stream); |
| 3308 m_uniformRandomVariable->SetStream (stream); |
| 3309 return 1; |
| 3310 } |
| 3311 |
3303 bool | 3312 bool |
3304 RoutingProtocol::IsMyOwnAddress (const Ipv4Address & a) const | 3313 RoutingProtocol::IsMyOwnAddress (const Ipv4Address & a) const |
3305 { | 3314 { |
3306 for (std::map<Ptr<Socket>, Ipv4InterfaceAddress>::const_iterator j = | 3315 for (std::map<Ptr<Socket>, Ipv4InterfaceAddress>::const_iterator j = |
3307 m_socketAddresses.begin (); j != m_socketAddresses.end (); ++j) | 3316 m_socketAddresses.begin (); j != m_socketAddresses.end (); ++j) |
3308 { | 3317 { |
3309 Ipv4InterfaceAddress iface = j->second; | 3318 Ipv4InterfaceAddress iface = j->second; |
3310 if (a == iface.GetLocal ()) | 3319 if (a == iface.GetLocal ()) |
3311 { | 3320 { |
3312 return true; | 3321 return true; |
(...skipping 29 matching lines...) Expand all Loading... |
3342 NS_LOG_DEBUG (" dest=" << iter->first << " --> next=" << iter->second.nex
tAddr << " via interface " << iter->second.interface); | 3351 NS_LOG_DEBUG (" dest=" << iter->first << " --> next=" << iter->second.nex
tAddr << " via interface " << iter->second.interface); |
3343 } | 3352 } |
3344 NS_LOG_DEBUG (""); | 3353 NS_LOG_DEBUG (""); |
3345 #endif //NS3_LOG_ENABLE | 3354 #endif //NS3_LOG_ENABLE |
3346 } | 3355 } |
3347 | 3356 |
3348 } // namespace olsr | 3357 } // namespace olsr |
3349 } // namespace ns3 | 3358 } // namespace ns3 |
3350 | 3359 |
3351 | 3360 |
OLD | NEW |