akmhoque | 3d06e79 | 2014-05-27 16:23:20 -0500 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (c) 2014 University of Memphis, |
| 4 | * Regents of the University of California |
| 5 | * |
| 6 | * This file is part of NLSR (Named-data Link State Routing). |
| 7 | * See AUTHORS.md for complete list of NLSR authors and contributors. |
| 8 | * |
| 9 | * NLSR is free software: you can redistribute it and/or modify it under the terms |
| 10 | * of the GNU General Public License as published by the Free Software Foundation, |
| 11 | * either version 3 of the License, or (at your option) any later version. |
| 12 | * |
| 13 | * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 14 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 15 | * PURPOSE. See the GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License along with |
| 18 | * NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 19 | * |
| 20 | * \author A K M Mahmudul Hoque <ahoque1@memphis.edu> |
| 21 | * |
| 22 | **/ |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 23 | #ifndef NLSR_ROUTING_TABLE_HPP |
| 24 | #define NLSR_ROUTING_TABLE_HPP |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 25 | |
| 26 | #include <iostream> |
| 27 | #include <utility> |
| 28 | #include <string> |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 29 | #include <boost/cstdint.hpp> |
Vince Lehman | 7c60329 | 2014-09-11 17:48:16 -0500 | [diff] [blame] | 30 | #include <ndn-cxx/util/scheduler.hpp> |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 31 | |
| 32 | #include "routing-table-entry.hpp" |
| 33 | |
| 34 | namespace nlsr { |
| 35 | |
| 36 | class Nlsr; |
| 37 | class NextHop; |
| 38 | |
| 39 | class RoutingTable |
| 40 | { |
| 41 | public: |
Vince Lehman | 7c60329 | 2014-09-11 17:48:16 -0500 | [diff] [blame] | 42 | RoutingTable(ndn::Scheduler& scheduler) |
| 43 | : m_scheduler(scheduler) |
| 44 | , m_NO_NEXT_HOP(-12345) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 45 | { |
| 46 | } |
| 47 | void |
| 48 | calculate(Nlsr& pnlsr); |
| 49 | |
| 50 | void |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 51 | addNextHop(const ndn::Name& destRouter, NextHop& nh); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 52 | |
| 53 | void |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 54 | addNextHopToDryTable(const ndn::Name& destRouter, NextHop& nh); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 55 | |
akmhoque | b6450b1 | 2014-04-24 00:01:03 -0500 | [diff] [blame] | 56 | RoutingTableEntry* |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 57 | findRoutingTableEntry(const ndn::Name& destRouter); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 58 | |
| 59 | void |
| 60 | scheduleRoutingTableCalculation(Nlsr& pnlsr); |
| 61 | |
| 62 | int |
| 63 | getNoNextHop() |
| 64 | { |
| 65 | return m_NO_NEXT_HOP; |
| 66 | } |
| 67 | |
| 68 | private: |
| 69 | void |
| 70 | calculateLsRoutingTable(Nlsr& pnlsr); |
| 71 | |
| 72 | void |
| 73 | calculateHypRoutingTable(Nlsr& pnlsr); |
| 74 | |
| 75 | void |
| 76 | calculateHypDryRoutingTable(Nlsr& pnlsr); |
| 77 | |
| 78 | void |
| 79 | clearRoutingTable(); |
| 80 | |
| 81 | void |
| 82 | clearDryRoutingTable(); |
| 83 | |
akmhoque | 674b0b1 | 2014-05-20 14:33:28 -0500 | [diff] [blame] | 84 | void |
akmhoque | dcee936 | 2014-08-05 22:58:01 -0500 | [diff] [blame] | 85 | writeLog(int hyperbolicState); |
akmhoque | 674b0b1 | 2014-05-20 14:33:28 -0500 | [diff] [blame] | 86 | |
Vince Lehman | 7c60329 | 2014-09-11 17:48:16 -0500 | [diff] [blame] | 87 | private: |
| 88 | ndn::Scheduler& m_scheduler; |
| 89 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 90 | const int m_NO_NEXT_HOP; |
| 91 | |
| 92 | std::list<RoutingTableEntry> m_rTable; |
| 93 | std::list<RoutingTableEntry> m_dryTable; |
| 94 | }; |
| 95 | |
| 96 | }//namespace nlsr |
| 97 | |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 98 | #endif //NLSR_ROUTING_TABLE_HPP |