blob: ea9f69220d08e60d1be7ede3604263b3412e03cc [file] [log] [blame]
Alexander Afanasyevc74a6022011-08-15 20:01:35 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
Alexander Afanasyev98256102011-08-14 01:00:02 -07002/*
Ilya Moiseenko25f7d4d2011-09-29 18:41:06 -07003 * Copyright (c) 2011 University of California, Los Angeles
Alexander Afanasyev98256102011-08-14 01:00:02 -07004 *
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
Alexander Afanasyevcf133f02011-09-06 12:13:48 -070017 *
Ilya Moiseenko25f7d4d2011-09-29 18:41:06 -070018 * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
19 * Ilya Moiseenko <iliamo@cs.ucla.edu>
Alexander Afanasyev98256102011-08-14 01:00:02 -070020 */
Alexander Afanasyevc74a6022011-08-15 20:01:35 -070021#ifndef CCNX_FORWARDING_STRATEGY_H
22#define CCNX_FORWARDING_STRATEGY_H
Alexander Afanasyev98256102011-08-14 01:00:02 -070023
24#include "ns3/packet.h"
25#include "ns3/callback.h"
26#include "ns3/object.h"
Alexander Afanasyevf377b332011-12-16 15:32:12 -080027#include "ns3/traced-callback.h"
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070028
Alexander Afanasyev98256102011-08-14 01:00:02 -070029namespace ns3 {
30
Alexander Afanasyev98256102011-08-14 01:00:02 -070031class CcnxFace;
Alexander Afanasyevcf133f02011-09-06 12:13:48 -070032class CcnxInterestHeader;
Alexander Afanasyevf377b332011-12-16 15:32:12 -080033class CcnxPit;
34class CcnxPitEntry;
Alexander Afanasyeve9c9d722012-01-19 16:59:30 -080035class CcnxFibFaceMetric;
Alexander Afanasyev98256102011-08-14 01:00:02 -070036
37/**
Alexander Afanasyevcf133f02011-09-06 12:13:48 -070038 * \ingroup ccnx
Alexander Afanasyeva5bbe0e2011-11-22 17:28:39 -080039 * \brief Abstract base class for CCNx forwarding strategies
Alexander Afanasyev98256102011-08-14 01:00:02 -070040 */
Alexander Afanasyevc74a6022011-08-15 20:01:35 -070041class CcnxForwardingStrategy : public Object
Alexander Afanasyev98256102011-08-14 01:00:02 -070042{
43public:
Alexander Afanasyeva5bbe0e2011-11-22 17:28:39 -080044 static TypeId GetTypeId (void);
45
46 /**
47 * @brief Default constructor
48 */
49 CcnxForwardingStrategy ();
50 virtual ~CcnxForwardingStrategy ();
51
52 /**
Ilya Moiseenko332add02011-12-24 17:21:25 -080053 * @brief Base method to propagate the interest according to the forwarding strategy
Alexander Afanasyeva5bbe0e2011-11-22 17:28:39 -080054 *
55 * @param pitEntry Reference to PIT entry (reference to corresponding FIB entry inside)
56 * @param incomingFace Incoming face
57 * @param header CcnxInterestHeader
58 * @param packet Original Interest packet
59 * @param sendCallback Send callback
60 *
61 * @return true if interest was successfully propagated, false if all options have failed
62 */
Alexander Afanasyev4fa5e842011-11-21 13:38:39 -080063 virtual bool
Alexander Afanasyeva5bbe0e2011-11-22 17:28:39 -080064 PropagateInterest (const CcnxPitEntry &pitEntry,
Alexander Afanasyev4fa5e842011-11-21 13:38:39 -080065 const Ptr<CcnxFace> &incomingFace,
66 Ptr<CcnxInterestHeader> &header,
Alexander Afanasyev0a61c342011-12-06 12:48:55 -080067 const Ptr<const Packet> &packet) = 0;
Ilya Moiseenko25f7d4d2011-09-29 18:41:06 -070068
Alexander Afanasyeva5bbe0e2011-11-22 17:28:39 -080069 /**
70 * @brief Set link to PIT for the forwarding strategy
71 *
72 * @param pit pointer to PIT
73 */
74 void
75 SetPit (Ptr<CcnxPit> pit);
Alexander Afanasyevf377b332011-12-16 15:32:12 -080076
Alexander Afanasyev0a61c342011-12-06 12:48:55 -080077protected:
78 /**
Ilya Moiseenko332add02011-12-24 17:21:25 -080079 * @brief Propagate interest via a green interface. Fail, if no green interfaces available
Alexander Afanasyev0a61c342011-12-06 12:48:55 -080080 *
81 * @param pitEntry Reference to PIT entry (reference to corresponding FIB entry inside)
82 * @param incomingFace Incoming face
83 * @param header CcnxInterestHeader
84 * @param packet Original Interest packet
85 * @param sendCallback Send callback
86 * @return true if interest was successfully propagated, false if all options have failed
87 *
88 * \see PropagateInterest
89 */
90 bool
91 PropagateInterestViaGreen (const CcnxPitEntry &pitEntry,
92 const Ptr<CcnxFace> &incomingFace,
93 Ptr<CcnxInterestHeader> &header,
94 const Ptr<const Packet> &packet);
Alexander Afanasyevf377b332011-12-16 15:32:12 -080095
96 TracedCallback<Ptr<const CcnxInterestHeader>, Ptr<const CcnxFace> > m_transmittedInterestsTrace;
Alexander Afanasyev0a61c342011-12-06 12:48:55 -080097
Alexander Afanasyeva5bbe0e2011-11-22 17:28:39 -080098protected:
Ilya Moiseenkoea27f4e2011-10-28 13:19:07 -070099 Ptr<CcnxPit> m_pit;
Alexander Afanasyev98256102011-08-14 01:00:02 -0700100};
101
102} //namespace ns3
103
Alexander Afanasyevc74a6022011-08-15 20:01:35 -0700104#endif /* CCNX_FORWARDING_STRATEGY_H */