TimeoutHeader and NonceHeader for Interest ns-3 packets
diff --git a/model/ndn_nonceheader.cc b/model/ndn_nonceheader.cc
new file mode 100644
index 0000000..7d26a7d
--- /dev/null
+++ b/model/ndn_nonceheader.cc
@@ -0,0 +1,79 @@
+//
+// ndn_nonceheader.cpp
+// Abstraction
+//
+// Created by Ilya Moiseenko on 04.08.11.
+// Copyright 2011 UCLA. All rights reserved.
+//
+
+#include "ndn_nonceheader.h"
+
+
+namespace ns3
+{
+ namespace NDNabstraction
+ {
+ NS_OBJECT_ENSURE_REGISTERED (NonceHeader);
+
+ NonceHeader::NonceHeader()
+ {
+ m_value = 0;
+ }
+
+ NonceHeader::NonceHeader (uint32_t nonce)
+ {
+ m_value = nonce;
+ }
+
+ TypeId
+ NonceHeader::GetTypeId ()
+ {
+ static TypeId tid = TypeId ("ns3::NDNabstraction::NonceHeader")
+ .SetParent<Header> ()
+ .AddConstructor<NonceHeader> ()
+ ;
+ return tid;
+ }
+
+ TypeId
+ NonceHeader::GetInstanceTypeId () const
+ {
+ return GetTypeId ();
+ }
+
+ uint32_t
+ NonceHeader::GetSerializedSize () const
+ {
+ return 4;
+ }
+
+ void
+ NonceHeader::Serialize (Buffer::Iterator i) const
+ {
+ i.WriteU32 ((uint32_t) m_value);
+ }
+
+ uint32_t
+ NonceHeader::Deserialize (Buffer::Iterator start)
+ {
+ Buffer::Iterator i = start;
+ m_value = i.ReadU32 ();
+
+ uint32_t dist = i.GetDistanceFrom (start);
+ NS_ASSERT (dist == GetSerializedSize ());
+ return dist;
+ }
+
+ void
+ NonceHeader::Print (std::ostream &os) const
+ {
+ os << m_value;
+ }
+
+ uint32_t
+ NonceHeader::GetValue()
+ {
+ return m_value;
+ }
+ }
+}
\ No newline at end of file
diff --git a/model/ndn_nonceheader.h b/model/ndn_nonceheader.h
new file mode 100644
index 0000000..f12abec
--- /dev/null
+++ b/model/ndn_nonceheader.h
@@ -0,0 +1,36 @@
+//
+// ndn_nonceheader.h
+// Abstraction
+//
+// Created by Ilya Moiseenko on 04.08.11.
+// Copyright 2011 UCLA. All rights reserved.
+//
+
+#include "ns3/header.h"
+#include <iostream>
+
+namespace ns3
+{
+ namespace NDNabstraction
+ {
+ class NonceHeader: public Header
+ {
+ public:
+ NonceHeader();
+ NonceHeader(uint32_t nonce);
+ uint32_t GetValue();
+
+
+ // Header serialization/deserialization
+ static TypeId GetTypeId ();
+ TypeId GetInstanceTypeId () const;
+ uint32_t GetSerializedSize () const;
+ void Serialize (Buffer::Iterator start) const;
+ uint32_t Deserialize (Buffer::Iterator start);
+ void Print (std::ostream &os) const;
+
+ private:
+ uint32_t m_value;
+ };
+ }
+}
\ No newline at end of file
diff --git a/model/ndn_timeoutheader.cc b/model/ndn_timeoutheader.cc
new file mode 100644
index 0000000..77afdec
--- /dev/null
+++ b/model/ndn_timeoutheader.cc
@@ -0,0 +1,78 @@
+//
+// ndn_timeoutheader.cpp
+// Abstraction
+//
+// Created by Ilya Moiseenko on 04.08.11.
+// Copyright 2011 UCLA. All rights reserved.
+//
+
+#include "ndn_timeoutheader.h"
+
+namespace ns3
+{
+namespace NDNabstraction
+{
+ NS_OBJECT_ENSURE_REGISTERED (TimeoutHeader);
+
+ TimeoutHeader::TimeoutHeader()
+ {
+ m_value = 4000;
+ }
+
+ TimeoutHeader::TimeoutHeader (uint32_t timeout)
+ {
+ m_value = timeout;
+ }
+
+ TypeId
+ TimeoutHeader::GetTypeId ()
+ {
+ static TypeId tid = TypeId ("ns3::NDNabstraction::TimeoutHeader")
+ .SetParent<Header> ()
+ .AddConstructor<TimeoutHeader> ()
+ ;
+ return tid;
+ }
+
+ TypeId
+ TimeoutHeader::GetInstanceTypeId () const
+ {
+ return GetTypeId ();
+ }
+
+ uint32_t
+ TimeoutHeader::GetSerializedSize () const
+ {
+ return 4;
+ }
+
+ void
+ TimeoutHeader::Serialize (Buffer::Iterator i) const
+ {
+ i.WriteU32 ((uint32_t) m_value);
+ }
+
+ uint32_t
+ TimeoutHeader::Deserialize (Buffer::Iterator start)
+ {
+ Buffer::Iterator i = start;
+ m_value = i.ReadU32 ();
+
+ uint32_t dist = i.GetDistanceFrom (start);
+ NS_ASSERT (dist == GetSerializedSize ());
+ return dist;
+ }
+
+ void
+ TimeoutHeader::Print (std::ostream &os) const
+ {
+ os << m_value;
+ }
+
+ uint32_t
+ TimeoutHeader::GetValue()
+ {
+ return m_value;
+ }
+}
+}
\ No newline at end of file
diff --git a/model/ndn_timeoutheader.h b/model/ndn_timeoutheader.h
new file mode 100644
index 0000000..ffa158b
--- /dev/null
+++ b/model/ndn_timeoutheader.h
@@ -0,0 +1,37 @@
+//
+// ndn_timeoutheader.h
+// Abstraction
+//
+// Created by Ilya Moiseenko on 04.08.11.
+// Copyright 2011 UCLA. All rights reserved.
+//
+
+#include "ns3/header.h"
+#include <iostream>
+
+namespace ns3
+{
+namespace NDNabstraction
+{
+
+ class TimeoutHeader: public Header
+ {
+ public:
+ TimeoutHeader();
+ TimeoutHeader(uint32_t timeout);
+ uint32_t GetValue();
+
+
+ // Header serialization/deserialization
+ static TypeId GetTypeId ();
+ TypeId GetInstanceTypeId () const;
+ uint32_t GetSerializedSize () const;
+ void Serialize (Buffer::Iterator start) const;
+ uint32_t Deserialize (Buffer::Iterator start);
+ void Print (std::ostream &os) const;
+
+ private:
+ uint32_t m_value;
+ };
+}
+}
\ No newline at end of file