A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
aodv-packet.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2009 IITP RAS
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Based on
18 * NS-2 AODV model developed by the CMU/MONARCH group and optimized and
19 * tuned by Samir Das and Mahesh Marina, University of Cincinnati;
20 *
21 * AODV-UU implementation by Erik Nordström of Uppsala University
22 * https://web.archive.org/web/20100527072022/http://core.it.uu.se/core/index.php/AODV-UU
23 *
24 * Authors: Elena Buchatskaia <borovkovaes@iitp.ru>
25 * Pavel Boyko <boyko@iitp.ru>
26 */
27#include "aodv-packet.h"
28
29#include "ns3/address-utils.h"
30#include "ns3/packet.h"
31
32namespace ns3
33{
34namespace aodv
35{
36
38
40 : m_type(t),
41 m_valid(true)
42{
43}
44
47{
48 static TypeId tid = TypeId("ns3::aodv::TypeHeader")
50 .SetGroupName("Aodv")
51 .AddConstructor<TypeHeader>();
52 return tid;
53}
54
57{
58 return GetTypeId();
59}
60
63{
64 return 1;
65}
66
67void
69{
70 i.WriteU8((uint8_t)m_type);
71}
72
75{
76 Buffer::Iterator i = start;
77 uint8_t type = i.ReadU8();
78 m_valid = true;
79 switch (type)
80 {
81 case AODVTYPE_RREQ:
82 case AODVTYPE_RREP:
83 case AODVTYPE_RERR:
84 case AODVTYPE_RREP_ACK: {
85 m_type = (MessageType)type;
86 break;
87 }
88 default:
89 m_valid = false;
90 }
91 uint32_t dist = i.GetDistanceFrom(start);
93 return dist;
94}
95
96void
97TypeHeader::Print(std::ostream& os) const
98{
99 switch (m_type)
100 {
101 case AODVTYPE_RREQ: {
102 os << "RREQ";
103 break;
104 }
105 case AODVTYPE_RREP: {
106 os << "RREP";
107 break;
108 }
109 case AODVTYPE_RERR: {
110 os << "RERR";
111 break;
112 }
113 case AODVTYPE_RREP_ACK: {
114 os << "RREP_ACK";
115 break;
116 }
117 default:
118 os << "UNKNOWN_TYPE";
119 }
120}
121
122bool
124{
125 return (m_type == o.m_type && m_valid == o.m_valid);
126}
127
128std::ostream&
129operator<<(std::ostream& os, const TypeHeader& h)
130{
131 h.Print(os);
132 return os;
133}
134
135//-----------------------------------------------------------------------------
136// RREQ
137//-----------------------------------------------------------------------------
139 uint8_t reserved,
140 uint8_t hopCount,
141 uint32_t requestID,
142 Ipv4Address dst,
143 uint32_t dstSeqNo,
144 Ipv4Address origin,
145 uint32_t originSeqNo)
146 : m_flags(flags),
147 m_reserved(reserved),
148 m_hopCount(hopCount),
149 m_requestID(requestID),
150 m_dst(dst),
151 m_dstSeqNo(dstSeqNo),
152 m_origin(origin),
153 m_originSeqNo(originSeqNo)
154{
155}
156
158
159TypeId
161{
162 static TypeId tid = TypeId("ns3::aodv::RreqHeader")
163 .SetParent<Header>()
164 .SetGroupName("Aodv")
165 .AddConstructor<RreqHeader>();
166 return tid;
167}
168
169TypeId
171{
172 return GetTypeId();
173}
174
177{
178 return 23;
179}
180
181void
183{
184 i.WriteU8(m_flags);
188 WriteTo(i, m_dst);
190 WriteTo(i, m_origin);
192}
193
196{
197 Buffer::Iterator i = start;
198 m_flags = i.ReadU8();
199 m_reserved = i.ReadU8();
200 m_hopCount = i.ReadU8();
202 ReadFrom(i, m_dst);
204 ReadFrom(i, m_origin);
206
207 uint32_t dist = i.GetDistanceFrom(start);
208 NS_ASSERT(dist == GetSerializedSize());
209 return dist;
210}
211
212void
213RreqHeader::Print(std::ostream& os) const
214{
215 os << "RREQ ID " << m_requestID << " destination: ipv4 " << m_dst << " sequence number "
216 << m_dstSeqNo << " source: ipv4 " << m_origin << " sequence number " << m_originSeqNo
217 << " flags:"
218 << " Gratuitous RREP " << (*this).GetGratuitousRrep() << " Destination only "
219 << (*this).GetDestinationOnly() << " Unknown sequence number " << (*this).GetUnknownSeqno();
220}
221
222std::ostream&
223operator<<(std::ostream& os, const RreqHeader& h)
224{
225 h.Print(os);
226 return os;
227}
228
229void
231{
232 if (f)
233 {
234 m_flags |= (1 << 5);
235 }
236 else
237 {
238 m_flags &= ~(1 << 5);
239 }
240}
241
242bool
244{
245 return (m_flags & (1 << 5));
246}
247
248void
250{
251 if (f)
252 {
253 m_flags |= (1 << 4);
254 }
255 else
256 {
257 m_flags &= ~(1 << 4);
258 }
259}
260
261bool
263{
264 return (m_flags & (1 << 4));
265}
266
267void
269{
270 if (f)
271 {
272 m_flags |= (1 << 3);
273 }
274 else
275 {
276 m_flags &= ~(1 << 3);
277 }
278}
279
280bool
282{
283 return (m_flags & (1 << 3));
284}
285
286bool
288{
289 return (m_flags == o.m_flags && m_reserved == o.m_reserved && m_hopCount == o.m_hopCount &&
292}
293
294//-----------------------------------------------------------------------------
295// RREP
296//-----------------------------------------------------------------------------
297
298RrepHeader::RrepHeader(uint8_t prefixSize,
299 uint8_t hopCount,
300 Ipv4Address dst,
301 uint32_t dstSeqNo,
302 Ipv4Address origin,
303 Time lifeTime)
304 : m_flags(0),
305 m_prefixSize(prefixSize),
306 m_hopCount(hopCount),
307 m_dst(dst),
308 m_dstSeqNo(dstSeqNo),
309 m_origin(origin)
310{
311 m_lifeTime = uint32_t(lifeTime.GetMilliSeconds());
312}
313
315
316TypeId
318{
319 static TypeId tid = TypeId("ns3::aodv::RrepHeader")
320 .SetParent<Header>()
321 .SetGroupName("Aodv")
322 .AddConstructor<RrepHeader>();
323 return tid;
324}
325
326TypeId
328{
329 return GetTypeId();
330}
331
334{
335 return 19;
336}
337
338void
340{
341 i.WriteU8(m_flags);
344 WriteTo(i, m_dst);
346 WriteTo(i, m_origin);
348}
349
352{
353 Buffer::Iterator i = start;
354
355 m_flags = i.ReadU8();
356 m_prefixSize = i.ReadU8();
357 m_hopCount = i.ReadU8();
358 ReadFrom(i, m_dst);
360 ReadFrom(i, m_origin);
362
363 uint32_t dist = i.GetDistanceFrom(start);
364 NS_ASSERT(dist == GetSerializedSize());
365 return dist;
366}
367
368void
369RrepHeader::Print(std::ostream& os) const
370{
371 os << "destination: ipv4 " << m_dst << " sequence number " << m_dstSeqNo;
372 if (m_prefixSize != 0)
373 {
374 os << " prefix size " << m_prefixSize;
375 }
376 os << " source ipv4 " << m_origin << " lifetime " << m_lifeTime
377 << " acknowledgment required flag " << (*this).GetAckRequired();
378}
379
380void
382{
384}
385
386Time
388{
390 return t;
391}
392
393void
395{
396 if (f)
397 {
398 m_flags |= (1 << 6);
399 }
400 else
401 {
402 m_flags &= ~(1 << 6);
403 }
404}
405
406bool
408{
409 return (m_flags & (1 << 6));
410}
411
412void
414{
415 m_prefixSize = sz;
416}
417
418uint8_t
420{
421 return m_prefixSize;
422}
423
424bool
426{
427 return (m_flags == o.m_flags && m_prefixSize == o.m_prefixSize && m_hopCount == o.m_hopCount &&
428 m_dst == o.m_dst && m_dstSeqNo == o.m_dstSeqNo && m_origin == o.m_origin &&
430}
431
432void
434{
435 m_flags = 0;
436 m_prefixSize = 0;
437 m_hopCount = 0;
438 m_dst = origin;
439 m_dstSeqNo = srcSeqNo;
440 m_origin = origin;
441 m_lifeTime = lifetime.GetMilliSeconds();
442}
443
444std::ostream&
445operator<<(std::ostream& os, const RrepHeader& h)
446{
447 h.Print(os);
448 return os;
449}
450
451//-----------------------------------------------------------------------------
452// RREP-ACK
453//-----------------------------------------------------------------------------
454
456 : m_reserved(0)
457{
458}
459
461
462TypeId
464{
465 static TypeId tid = TypeId("ns3::aodv::RrepAckHeader")
466 .SetParent<Header>()
467 .SetGroupName("Aodv")
468 .AddConstructor<RrepAckHeader>();
469 return tid;
470}
471
472TypeId
474{
475 return GetTypeId();
476}
477
480{
481 return 1;
482}
483
484void
486{
488}
489
492{
493 Buffer::Iterator i = start;
494 m_reserved = i.ReadU8();
495 uint32_t dist = i.GetDistanceFrom(start);
496 NS_ASSERT(dist == GetSerializedSize());
497 return dist;
498}
499
500void
501RrepAckHeader::Print(std::ostream& os) const
502{
503}
504
505bool
507{
508 return m_reserved == o.m_reserved;
509}
510
511std::ostream&
512operator<<(std::ostream& os, const RrepAckHeader& h)
513{
514 h.Print(os);
515 return os;
516}
517
518//-----------------------------------------------------------------------------
519// RERR
520//-----------------------------------------------------------------------------
522 : m_flag(0),
523 m_reserved(0)
524{
525}
526
528
529TypeId
531{
532 static TypeId tid = TypeId("ns3::aodv::RerrHeader")
533 .SetParent<Header>()
534 .SetGroupName("Aodv")
535 .AddConstructor<RerrHeader>();
536 return tid;
537}
538
539TypeId
541{
542 return GetTypeId();
543}
544
547{
548 return (3 + 8 * GetDestCount());
549}
550
551void
553{
554 i.WriteU8(m_flag);
557 for (auto j = m_unreachableDstSeqNo.begin(); j != m_unreachableDstSeqNo.end(); ++j)
558 {
559 WriteTo(i, (*j).first);
560 i.WriteHtonU32((*j).second);
561 }
562}
563
566{
567 Buffer::Iterator i = start;
568 m_flag = i.ReadU8();
569 m_reserved = i.ReadU8();
570 uint8_t dest = i.ReadU8();
571 m_unreachableDstSeqNo.clear();
572 Ipv4Address address;
573 uint32_t seqNo;
574 for (uint8_t k = 0; k < dest; ++k)
575 {
576 ReadFrom(i, address);
577 seqNo = i.ReadNtohU32();
578 m_unreachableDstSeqNo.insert(std::make_pair(address, seqNo));
579 }
580
581 uint32_t dist = i.GetDistanceFrom(start);
582 NS_ASSERT(dist == GetSerializedSize());
583 return dist;
584}
585
586void
587RerrHeader::Print(std::ostream& os) const
588{
589 os << "Unreachable destination (ipv4 address, seq. number):";
590 for (auto j = m_unreachableDstSeqNo.begin(); j != m_unreachableDstSeqNo.end(); ++j)
591 {
592 os << (*j).first << ", " << (*j).second;
593 }
594 os << "No delete flag " << (*this).GetNoDelete();
595}
596
597void
599{
600 if (f)
601 {
602 m_flag |= (1 << 0);
603 }
604 else
605 {
606 m_flag &= ~(1 << 0);
607 }
608}
609
610bool
612{
613 return (m_flag & (1 << 0));
614}
615
616bool
618{
619 if (m_unreachableDstSeqNo.find(dst) != m_unreachableDstSeqNo.end())
620 {
621 return true;
622 }
623
624 NS_ASSERT(GetDestCount() < 255); // can't support more than 255 destinations in single RERR
625 m_unreachableDstSeqNo.insert(std::make_pair(dst, seqNo));
626 return true;
627}
628
629bool
630RerrHeader::RemoveUnDestination(std::pair<Ipv4Address, uint32_t>& un)
631{
632 if (m_unreachableDstSeqNo.empty())
633 {
634 return false;
635 }
636 auto i = m_unreachableDstSeqNo.begin();
637 un = *i;
638 m_unreachableDstSeqNo.erase(i);
639 return true;
640}
641
642void
644{
645 m_unreachableDstSeqNo.clear();
646 m_flag = 0;
647 m_reserved = 0;
648}
649
650bool
652{
653 if (m_flag != o.m_flag || m_reserved != o.m_reserved || GetDestCount() != o.GetDestCount())
654 {
655 return false;
656 }
657
658 auto j = m_unreachableDstSeqNo.begin();
659 auto k = o.m_unreachableDstSeqNo.begin();
660 for (uint8_t i = 0; i < GetDestCount(); ++i)
661 {
662 if ((j->first != k->first) || (j->second != k->second))
663 {
664 return false;
665 }
666
667 j++;
668 k++;
669 }
670 return true;
671}
672
673std::ostream&
674operator<<(std::ostream& os, const RerrHeader& h)
675{
676 h.Print(os);
677 return os;
678}
679} // namespace aodv
680} // namespace ns3
iterator in a Buffer instance
Definition: buffer.h:100
uint8_t ReadU8()
Definition: buffer.h:1027
void WriteU8(uint8_t data)
Definition: buffer.h:881
uint32_t ReadNtohU32()
Definition: buffer.h:978
void WriteHtonU32(uint32_t data)
Definition: buffer.h:933
uint32_t GetDistanceFrom(const Iterator &o) const
Definition: buffer.cc:780
Protocol header serialization and deserialization.
Definition: header.h:44
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:42
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
int64_t GetMilliSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:408
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:932
Route Error (RERR) Message Format.
Definition: aodv-packet.h:592
uint32_t Deserialize(Buffer::Iterator start) override
Definition: aodv-packet.cc:565
uint8_t GetDestCount() const
Definition: aodv-packet.h:640
void Clear()
Clear header.
Definition: aodv-packet.cc:643
static TypeId GetTypeId()
Get the type ID.
Definition: aodv-packet.cc:530
uint8_t m_reserved
Not used (must be 0)
Definition: aodv-packet.h:654
bool GetNoDelete() const
Get the no delete flag.
Definition: aodv-packet.cc:611
uint32_t GetSerializedSize() const override
Definition: aodv-packet.cc:546
RerrHeader()
constructor
Definition: aodv-packet.cc:521
uint8_t m_flag
No delete flag.
Definition: aodv-packet.h:653
bool operator==(const RerrHeader &o) const
Comparison operator.
Definition: aodv-packet.cc:651
void Serialize(Buffer::Iterator i) const override
Definition: aodv-packet.cc:552
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition: aodv-packet.cc:540
void SetNoDelete(bool f)
Set the no delete flag.
Definition: aodv-packet.cc:598
bool AddUnDestination(Ipv4Address dst, uint32_t seqNo)
Add unreachable node address and its sequence number in RERR header.
Definition: aodv-packet.cc:617
std::map< Ipv4Address, uint32_t > m_unreachableDstSeqNo
List of Unreachable destination: IP addresses and sequence numbers.
Definition: aodv-packet.h:657
void Print(std::ostream &os) const override
Definition: aodv-packet.cc:587
bool RemoveUnDestination(std::pair< Ipv4Address, uint32_t > &un)
Delete pair (address + sequence number) from REER header, if the number of unreachable destinations >...
Definition: aodv-packet.cc:630
Route Reply Acknowledgment (RREP-ACK) Message Format.
Definition: aodv-packet.h:538
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition: aodv-packet.cc:473
void Serialize(Buffer::Iterator start) const override
Definition: aodv-packet.cc:485
void Print(std::ostream &os) const override
Definition: aodv-packet.cc:501
static TypeId GetTypeId()
Get the type ID.
Definition: aodv-packet.cc:463
uint32_t Deserialize(Buffer::Iterator start) override
Definition: aodv-packet.cc:491
bool operator==(const RrepAckHeader &o) const
Comparison operator.
Definition: aodv-packet.cc:506
uint32_t GetSerializedSize() const override
Definition: aodv-packet.cc:479
RrepAckHeader()
constructor
Definition: aodv-packet.cc:455
uint8_t m_reserved
Not used (must be 0)
Definition: aodv-packet.h:562
Route Reply (RREP) Message Format.
Definition: aodv-packet.h:358
bool GetAckRequired() const
get the ack required flag
Definition: aodv-packet.cc:407
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition: aodv-packet.cc:327
uint8_t GetPrefixSize() const
Set the prefix size.
Definition: aodv-packet.cc:419
uint32_t Deserialize(Buffer::Iterator start) override
Definition: aodv-packet.cc:351
void Print(std::ostream &os) const override
Definition: aodv-packet.cc:369
void Serialize(Buffer::Iterator start) const override
Definition: aodv-packet.cc:339
void SetHello(Ipv4Address src, uint32_t srcSeqNo, Time lifetime)
Configure RREP to be a Hello message.
Definition: aodv-packet.cc:433
static TypeId GetTypeId()
Get the type ID.
Definition: aodv-packet.cc:317
uint32_t GetSerializedSize() const override
Definition: aodv-packet.cc:333
uint32_t m_dstSeqNo
Destination Sequence Number.
Definition: aodv-packet.h:514
void SetLifeTime(Time t)
Set the lifetime.
Definition: aodv-packet.cc:381
void SetAckRequired(bool f)
Set the ack required flag.
Definition: aodv-packet.cc:394
void SetPrefixSize(uint8_t sz)
Set the prefix size.
Definition: aodv-packet.cc:413
RrepHeader(uint8_t prefixSize=0, uint8_t hopCount=0, Ipv4Address dst=Ipv4Address(), uint32_t dstSeqNo=0, Ipv4Address origin=Ipv4Address(), Time lifetime=MilliSeconds(0))
constructor
Definition: aodv-packet.cc:298
Time GetLifeTime() const
Get the lifetime.
Definition: aodv-packet.cc:387
Ipv4Address m_dst
Destination IP Address.
Definition: aodv-packet.h:513
uint8_t m_flags
A - acknowledgment required flag.
Definition: aodv-packet.h:510
uint8_t m_hopCount
Hop Count.
Definition: aodv-packet.h:512
uint8_t m_prefixSize
Prefix Size.
Definition: aodv-packet.h:511
bool operator==(const RrepHeader &o) const
Comparison operator.
Definition: aodv-packet.cc:425
Ipv4Address m_origin
Source IP Address.
Definition: aodv-packet.h:515
uint32_t m_lifeTime
Lifetime (in milliseconds)
Definition: aodv-packet.h:516
Route Request (RREQ) Message Format.
Definition: aodv-packet.h:138
bool GetUnknownSeqno() const
Get the unknown sequence number flag.
Definition: aodv-packet.cc:281
uint32_t m_originSeqNo
Source Sequence Number.
Definition: aodv-packet.h:328
RreqHeader(uint8_t flags=0, uint8_t reserved=0, uint8_t hopCount=0, uint32_t requestID=0, Ipv4Address dst=Ipv4Address(), uint32_t dstSeqNo=0, Ipv4Address origin=Ipv4Address(), uint32_t originSeqNo=0)
constructor
Definition: aodv-packet.cc:138
uint8_t m_hopCount
Hop Count.
Definition: aodv-packet.h:323
void SetUnknownSeqno(bool f)
Set the unknown sequence number flag.
Definition: aodv-packet.cc:268
void SetGratuitousRrep(bool f)
Set the gratuitous RREP flag.
Definition: aodv-packet.cc:230
void SetDestinationOnly(bool f)
Set the Destination only flag.
Definition: aodv-packet.cc:249
Ipv4Address m_origin
Originator IP Address.
Definition: aodv-packet.h:327
bool GetDestinationOnly() const
Get the Destination only flag.
Definition: aodv-packet.cc:262
uint32_t GetSerializedSize() const override
Definition: aodv-packet.cc:176
Ipv4Address m_dst
Destination IP Address.
Definition: aodv-packet.h:325
static TypeId GetTypeId()
Get the type ID.
Definition: aodv-packet.cc:160
uint32_t m_requestID
RREQ ID.
Definition: aodv-packet.h:324
void Print(std::ostream &os) const override
Definition: aodv-packet.cc:213
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition: aodv-packet.cc:170
void Serialize(Buffer::Iterator start) const override
Definition: aodv-packet.cc:182
uint8_t m_reserved
Not used (must be 0)
Definition: aodv-packet.h:322
bool GetGratuitousRrep() const
Get the gratuitous RREP flag.
Definition: aodv-packet.cc:243
uint32_t m_dstSeqNo
Destination Sequence Number.
Definition: aodv-packet.h:326
uint32_t Deserialize(Buffer::Iterator start) override
Definition: aodv-packet.cc:195
bool operator==(const RreqHeader &o) const
Comparison operator.
Definition: aodv-packet.cc:287
uint8_t m_flags
|J|R|G|D|U| bit flags, see RFC
Definition: aodv-packet.h:321
uint32_t Deserialize(Buffer::Iterator start) override
Definition: aodv-packet.cc:74
TypeHeader(MessageType t=AODVTYPE_RREQ)
constructor
Definition: aodv-packet.cc:39
bool operator==(const TypeHeader &o) const
Comparison operator.
Definition: aodv-packet.cc:123
void Print(std::ostream &os) const override
Definition: aodv-packet.cc:97
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition: aodv-packet.cc:56
void Serialize(Buffer::Iterator start) const override
Definition: aodv-packet.cc:68
MessageType m_type
type of the message
Definition: aodv-packet.h:104
bool m_valid
Indicates if the message is valid.
Definition: aodv-packet.h:105
uint32_t GetSerializedSize() const override
Definition: aodv-packet.cc:62
static TypeId GetTypeId()
Get the type ID.
Definition: aodv-packet.cc:46
MessageType
MessageType enumeration.
Definition: aodv-packet.h:48
@ AODVTYPE_RREP
AODVTYPE_RREP.
Definition: aodv-packet.h:50
@ AODVTYPE_RREP_ACK
AODVTYPE_RREP_ACK.
Definition: aodv-packet.h:52
@ AODVTYPE_RERR
AODVTYPE_RERR.
Definition: aodv-packet.h:51
@ AODVTYPE_RREQ
AODVTYPE_RREQ.
Definition: aodv-packet.h:49
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition: assert.h:66
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:46
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1331
std::ostream & operator<<(std::ostream &os, const TypeHeader &h)
Stream output operator.
Definition: aodv-packet.cc:129
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void WriteTo(Buffer::Iterator &i, Ipv4Address ad)
Write an Ipv4Address to a Buffer.
void ReadFrom(Buffer::Iterator &i, Ipv4Address &ad)
Read an Ipv4Address from a Buffer.