blob: 6b4920cb7f0f6e660797b6fb3a97770e1f8d906a [file] [log] [blame]
Alexander Afanasyev1a0fff62013-01-19 14:29:51 -08001/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
2/*
3 * Copyright (c) 2013 University of California, Los Angeles
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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
19 */
20
21#ifndef NDN_FW_HOP_COUNT_TAG_H
22#define NDN_FW_HOP_COUNT_TAG_H
23
24#include "ns3/tag.h"
25
26namespace ns3 {
27namespace ndn {
28
29/**
Alexander Afanasyev79206512013-07-27 16:49:12 -070030 * @ingroup ndn-fw
Alexander Afanasyev1a0fff62013-01-19 14:29:51 -080031 * @brief Packet tag that is used to track hop count for Interest-Data pairs
32 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080033class FwHopCountTag : public Tag {
Alexander Afanasyev1a0fff62013-01-19 14:29:51 -080034public:
35 static TypeId
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080036 GetTypeId(void);
Alexander Afanasyev1a0fff62013-01-19 14:29:51 -080037
38 /**
39 * @brief Default constructor
40 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080041 FwHopCountTag()
42 : m_hopCount(0){};
Alexander Afanasyev1a0fff62013-01-19 14:29:51 -080043
44 /**
45 * @brief Destructor
46 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080047 ~FwHopCountTag()
48 {
49 }
Alexander Afanasyev1a0fff62013-01-19 14:29:51 -080050
51 /**
52 * @brief Increment hop count
53 */
54 void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080055 Increment()
56 {
57 m_hopCount++;
58 }
Alexander Afanasyev1a0fff62013-01-19 14:29:51 -080059
60 /**
61 * @brief Get value of hop count
62 */
63 uint32_t
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080064 Get() const
65 {
66 return m_hopCount;
67 }
Alexander Afanasyev1a0fff62013-01-19 14:29:51 -080068
69 ////////////////////////////////////////////////////////
70 // from ObjectBase
71 ////////////////////////////////////////////////////////
72 virtual TypeId
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080073 GetInstanceTypeId() const;
74
Alexander Afanasyev1a0fff62013-01-19 14:29:51 -080075 ////////////////////////////////////////////////////////
76 // from Tag
77 ////////////////////////////////////////////////////////
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080078
Alexander Afanasyev1a0fff62013-01-19 14:29:51 -080079 virtual uint32_t
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080080 GetSerializedSize() const;
Alexander Afanasyev1a0fff62013-01-19 14:29:51 -080081
82 virtual void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080083 Serialize(TagBuffer i) const;
Alexander Afanasyev1a0fff62013-01-19 14:29:51 -080084
85 virtual void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080086 Deserialize(TagBuffer i);
87
88 virtual void
89 Print(std::ostream& os) const;
90
Alexander Afanasyev1a0fff62013-01-19 14:29:51 -080091private:
92 uint32_t m_hopCount;
93};
94
95} // namespace ndn
96} // namespace ns3
97
98#endif // NDN_FW_HOP_COUNT_TAG_H