26 #include "ns3/header.h"
27 #include "ns3/ipv4-address.h"
28 #include "ns3/nstime.h"
34 double EmfToSeconds (uint8_t emf);
35 uint8_t SecondsToEmf (
double seconds);
75 void SetPacketLength (uint16_t length)
77 m_packetLength = length;
79 uint16_t GetPacketLength ()
const
81 return m_packetLength;
84 void SetPacketSequenceNumber (uint16_t seqnum)
86 m_packetSequenceNumber = seqnum;
88 uint16_t GetPacketSequenceNumber ()
const
90 return m_packetSequenceNumber;
94 uint16_t m_packetLength;
95 uint16_t m_packetSequenceNumber;
98 static TypeId GetTypeId (
void);
100 virtual void Print (std::ostream &os)
const;
130 void SetMessageType (MessageType messageType)
132 m_messageType = messageType;
134 MessageType GetMessageType ()
const
136 return m_messageType;
139 void SetVTime (
Time time)
143 Time GetVTime ()
const
145 return Seconds (EmfToSeconds (m_vTime));
148 void SetOriginatorAddress (
Ipv4Address originatorAddress)
150 m_originatorAddress = originatorAddress;
154 return m_originatorAddress;
157 void SetTimeToLive (uint8_t timeToLive)
159 m_timeToLive = timeToLive;
161 uint8_t GetTimeToLive ()
const
166 void SetHopCount (uint8_t hopCount)
168 m_hopCount = hopCount;
170 uint8_t GetHopCount ()
const
175 void SetMessageSequenceNumber (uint16_t messageSequenceNumber)
177 m_messageSequenceNumber = messageSequenceNumber;
179 uint16_t GetMessageSequenceNumber ()
const
181 return m_messageSequenceNumber;
194 MessageType m_messageType;
197 uint8_t m_timeToLive;
199 uint16_t m_messageSequenceNumber;
200 uint16_t m_messageSize;
203 static TypeId GetTypeId (
void);
205 virtual void Print (std::ostream &os)
const;
225 std::vector<Ipv4Address> interfaceAddresses;
226 void Print (std::ostream &os)
const;
227 uint32_t GetSerializedSize (
void)
const;
262 std::vector<Ipv4Address> neighborInterfaceAddresses;
266 void SetHTime (
Time time)
268 this->hTime = SecondsToEmf (time.
GetSeconds ());
270 Time GetHTime ()
const
272 return Seconds (EmfToSeconds (this->hTime));
276 std::vector<LinkMessage> linkMessages;
278 void Print (std::ostream &os)
const;
279 uint32_t GetSerializedSize (
void)
const;
302 std::vector<Ipv4Address> neighborAddresses;
305 void Print (std::ostream &os)
const;
306 uint32_t GetSerializedSize (
void)
const;
338 std::vector<Association> associations;
340 void Print (std::ostream &os)
const;
341 uint32_t GetSerializedSize (
void)
const;
359 if (m_messageType == 0)
361 m_messageType = MID_MESSAGE;
365 NS_ASSERT (m_messageType == MID_MESSAGE);
367 return m_message.mid;
372 if (m_messageType == 0)
374 m_messageType = HELLO_MESSAGE;
378 NS_ASSERT (m_messageType == HELLO_MESSAGE);
380 return m_message.hello;
385 if (m_messageType == 0)
387 m_messageType = TC_MESSAGE;
398 if (m_messageType == 0)
400 m_messageType = HNA_MESSAGE;
404 NS_ASSERT (m_messageType == HNA_MESSAGE);
406 return m_message.hna;
410 const Mid& GetMid ()
const
412 NS_ASSERT (m_messageType == MID_MESSAGE);
413 return m_message.mid;
416 const Hello& GetHello ()
const
418 NS_ASSERT (m_messageType == HELLO_MESSAGE);
419 return m_message.hello;
422 const Tc& GetTc ()
const
428 const Hna& GetHna ()
const
430 NS_ASSERT (m_messageType == HNA_MESSAGE);
431 return m_message.hna;
438 static inline std::ostream&
operator<< (std::ostream& os,
const PacketHeader & packet)
444 static inline std::ostream&
operator<< (std::ostream& os,
const MessageHeader & message)
450 typedef std::vector<MessageHeader> MessageList;
452 static inline std::ostream&
operator<< (std::ostream& os,
const MessageList & messages)
455 for (std::vector<MessageHeader>::const_iterator messageIter = messages.begin ();
456 messageIter != messages.end (); messageIter++)
458 messageIter->Print (os);
459 if (messageIter+1 != messages.end ())
a class to represent an Ipv4 address mask
#define NS_ASSERT(condition)
iterator in a Buffer instance
double GetSeconds(void) const
std::ostream & operator<<(std::ostream &os, const Angles &a)
Ipv4 addresses are stored in host order in this class.
Time Seconds(double seconds)
create ns3::Time instances in units of seconds.
a unique identifier for an interface.