A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
flame-rtable.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2009 IITP RAS
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Kirill Andreev <andreev@iitp.ru>
7 */
8
9#ifndef FLAME_RTABLE_H
10#define FLAME_RTABLE_H
11
12#include "ns3/mac48-address.h"
13#include "ns3/nstime.h"
14#include "ns3/object.h"
15
16#include <map>
17
18namespace ns3
19{
20namespace flame
21{
22/**
23 * @ingroup flame
24 *
25 * @brief Routing table for FLAME
26 */
27class FlameRtable : public Object
28{
29 public:
30 /// Means all interfaces
31 const static uint32_t INTERFACE_ANY = 0xffffffff;
32 /// Maximum (the best?) path cost
33 const static uint32_t MAX_COST = 0xff;
34
35 /// Route lookup result, return type of LookupXXX methods
37 {
38 Mac48Address retransmitter; ///< retransmitter
39 uint32_t ifIndex; ///< IF index
40 uint8_t cost; ///< cost
41 uint16_t seqnum; ///< sequence number
42
43 /**
44 * Constructor
45 *
46 * @param r retransmitter MAC address
47 * @param i interfce index
48 * @param c cost
49 * @param s sequence number
50 */
53 uint8_t c = MAX_COST,
54 uint16_t s = 0)
55 : retransmitter(r),
56 ifIndex(i),
57 cost(c),
58 seqnum(s)
59 {
60 }
61
62 /**
63 * @returns True for valid route
64 */
65 bool IsValid() const;
66 /**
67 * Compare route lookup results, used by tests
68 *
69 * @param o the object to compare
70 * @returns true if equal
71 */
72 bool operator==(const LookupResult& o) const;
73 };
74
75 public:
76 /**
77 * @brief Get the type ID.
78 * @return the object TypeId
79 */
80 static TypeId GetTypeId();
81
83 ~FlameRtable() override;
84
85 // Delete copy constructor and assignment operator to avoid misuse
86 FlameRtable(const FlameRtable&) = delete;
88
89 void DoDispose() override;
90
91 /**
92 * Add path
93 *
94 * @param destination the destination address
95 * @param retransmitter the retransmitter address
96 * @param interface the interface
97 * @param cost the cost
98 * @param seqnum the sequence number
99 */
100 void AddPath(const Mac48Address destination,
101 const Mac48Address retransmitter,
102 const uint32_t interface,
103 const uint8_t cost,
104 const uint16_t seqnum);
105 /**
106 * @brief Lookup path to destination
107 * @param destination
108 * @return Broadcast if not found
109 */
110 LookupResult Lookup(Mac48Address destination);
111
112 private:
113 /// Routing table entry
114 struct Route
115 {
116 Mac48Address retransmitter; ///< retransmitter
117 uint32_t interface; ///< interface
118 uint32_t cost; ///< cost
119 Time whenExpire; ///< expire when?
120 uint32_t seqnum; ///< sequence number
121 };
122
123 /// Lifetime parameter
125 /// List of routes
126 std::map<Mac48Address, Route> m_routes;
127};
128
129} // namespace flame
130} // namespace ns3
131#endif /* FLAME_PROTOCOL_H */
an EUI-48 address
static Mac48Address GetBroadcast()
A base class which provides memory management and object aggregation.
Definition object.h:78
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
a unique identifier for an interface.
Definition type-id.h:48
Routing table for FLAME.
LookupResult Lookup(Mac48Address destination)
Lookup path to destination.
void DoDispose() override
Destructor implementation.
static const uint32_t INTERFACE_ANY
Means all interfaces.
void AddPath(const Mac48Address destination, const Mac48Address retransmitter, const uint32_t interface, const uint8_t cost, const uint16_t seqnum)
Add path.
FlameRtable(const FlameRtable &)=delete
static TypeId GetTypeId()
Get the type ID.
std::map< Mac48Address, Route > m_routes
List of routes.
Time m_lifetime
Lifetime parameter.
static const uint32_t MAX_COST
Maximum (the best?) path cost.
FlameRtable & operator=(const FlameRtable &)=delete
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Route lookup result, return type of LookupXXX methods.
LookupResult(Mac48Address r=Mac48Address::GetBroadcast(), uint32_t i=INTERFACE_ANY, uint8_t c=MAX_COST, uint16_t s=0)
Constructor.
bool operator==(const LookupResult &o) const
Compare route lookup results, used by tests.
Mac48Address retransmitter
retransmitter
uint32_t seqnum
sequence number
Mac48Address retransmitter
retransmitter