blob: efbbdd0bcee4747a5b4157cbe918f49833361112 [file] [log] [blame]
Alexander Afanasyev60a7b622014-12-20 17:04:07 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2011-2015 Regents of the University of California.
Alexander Afanasyev1a0fff62013-01-19 14:29:51 -08004 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -08005 * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and
6 * contributors.
Alexander Afanasyev1a0fff62013-01-19 14:29:51 -08007 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -08008 * ndnSIM is free software: you can redistribute it and/or modify it under the terms
9 * of the GNU General Public License as published by the Free Software Foundation,
10 * either version 3 of the License, or (at your option) any later version.
Alexander Afanasyev1a0fff62013-01-19 14:29:51 -080011 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -080012 * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
13 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
Alexander Afanasyev1a0fff62013-01-19 14:29:51 -080015 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -080016 * You should have received a copy of the GNU General Public License along with
17 * ndnSIM, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
18 **/
Alexander Afanasyev1a0fff62013-01-19 14:29:51 -080019
20#ifndef NDN_FW_HOP_COUNT_TAG_H
21#define NDN_FW_HOP_COUNT_TAG_H
22
23#include "ns3/tag.h"
24
25namespace ns3 {
26namespace ndn {
27
28/**
Alexander Afanasyev79206512013-07-27 16:49:12 -070029 * @ingroup ndn-fw
Alexander Afanasyev1a0fff62013-01-19 14:29:51 -080030 * @brief Packet tag that is used to track hop count for Interest-Data pairs
31 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080032class FwHopCountTag : public Tag {
Alexander Afanasyev1a0fff62013-01-19 14:29:51 -080033public:
34 static TypeId
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080035 GetTypeId(void);
Alexander Afanasyev1a0fff62013-01-19 14:29:51 -080036
37 /**
38 * @brief Default constructor
39 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080040 FwHopCountTag()
41 : m_hopCount(0){};
Alexander Afanasyev1a0fff62013-01-19 14:29:51 -080042
43 /**
44 * @brief Destructor
45 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080046 ~FwHopCountTag()
47 {
48 }
Alexander Afanasyev1a0fff62013-01-19 14:29:51 -080049
50 /**
51 * @brief Increment hop count
52 */
53 void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080054 Increment()
55 {
56 m_hopCount++;
57 }
Alexander Afanasyev1a0fff62013-01-19 14:29:51 -080058
59 /**
60 * @brief Get value of hop count
61 */
62 uint32_t
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080063 Get() const
64 {
65 return m_hopCount;
66 }
Alexander Afanasyev1a0fff62013-01-19 14:29:51 -080067
68 ////////////////////////////////////////////////////////
69 // from ObjectBase
70 ////////////////////////////////////////////////////////
71 virtual TypeId
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080072 GetInstanceTypeId() const;
73
Alexander Afanasyev1a0fff62013-01-19 14:29:51 -080074 ////////////////////////////////////////////////////////
75 // from Tag
76 ////////////////////////////////////////////////////////
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080077
Alexander Afanasyev1a0fff62013-01-19 14:29:51 -080078 virtual uint32_t
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080079 GetSerializedSize() const;
Alexander Afanasyev1a0fff62013-01-19 14:29:51 -080080
81 virtual void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080082 Serialize(TagBuffer i) const;
Alexander Afanasyev1a0fff62013-01-19 14:29:51 -080083
84 virtual void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080085 Deserialize(TagBuffer i);
86
87 virtual void
88 Print(std::ostream& os) const;
89
Alexander Afanasyev1a0fff62013-01-19 14:29:51 -080090private:
91 uint32_t m_hopCount;
92};
93
94} // namespace ndn
95} // namespace ns3
96
97#endif // NDN_FW_HOP_COUNT_TAG_H