Alexander Afanasyev | 60a7b62 | 2014-12-20 17:04:07 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (c) 2011-2015 Regents of the University of California. |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 4 | * |
Alexander Afanasyev | 60a7b62 | 2014-12-20 17:04:07 -0800 | [diff] [blame] | 5 | * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and |
| 6 | * contributors. |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 7 | * |
Alexander Afanasyev | 60a7b62 | 2014-12-20 17:04:07 -0800 | [diff] [blame] | 8 | * 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 Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 11 | * |
Alexander Afanasyev | 60a7b62 | 2014-12-20 17:04:07 -0800 | [diff] [blame] | 12 | * 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 Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 15 | * |
Alexander Afanasyev | 60a7b62 | 2014-12-20 17:04:07 -0800 | [diff] [blame] | 16 | * 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 | **/ |
Ilya Moiseenko | 1cf6b0a | 2011-08-29 13:02:34 -0700 | [diff] [blame] | 19 | |
Alexander Afanasyev | c018a56 | 2016-09-08 16:27:31 -0700 | [diff] [blame] | 20 | #ifndef NDN_APP_LINK_SERVICE_HPP |
| 21 | #define NDN_APP_LINK_SERVICE_HPP |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 22 | |
Spyridon Mastorakis | 53e922f | 2014-10-17 17:29:26 -0700 | [diff] [blame] | 23 | #include "ns3/ndnSIM/model/ndn-common.hpp" |
Alexander Afanasyev | c018a56 | 2016-09-08 16:27:31 -0700 | [diff] [blame] | 24 | #include "ns3/ndnSIM/NFD/daemon/face/link-service.hpp" |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 25 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 26 | namespace ns3 { |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 27 | |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 28 | class Packet; |
Alexander Afanasyev | 82d5ffe | 2014-12-30 23:55:38 -0800 | [diff] [blame] | 29 | class Node; |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 30 | |
| 31 | namespace ndn { |
| 32 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 33 | class App; |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 34 | |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 35 | /** |
Alexander Afanasyev | 4aac557 | 2012-08-09 10:49:55 -0700 | [diff] [blame] | 36 | * \ingroup ndn-face |
Alexander Afanasyev | c018a56 | 2016-09-08 16:27:31 -0700 | [diff] [blame] | 37 | * \brief Implementation of LinkService for ndnSIM application |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 38 | * |
Alexander Afanasyev | c018a56 | 2016-09-08 16:27:31 -0700 | [diff] [blame] | 39 | * \see NetDeviceLinkService |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 40 | */ |
Alexander Afanasyev | c018a56 | 2016-09-08 16:27:31 -0700 | [diff] [blame] | 41 | class AppLinkService : public nfd::face::LinkService |
| 42 | { |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 43 | public: |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 44 | /** |
| 45 | * \brief Default constructor |
| 46 | */ |
Alexander Afanasyev | c018a56 | 2016-09-08 16:27:31 -0700 | [diff] [blame] | 47 | AppLinkService(Ptr<App> app); |
Alexander Afanasyev | 82d5ffe | 2014-12-30 23:55:38 -0800 | [diff] [blame] | 48 | |
Alexander Afanasyev | c018a56 | 2016-09-08 16:27:31 -0700 | [diff] [blame] | 49 | virtual ~AppLinkService(); |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 50 | |
Alexander Afanasyev | c018a56 | 2016-09-08 16:27:31 -0700 | [diff] [blame] | 51 | public: |
Alexander Afanasyev | c3c7f04 | 2015-08-21 11:38:00 -0700 | [diff] [blame] | 52 | void |
| 53 | onReceiveInterest(const Interest& interest); |
| 54 | |
Alexander Afanasyev | c3c7f04 | 2015-08-21 11:38:00 -0700 | [diff] [blame] | 55 | void |
| 56 | onReceiveData(const Data& data); |
| 57 | |
Alexander Afanasyev | c018a56 | 2016-09-08 16:27:31 -0700 | [diff] [blame] | 58 | void |
| 59 | onReceiveNack(const lp::Nack& nack); |
| 60 | |
| 61 | private: |
Alexander Afanasyev | 82d5ffe | 2014-12-30 23:55:38 -0800 | [diff] [blame] | 62 | virtual void |
Alexander Afanasyev | f007a99 | 2022-05-05 15:57:08 -0400 | [diff] [blame^] | 63 | doSendInterest(const Interest& interest) override; |
Alexander Afanasyev | c018a56 | 2016-09-08 16:27:31 -0700 | [diff] [blame] | 64 | |
| 65 | virtual void |
Alexander Afanasyev | f007a99 | 2022-05-05 15:57:08 -0400 | [diff] [blame^] | 66 | doSendData(const Data& data) override; |
Alexander Afanasyev | c018a56 | 2016-09-08 16:27:31 -0700 | [diff] [blame] | 67 | |
| 68 | virtual void |
Alexander Afanasyev | f007a99 | 2022-05-05 15:57:08 -0400 | [diff] [blame^] | 69 | doSendNack(const lp::Nack& nack) override; |
Alexander Afanasyev | c018a56 | 2016-09-08 16:27:31 -0700 | [diff] [blame] | 70 | |
| 71 | virtual void |
Alexander Afanasyev | 59090db | 2020-02-21 16:37:43 -0500 | [diff] [blame] | 72 | doReceivePacket(const Block& packet, const nfd::EndpointId& endpoint) override |
Alexander Afanasyev | c018a56 | 2016-09-08 16:27:31 -0700 | [diff] [blame] | 73 | { |
| 74 | // does nothing (all operations for now handled by LinkService) |
| 75 | BOOST_ASSERT(false); |
| 76 | } |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 77 | |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 78 | private: |
Alexander Afanasyev | 82d5ffe | 2014-12-30 23:55:38 -0800 | [diff] [blame] | 79 | Ptr<Node> m_node; |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 80 | Ptr<App> m_app; |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 81 | }; |
| 82 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 83 | } // namespace ndn |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 84 | } // namespace ns3 |
| 85 | |
Alexander Afanasyev | c018a56 | 2016-09-08 16:27:31 -0700 | [diff] [blame] | 86 | #endif // NDN_APP_LINK_SERVICE_HPP |