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 | 31 |
32 #define NS_LOG_APPEND_CONTEXT \ | 32 #define NS_LOG_APPEND_CONTEXT \ |
33 if (GetObject<Node> ()) { std::clog << "[node " << GetObject<Node> ()->GetId (
) << "] "; } | 33 if (GetObject<Node> ()) { std::clog << "[node " << GetObject<Node> ()->GetId (
) << "] "; } |
34 | 34 |
35 | 35 |
36 #include "olsr-routing-protocol.h" | 36 #include "olsr-routing-protocol.h" |
37 #include "ns3/socket-factory.h" | 37 #include "ns3/socket-factory.h" |
38 #include "ns3/udp-socket-factory.h" | 38 #include "ns3/udp-socket-factory.h" |
39 #include "ns3/simulator.h" | 39 #include "ns3/simulator.h" |
40 #include "ns3/log.h" | 40 #include "ns3/log.h" |
| 41 #include "ns3/names.h" |
41 #include "ns3/random-variable.h" | 42 #include "ns3/random-variable.h" |
42 #include "ns3/inet-socket-address.h" | 43 #include "ns3/inet-socket-address.h" |
43 #include "ns3/ipv4-routing-protocol.h" | 44 #include "ns3/ipv4-routing-protocol.h" |
44 #include "ns3/ipv4-routing-table-entry.h" | 45 #include "ns3/ipv4-routing-table-entry.h" |
45 #include "ns3/ipv4-route.h" | 46 #include "ns3/ipv4-route.h" |
46 #include "ns3/boolean.h" | 47 #include "ns3/boolean.h" |
47 #include "ns3/uinteger.h" | 48 #include "ns3/uinteger.h" |
48 #include "ns3/enum.h" | 49 #include "ns3/enum.h" |
49 #include "ns3/trace-source-accessor.h" | 50 #include "ns3/trace-source-accessor.h" |
50 #include "ns3/ipv4-header.h" | 51 #include "ns3/ipv4-header.h" |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 for (std::map< Ptr<Socket>, Ipv4InterfaceAddress >::iterator iter = m_socketAd
dresses.begin (); | 238 for (std::map< Ptr<Socket>, Ipv4InterfaceAddress >::iterator iter = m_socketAd
dresses.begin (); |
238 iter != m_socketAddresses.end (); iter++) | 239 iter != m_socketAddresses.end (); iter++) |
239 { | 240 { |
240 iter->first->Close (); | 241 iter->first->Close (); |
241 } | 242 } |
242 m_socketAddresses.clear (); | 243 m_socketAddresses.clear (); |
243 | 244 |
244 Ipv4RoutingProtocol::DoDispose (); | 245 Ipv4RoutingProtocol::DoDispose (); |
245 } | 246 } |
246 | 247 |
| 248 void |
| 249 RoutingProtocol::PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const |
| 250 { |
| 251 std::ostream* os = stream->GetStream(); |
| 252 *os << "Destination\tNextHop\t\tInterface\tDistance\n"; |
| 253 |
| 254 for (std::map<Ipv4Address, RoutingTableEntry>::const_iterator iter = m_table.b
egin (); |
| 255 iter != m_table.end (); iter++) |
| 256 { |
| 257 *os << iter->first << "\t"; |
| 258 *os << iter->second.nextAddr << "\t"; |
| 259 if (Names::FindName (m_ipv4->GetNetDevice (iter->second.interface)) != "") |
| 260 { |
| 261 *os << Names::FindName (m_ipv4->GetNetDevice (iter->second.interfa
ce)) << "\t\t"; |
| 262 } |
| 263 else |
| 264 { |
| 265 *os << iter->second.interface << "\t\t"; |
| 266 } |
| 267 |
| 268 *os << iter->second.distance << "\t"; |
| 269 *os << "\n"; |
| 270 } |
| 271 } |
| 272 |
247 void RoutingProtocol::DoStart () | 273 void RoutingProtocol::DoStart () |
248 { | 274 { |
249 if (m_mainAddress == Ipv4Address ()) | 275 if (m_mainAddress == Ipv4Address ()) |
250 { | 276 { |
251 Ipv4Address loopback ("127.0.0.1"); | 277 Ipv4Address loopback ("127.0.0.1"); |
252 for (uint32_t i = 0; i < m_ipv4->GetNInterfaces (); i++) | 278 for (uint32_t i = 0; i < m_ipv4->GetNInterfaces (); i++) |
253 { | 279 { |
254 // Use primary address, if multiple | 280 // Use primary address, if multiple |
255 Ipv4Address addr = m_ipv4->GetAddress (i, 0).GetLocal (); | 281 Ipv4Address addr = m_ipv4->GetAddress (i, 0).GetLocal (); |
256 if (addr != loopback) | 282 if (addr != loopback) |
(...skipping 3086 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3343 { | 3369 { |
3344 NS_LOG_DEBUG (" dest=" << iter->first << " --> next=" << iter->second.nex
tAddr << " via interface " << iter->second.interface); | 3370 NS_LOG_DEBUG (" dest=" << iter->first << " --> next=" << iter->second.nex
tAddr << " via interface " << iter->second.interface); |
3345 } | 3371 } |
3346 NS_LOG_DEBUG (""); | 3372 NS_LOG_DEBUG (""); |
3347 #endif //NS3_LOG_ENABLE | 3373 #endif //NS3_LOG_ENABLE |
3348 } | 3374 } |
3349 | 3375 |
3350 }} // namespace olsr, ns3 | 3376 }} // namespace olsr, ns3 |
3351 | 3377 |
3352 | 3378 |
OLD | NEW |