Left: | ||
Right: |
OLD | NEW |
---|---|
(Empty) | |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | |
2 /* | |
3 * Copyright (c) 2015 Amir Modarresi | |
4 * | |
5 * This program is free software; you can redistribute it and/or modify | |
6 * it under the terms of the GNU General Public License version 2 as | |
7 * published by the Free Software Foundation; | |
8 * | |
9 * This program is distributed in the hope that it will be useful, | |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 * GNU General Public License for more details. | |
13 * | |
14 * You should have received a copy of the GNU General Public License | |
15 * along with this program; if not, write to the Free Software | |
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
17 * | |
18 * Author: Amir Modarresi <amodarresi@ittc.ku.edu> | |
19 * | |
20 * James P.G. Sterbenz <jpgs@ittc.ku.edu>, director | |
21 * ResiliNets Research Group http://wiki.ittc.ku.edu/resilinets | |
22 * Information and Telecommunication Technology Center (ITTC) | |
23 * and Department of Electrical Engineering and Computer Science | |
24 * The University of Kansas Lawrence, KS USA. | |
25 * | |
26 * Work supported in part by NSF FIND (Future Internet Design) Program | |
27 * under grant CNS-0626918 (Postmodern Internet Architecture), | |
28 * NSF grant CNS-1050226 (Multilayer Network Resilience Analysis and Experimenta tion on GENI), | |
29 * US Department of Defense (DoD), and ITTC at The University of Kansas. | |
30 */ | |
31 | |
32 #ifndef SIFT_ROUTING_H | |
33 #define SIFT_ROUTING_H | |
34 | |
35 #include <map> | |
36 #include <list> | |
37 #include <vector> | |
38 #include <stdint.h> | |
39 #include <cassert> | |
40 #include <sys/types.h> | |
41 | |
42 #include "ns3/callback.h" | |
43 #include "ns3/object.h" | |
44 #include "ns3/node.h" | |
45 #include "ns3/ptr.h" | |
46 #include "ns3/buffer.h" | |
47 #include "ns3/packet.h" | |
48 #include "ns3/ipv4.h" | |
49 #include "ns3/ip-l4-protocol.h" | |
50 #include "ns3/ipv4-l3-protocol.h" | |
51 #include "ns3/icmpv4-l4-protocol.h" | |
52 #include "ns3/ipv4-interface.h" | |
53 #include "ns3/ipv4-header.h" | |
54 #include "ns3/ipv4-address.h" | |
55 #include "ns3/traced-callback.h" | |
56 #include "ns3/random-variable-stream.h" | |
57 #include "ns3/ipv4-route.h" | |
58 #include "ns3/timer.h" | |
59 #include "ns3/net-device.h" | |
60 #include "ns3/output-stream-wrapper.h" | |
61 #include "ns3/socket.h" | |
62 #include "ns3/event-garbage-collector.h" | |
63 #include "ns3/test.h" | |
64 #include "sift-repository.h" | |
65 | |
66 #include "sift-header.h" | |
67 #include "sift-geo.h" | |
68 | |
69 namespace ns3 { | |
70 | |
71 class Packet; | |
72 class Node; | |
73 class Ipv4; | |
74 class Ipv4Address; | |
75 class Ipv4Header; | |
76 class Ipv4Interface; | |
77 class Ipv4L3Protocol; | |
78 class Time; | |
79 | |
80 namespace sift { | |
81 | |
82 /** | |
83 * \class SiftRouting | |
84 * \brief Dsr Routing base | |
Tom Henderson
2015/12/08 01:12:04
more documentation needed (delete 'Dsr')
Amir.Arc
2016/10/17 03:53:24
Done.
| |
85 */ | |
86 class SiftRouting : public IpL4Protocol | |
87 { | |
88 public: | |
89 /** | |
90 * \brief Get the type identificator. | |
91 * \return type identificator | |
92 */ | |
93 static TypeId GetTypeId (); | |
94 /** | |
95 * \brief Define the sift protocol number. | |
96 */ | |
97 static const uint8_t PROT_NUMBER; | |
98 /** | |
99 * \brief Constructor. | |
100 */ | |
101 SiftRouting (); | |
102 /** | |
103 * \brief Destructor. | |
104 */ | |
105 virtual ~SiftRouting (); | |
106 /** | |
107 * \brief Get the node. | |
108 * \return the node | |
109 */ | |
110 void PrintSiftHeader (SiftHeader, GeographicTuple); | |
111 Ptr<Node> GetNode () const; | |
112 /** | |
113 * \brief Set the node. | |
114 * \param node the node to set | |
115 */ | |
116 void SetNode (Ptr<Node> node); | |
117 /** | |
118 * \brief Get the node with give ip address. | |
119 * \return the node associated with the ip address | |
120 */ | |
121 Ptr<Node> GetNodeWithAddress (Ipv4Address ipv4Address); | |
122 /** | |
123 * \brief Print the route vector. | |
124 */ | |
125 void PrintVector (std::vector<Ipv4Address>& vec); | |
126 /** | |
127 * \brief Get the sift protocol number. | |
128 * \return protocol number | |
129 */ | |
130 int GetProtocolNumber (void) const; | |
131 /** | |
132 * \brief Set the route to use for data packets | |
133 * \return the route | |
134 * \used by the option headers when sending data/control packets | |
135 */ | |
136 Ptr<Ipv4Route> SetRoute (Ipv4Address nextHop, Ipv4Address srcAddress); | |
137 /** | |
138 * \brief This function is called by higher layer protocol when sending packet s | |
139 */ | |
140 void Send (Ptr<Packet> packet, Ipv4Address source, | |
141 Ipv4Address destination, uint8_t protocol, Ptr<Ipv4Route> route); | |
142 /** | |
143 * \brief This function is called by when really sending out the packet | |
144 */ | |
145 void SendPacket (Ptr<Packet> packet, Ipv4Address source, Ipv4Address nextHop, uint8_t protocol); | |
146 /** | |
147 * \brief Forward the packet using the route saved in the source route option header | |
148 */ | |
149 void ForwardPacket (Ptr<Packet> packet, | |
150 Ipv4Address source, | |
151 uint8_t protocol); | |
152 void ScheduleTimer (Ptr<Packet> packet, Time timer, Ipv4Address source, uint8_ t protocol); | |
153 /** | |
154 * \param p packet to forward up | |
155 * \param header IPv4 Header information | |
156 * \param incomingInterface the Ipv4Interface on which the packet arrived | |
157 * | |
158 * Called from lower-level layers to send the packet up | |
159 * in the stack. | |
160 */ | |
161 virtual enum IpL4Protocol::RxStatus Receive (Ptr<Packet> p, | |
162 Ipv4Header const &header, | |
163 Ptr<Ipv4Interface> incomingInterf ace); | |
164 | |
165 /** | |
166 * \param p packet to forward up | |
167 * \param header IPv6 Header information | |
168 * \param incomingInterface the Ipv6Interface on which the packet arrived | |
169 * | |
170 * Called from lower-level layers to send the packet up | |
171 * in the stack. Not implemented (IPv6). | |
172 */ | |
173 virtual enum IpL4Protocol::RxStatus Receive (Ptr<Packet> p, | |
174 Ipv6Header const &header, | |
175 Ptr<Ipv6Interface> incomingInterf ace); | |
176 | |
177 void SetDownTarget (IpL4Protocol::DownTargetCallback callback); | |
178 void SetDownTarget6 (IpL4Protocol::DownTargetCallback6 callback); | |
179 IpL4Protocol::DownTargetCallback GetDownTarget (void) const; | |
180 IpL4Protocol::DownTargetCallback6 GetDownTarget6 (void) const; | |
181 /** | |
182 * Assign a fixed random variable stream number to the random variables | |
183 * used by this model. Return the number of streams (possibly zero) that | |
184 * have been assigned. | |
185 * | |
186 * \param stream first stream index to use | |
187 * \return the number of stream indices assigned by this model | |
188 */ | |
189 int64_t AssignStreams (int64_t stream); | |
190 void AddGeographicTuple (const GeographicTuple &tuple); | |
Tom Henderson
2015/12/08 01:12:04
add Doxygen to your public methods
| |
191 SiftGeo m_state; | |
192 | |
193 void AddNode (Ptr<Node> node); | |
194 | |
195 uint32_t GetNodesSize (void); | |
196 | |
197 void CancelTimer (Ptr<Packet> p); | |
198 | |
199 //void SiftRouting::CheckParameters (Ipv4Header const ip, Ipv4Header ipHeader) ; | |
200 | |
201 void PrintReceiveBuffer (void); | |
202 std::map<Ptr<Packet>, Time> GetReceiveBuffer (void); | |
203 | |
204 uint16_t GetSeqNo (); | |
205 void SetSeqNo (uint16_t sno); | |
206 | |
207 | |
208 | |
209 protected: | |
210 /* | |
211 * * This function will notify other components connected to the node that a new stack member is now connected | |
212 * * This will be used to notify Layer 3 protocol of layer 4 protocol stac k to connect them together. | |
213 * */ | |
214 virtual void NotifyNewAggregate (); | |
215 /** | |
216 * \brief Drop trace callback. | |
217 */ | |
218 virtual void DoDispose (void); | |
219 /** | |
220 * The trace for drop, receive and send data packets | |
221 */ | |
222 TracedCallback<Ptr<const Packet> > m_dropTrace; | |
223 TracedCallback <const SiftHeader &> m_txPacketTrace; | |
224 | |
225 private: | |
226 void Start (); | |
227 | |
228 Ptr<Ipv4L3Protocol> m_ipv4; ///< Ipv4l3Protocol | |
229 | |
230 Ptr<Ipv4Route> m_ipv4Route; ///< Ipv4 Route | |
231 | |
232 Ptr<Ipv4> m_ip; ///< The ip ptr | |
233 | |
234 Ptr<Node> m_node; ///< The node ptr | |
235 | |
236 Ipv4Address m_mainAddress; ///< Our own Ip address | |
237 | |
238 Ipv4Address m_broadcast; ///< The broadcast address | |
239 | |
240 IpL4Protocol::DownTargetCallback m_downTarget; ///< The callback for d own layer | |
241 | |
242 Ptr<UniformRandomVariable> m_uniformRandomVariable; ///< Provides uniform r andom variables. | |
243 uint16_t m_seqNo; | |
244 | |
245 | |
246 std::map<Ptr<Packet>, Timer> m_timer; ///< The timer to provide timing for eac h packet, the key is the packet itself TODO | |
247 // std::map<Ptr<Packet>, Timer> m_sentPacket; | |
248 std::map<Ptr<Packet>, Time> m_buffer; // Keeps received packets to control duplicate ones | |
249 | |
250 private: | |
251 uint16_t GetIDfromIP (Ipv4Address address); | |
252 Ipv4Address GetIPfromID (const uint32_t id); ///< node id -> IP | |
253 GeographicSet m_geoSet; ///< the geographi cal set | |
254 std::vector<Ptr<Node> > m_nodePtrs; | |
255 }; | |
256 } /* namespace sift */ | |
257 } /* namespace ns3 */ | |
258 | |
259 #endif /* SIFT_ROUTING_H */ | |
OLD | NEW |