face: eliminate Transport::Packet wrapper type

Refs: #4843
Change-Id: I5977be55e8bdac33c989e3b8523fea764f304c37
diff --git a/daemon/face/datagram-transport.hpp b/daemon/face/datagram-transport.hpp
index fcde63b..dfe8bee 100644
--- a/daemon/face/datagram-transport.hpp
+++ b/daemon/face/datagram-transport.hpp
@@ -69,7 +69,7 @@
   doClose() override;
 
   void
-  doSend(Transport::Packet&& packet) override;
+  doSend(const Block& packet, const EndpointId& endpoint) override;
 
   void
   handleSend(const boost::system::error_code& error, size_t nBytesSent);
@@ -157,13 +157,13 @@
 
 template<class T, class U>
 void
-DatagramTransport<T, U>::doSend(Transport::Packet&& packet)
+DatagramTransport<T, U>::doSend(const Block& packet, const EndpointId&)
 {
   NFD_LOG_FACE_TRACE(__func__);
 
-  m_socket.async_send(boost::asio::buffer(packet.packet),
-                      // packet.packet is copied into the lambda to retain the underlying Buffer
-                      [this, p = packet.packet] (auto&&... args) {
+  m_socket.async_send(boost::asio::buffer(packet),
+                      // 'packet' is copied into the lambda to retain the underlying Buffer
+                      [this, packet] (auto&&... args) {
                         this->handleSend(std::forward<decltype(args)>(args)...);
                       });
 }
@@ -193,9 +193,7 @@
   }
   m_hasRecentlyReceived = true;
 
-  Transport::Packet tp(std::move(element));
-  tp.remoteEndpoint = makeEndpointId(m_sender);
-  this->receive(std::move(tp));
+  this->receive(element, makeEndpointId(m_sender));
 }
 
 template<class T, class U>
diff --git a/daemon/face/ethernet-transport.cpp b/daemon/face/ethernet-transport.cpp
index a2f3e9b..6b419bf 100644
--- a/daemon/face/ethernet-transport.cpp
+++ b/daemon/face/ethernet-transport.cpp
@@ -102,11 +102,11 @@
 }
 
 void
-EthernetTransport::doSend(Transport::Packet&& packet)
+EthernetTransport::doSend(const Block& packet, const EndpointId&)
 {
   NFD_LOG_FACE_TRACE(__func__);
 
-  sendPacket(packet.packet);
+  sendPacket(packet);
 }
 
 void
@@ -209,13 +209,13 @@
   }
   m_hasRecentlyReceived = true;
 
-  Transport::Packet tp(std::move(element));
-  static_assert(sizeof(tp.remoteEndpoint) >= ethernet::ADDR_LEN,
-                "Transport::Packet::remoteEndpoint is too small");
+  static_assert(sizeof(EndpointId) >= ethernet::ADDR_LEN, "EndpointId is too small");
+  EndpointId endpoint = 0;
   if (m_destAddress.isMulticast()) {
-    std::memcpy(&tp.remoteEndpoint, sender.data(), sender.size());
+    std::memcpy(&endpoint, sender.data(), sender.size());
   }
-  this->receive(std::move(tp));
+
+  this->receive(element, endpoint);
 }
 
 void
diff --git a/daemon/face/ethernet-transport.hpp b/daemon/face/ethernet-transport.hpp
index 798b937..8258285 100644
--- a/daemon/face/ethernet-transport.hpp
+++ b/daemon/face/ethernet-transport.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2018,  Regents of the University of California,
+ * Copyright (c) 2014-2019,  Regents of the University of California,
  *                           Arizona Board of Regents,
  *                           Colorado State University,
  *                           University Pierre & Marie Curie, Sorbonne University,
@@ -29,6 +29,7 @@
 #include "ethernet-protocol.hpp"
 #include "pcap-helper.hpp"
 #include "transport.hpp"
+
 #include <ndn-cxx/net/network-interface.hpp>
 
 namespace nfd {
@@ -43,11 +44,7 @@
   class Error : public std::runtime_error
   {
   public:
-    explicit
-    Error(const std::string& what)
-      : std::runtime_error(what)
-    {
-    }
+    using std::runtime_error::runtime_error;
   };
 
   /**
@@ -84,7 +81,7 @@
   handleNetifStateChange(ndn::net::InterfaceState netifState);
 
   void
-  doSend(Transport::Packet&& packet) final;
+  doSend(const Block& packet, const EndpointId& endpoint) final;
 
   /**
    * @brief Sends the specified TLV block on the network wrapped in an Ethernet frame
diff --git a/daemon/face/face-endpoint.hpp b/daemon/face/face-endpoint.hpp
index cf2c466..4d33634 100644
--- a/daemon/face/face-endpoint.hpp
+++ b/daemon/face/face-endpoint.hpp
@@ -30,7 +30,8 @@
 
 namespace nfd {
 
-/** \brief Represents a face-endpoint pair in the forwarder
+/** \brief Represents a face-endpoint pair in the forwarder.
+ *  \sa face::Face, face::EndpointId
  */
 class FaceEndpoint
 {
@@ -49,7 +50,7 @@
 inline std::ostream&
 operator<<(std::ostream& os, const FaceEndpoint& fe)
 {
-  return os << "(" << fe.face.getId() << "," << fe.endpoint << ")";
+  return os << '(' << fe.face.getId() << ',' << fe.endpoint << ')';
 }
 
 } // namespace nfd
diff --git a/daemon/face/generic-link-service.cpp b/daemon/face/generic-link-service.cpp
index 09b874c..5a3664c 100644
--- a/daemon/face/generic-link-service.cpp
+++ b/daemon/face/generic-link-service.cpp
@@ -85,13 +85,13 @@
     checkCongestionLevel(pkt);
   }
 
-  Transport::Packet tp(pkt.wireEncode());
-  if (mtu != MTU_UNLIMITED && tp.packet.size() > static_cast<size_t>(mtu)) {
+  auto block = pkt.wireEncode();
+  if (mtu != MTU_UNLIMITED && block.size() > static_cast<size_t>(mtu)) {
     ++this->nOutOverMtu;
     NFD_LOG_FACE_WARN("attempted to send packet over MTU limit");
     return;
   }
-  this->sendPacket(std::move(tp), endpointId);
+  this->sendPacket(block, endpointId);
 }
 
 void
@@ -276,10 +276,10 @@
 }
 
 void
-GenericLinkService::doReceivePacket(Transport::Packet&& packet)
+GenericLinkService::doReceivePacket(const Block& packet, const EndpointId& endpoint)
 {
   try {
-    lp::Packet pkt(packet.packet);
+    lp::Packet pkt(packet);
 
     if (m_options.reliabilityOptions.isEnabled) {
       m_reliability.processIncomingPacket(pkt);
@@ -299,10 +299,9 @@
     bool isReassembled = false;
     Block netPkt;
     lp::Packet firstPkt;
-    std::tie(isReassembled, netPkt, firstPkt) = m_reassembler.receiveFragment(packet.remoteEndpoint,
-                                                                              pkt);
+    std::tie(isReassembled, netPkt, firstPkt) = m_reassembler.receiveFragment(endpoint, pkt);
     if (isReassembled) {
-      this->decodeNetPacket(netPkt, firstPkt, packet.remoteEndpoint);
+      this->decodeNetPacket(netPkt, firstPkt, endpoint);
     }
   }
   catch (const tlv::Error& e) {
diff --git a/daemon/face/generic-link-service.hpp b/daemon/face/generic-link-service.hpp
index c28b9ef..fe8e962 100644
--- a/daemon/face/generic-link-service.hpp
+++ b/daemon/face/generic-link-service.hpp
@@ -232,7 +232,7 @@
   /** \brief receive Packet from Transport
    */
   void
-  doReceivePacket(Transport::Packet&& packet) OVERRIDE_WITH_TESTS_ELSE_FINAL;
+  doReceivePacket(const Block& packet, const EndpointId& endpoint) OVERRIDE_WITH_TESTS_ELSE_FINAL;
 
   /** \brief decode incoming network-layer packet
    *  \param netPkt reassembled network-layer packet
diff --git a/daemon/face/internal-transport.cpp b/daemon/face/internal-transport.cpp
index 18bfe0a..e5d598a 100644
--- a/daemon/face/internal-transport.cpp
+++ b/daemon/face/internal-transport.cpp
@@ -46,21 +46,21 @@
 }
 
 void
-InternalForwarderTransport::receivePacket(Block&& packet)
+InternalForwarderTransport::receivePacket(const Block& packet)
 {
-  getGlobalIoService().post([this, pkt = std::move(packet)] () mutable {
-    NFD_LOG_FACE_TRACE("Received: " << pkt.size() << " bytes");
-    receive(Packet{std::move(pkt)});
+  getGlobalIoService().post([this, packet] {
+    NFD_LOG_FACE_TRACE("Received: " << packet.size() << " bytes");
+    receive(packet);
   });
 }
 
 void
-InternalForwarderTransport::doSend(Packet&& packet)
+InternalForwarderTransport::doSend(const Block& packet, const EndpointId&)
 {
   NFD_LOG_FACE_TRACE("Sending to " << m_peer);
 
   if (m_peer)
-    m_peer->receivePacket(std::move(packet.packet));
+    m_peer->receivePacket(packet);
 }
 
 void
@@ -104,12 +104,12 @@
 }
 
 void
-InternalClientTransport::receivePacket(Block&& packet)
+InternalClientTransport::receivePacket(const Block& packet)
 {
-  getGlobalIoService().post([this, pkt = std::move(packet)] {
-    NFD_LOG_TRACE("Received: " << pkt.size() << " bytes");
+  getGlobalIoService().post([this, packet] {
+    NFD_LOG_TRACE("Received: " << packet.size() << " bytes");
     if (m_receiveCallback) {
-      m_receiveCallback(pkt);
+      m_receiveCallback(packet);
     }
   });
 }
@@ -120,7 +120,7 @@
   NFD_LOG_TRACE("Sending to " << m_forwarder);
 
   if (m_forwarder)
-    m_forwarder->receivePacket(Block{wire});
+    m_forwarder->receivePacket(wire);
 }
 
 void
diff --git a/daemon/face/internal-transport.hpp b/daemon/face/internal-transport.hpp
index f859099..71ae4d5 100644
--- a/daemon/face/internal-transport.hpp
+++ b/daemon/face/internal-transport.hpp
@@ -42,7 +42,7 @@
   ~InternalTransportBase() = default;
 
   virtual void
-  receivePacket(Block&& packet) = 0;
+  receivePacket(const Block& packet) = 0;
 };
 
 /** \brief Implements a forwarder-side transport that can be paired with another transport.
@@ -63,7 +63,7 @@
   }
 
   void
-  receivePacket(Block&& packet) final;
+  receivePacket(const Block& packet) final;
 
 protected:
   void
@@ -71,7 +71,7 @@
 
 private:
   void
-  doSend(Packet&& packet) final;
+  doSend(const Block& packet, const EndpointId& endpoint) final;
 
 private:
   NFD_LOG_MEMBER_DECL();
@@ -98,7 +98,7 @@
   connectToForwarder(InternalForwarderTransport* forwarder);
 
   void
-  receivePacket(Block&& packet) final;
+  receivePacket(const Block& packet) final;
 
   void
   send(const Block& wire) final;
diff --git a/daemon/face/link-service.cpp b/daemon/face/link-service.cpp
index 34abd58..a382ebe 100644
--- a/daemon/face/link-service.cpp
+++ b/daemon/face/link-service.cpp
@@ -52,66 +52,66 @@
 }
 
 void
-LinkService::sendInterest(const Interest& interest, const EndpointId& endpointId)
+LinkService::sendInterest(const Interest& interest, const EndpointId& endpoint)
 {
   BOOST_ASSERT(m_transport != nullptr);
   NFD_LOG_FACE_TRACE(__func__);
 
   ++this->nOutInterests;
 
-  doSendInterest(interest, endpointId);
+  doSendInterest(interest, endpoint);
 }
 
 void
-LinkService::sendData(const Data& data, const EndpointId& endpointId)
+LinkService::sendData(const Data& data, const EndpointId& endpoint)
 {
   BOOST_ASSERT(m_transport != nullptr);
   NFD_LOG_FACE_TRACE(__func__);
 
   ++this->nOutData;
 
-  doSendData(data, endpointId);
+  doSendData(data, endpoint);
 }
 
 void
-LinkService::sendNack(const ndn::lp::Nack& nack, const EndpointId& endpointId)
+LinkService::sendNack(const ndn::lp::Nack& nack, const EndpointId& endpoint)
 {
   BOOST_ASSERT(m_transport != nullptr);
   NFD_LOG_FACE_TRACE(__func__);
 
   ++this->nOutNacks;
 
-  doSendNack(nack, endpointId);
+  doSendNack(nack, endpoint);
 }
 
 void
-LinkService::receiveInterest(const Interest& interest, const EndpointId& endpointId)
+LinkService::receiveInterest(const Interest& interest, const EndpointId& endpoint)
 {
   NFD_LOG_FACE_TRACE(__func__);
 
   ++this->nInInterests;
 
-  afterReceiveInterest(interest, endpointId);
+  afterReceiveInterest(interest, endpoint);
 }
 
 void
-LinkService::receiveData(const Data& data, const EndpointId& endpointId)
+LinkService::receiveData(const Data& data, const EndpointId& endpoint)
 {
   NFD_LOG_FACE_TRACE(__func__);
 
   ++this->nInData;
 
-  afterReceiveData(data, endpointId);
+  afterReceiveData(data, endpoint);
 }
 
 void
-LinkService::receiveNack(const ndn::lp::Nack& nack, const EndpointId& endpointId)
+LinkService::receiveNack(const ndn::lp::Nack& nack, const EndpointId& endpoint)
 {
   NFD_LOG_FACE_TRACE(__func__);
 
   ++this->nInNacks;
 
-  afterReceiveNack(nack, endpointId);
+  afterReceiveNack(nack, endpoint);
 }
 
 void
diff --git a/daemon/face/link-service.hpp b/daemon/face/link-service.hpp
index fd77391..8396137 100644
--- a/daemon/face/link-service.hpp
+++ b/daemon/face/link-service.hpp
@@ -112,23 +112,23 @@
   getCounters() const;
 
 public: // upper interface to be used by forwarding
-  /** \brief send Interest to \p endpointId
+  /** \brief Send Interest to \p endpoint
    *  \pre setTransport has been called
    */
   void
-  sendInterest(const Interest& interest, const EndpointId& endpointId);
+  sendInterest(const Interest& interest, const EndpointId& endpoint);
 
-  /** \brief send Data to \p endpointId
+  /** \brief Send Data to \p endpoint
    *  \pre setTransport has been called
    */
   void
-  sendData(const Data& data, const EndpointId& endpointId);
+  sendData(const Data& data, const EndpointId& endpoint);
 
-  /** \brief send Nack to \p endpointId
+  /** \brief Send Nack to \p endpoint
    *  \pre setTransport has been called
    */
   void
-  sendNack(const ndn::lp::Nack& nack, const EndpointId& endpointId);
+  sendNack(const ndn::lp::Nack& nack, const EndpointId& endpoint);
 
   /** \brief signals on Interest received
    */
@@ -150,53 +150,53 @@
   /** \brief performs LinkService specific operations to receive a lower-layer packet
    */
   void
-  receivePacket(Transport::Packet&& packet);
+  receivePacket(const Block& packet, const EndpointId& endpoint);
 
 protected: // upper interface to be invoked in subclass (receive path termination)
   /** \brief delivers received Interest to forwarding
    */
   void
-  receiveInterest(const Interest& interest, const EndpointId& endpointId);
+  receiveInterest(const Interest& interest, const EndpointId& endpoint);
 
   /** \brief delivers received Data to forwarding
    */
   void
-  receiveData(const Data& data, const EndpointId& endpointId);
+  receiveData(const Data& data, const EndpointId& endpoint);
 
   /** \brief delivers received Nack to forwarding
    */
   void
-  receiveNack(const lp::Nack& nack, const EndpointId& endpointId);
+  receiveNack(const lp::Nack& nack, const EndpointId& endpoint);
 
 protected: // lower interface to be invoked in subclass (send path termination)
-  /** \brief send a lower-layer packet via Transport to \p endpointId
+  /** \brief send a lower-layer packet via Transport to \p endpoint
    */
   void
-  sendPacket(Transport::Packet&& packet, const EndpointId& endpointId);
+  sendPacket(const Block& packet, const EndpointId& endpoint);
 
 protected:
   void
   notifyDroppedInterest(const Interest& packet);
 
 private: // upper interface to be overridden in subclass (send path entrypoint)
-  /** \brief performs LinkService specific operations to send an Interest to \p endpointId
+  /** \brief performs LinkService specific operations to send an Interest to \p endpoint
    */
   virtual void
-  doSendInterest(const Interest& interest, const EndpointId& endpointId) = 0;
+  doSendInterest(const Interest& interest, const EndpointId& endpoint) = 0;
 
-  /** \brief performs LinkService specific operations to send a Data to \p endpointId
+  /** \brief performs LinkService specific operations to send a Data to \p endpoint
    */
   virtual void
-  doSendData(const Data& data, const EndpointId& endpointId) = 0;
+  doSendData(const Data& data, const EndpointId& endpoint) = 0;
 
-  /** \brief performs LinkService specific operations to send a Nack to \p endpointId
+  /** \brief performs LinkService specific operations to send a Nack to \p endpoint
    */
   virtual void
-  doSendNack(const lp::Nack& nack, const EndpointId& endpointId) = 0;
+  doSendNack(const lp::Nack& nack, const EndpointId& endpoint) = 0;
 
 private: // lower interface to be overridden in subclass
   virtual void
-  doReceivePacket(Transport::Packet&& packet) = 0;
+  doReceivePacket(const Block& packet, const EndpointId& endpoint) = 0;
 
 private:
   Face* m_face;
@@ -228,16 +228,15 @@
 }
 
 inline void
-LinkService::receivePacket(Transport::Packet&& packet)
+LinkService::receivePacket(const Block& packet, const EndpointId& endpoint)
 {
-  doReceivePacket(std::move(packet));
+  doReceivePacket(packet, endpoint);
 }
 
 inline void
-LinkService::sendPacket(Transport::Packet&& packet, const EndpointId& endpointId)
+LinkService::sendPacket(const Block& packet, const EndpointId& endpoint)
 {
-  packet.remoteEndpoint = endpointId;
-  m_transport->send(std::move(packet));
+  m_transport->send(packet, endpoint);
 }
 
 std::ostream&
diff --git a/daemon/face/lp-reassembler.hpp b/daemon/face/lp-reassembler.hpp
index 2c5ff91..e9f0556 100644
--- a/daemon/face/lp-reassembler.hpp
+++ b/daemon/face/lp-reassembler.hpp
@@ -72,13 +72,13 @@
   const LinkService*
   getLinkService() const;
 
-  /** \brief adds received fragment to buffer
-   *  \param remoteEndpoint endpoint whose sends the packet
-   *  \param packet received fragment;
-   *                must have Fragment field
-   *  \return whether network-layer packet has been completely received,
+  /** \brief adds received fragment to the buffer
+   *  \param remoteEndpoint endpoint that sent the packet
+   *  \param packet received fragment; must have Fragment field
+   *  \return a tuple containing:
+   *          whether a network-layer packet has been completely received,
    *          the reassembled network-layer packet,
-   *          and the first fragment for inspecting other NDNLPv2 headers
+   *          the first fragment for inspecting other NDNLPv2 headers
    *  \throw tlv::Error packet is malformed
    */
   std::tuple<bool, Block, lp::Packet>
diff --git a/daemon/face/multicast-udp-transport.cpp b/daemon/face/multicast-udp-transport.cpp
index 689b7e0..5017e7d 100644
--- a/daemon/face/multicast-udp-transport.cpp
+++ b/daemon/face/multicast-udp-transport.cpp
@@ -82,13 +82,13 @@
 }
 
 void
-MulticastUdpTransport::doSend(Transport::Packet&& packet)
+MulticastUdpTransport::doSend(const Block& packet, const EndpointId&)
 {
   NFD_LOG_FACE_TRACE(__func__);
 
-  m_sendSocket.async_send_to(boost::asio::buffer(packet.packet), m_multicastGroup,
-                             // packet.packet is copied into the lambda to retain the underlying Buffer
-                             [this, p = packet.packet] (auto&&... args) {
+  m_sendSocket.async_send_to(boost::asio::buffer(packet), m_multicastGroup,
+                             // 'packet' is copied into the lambda to retain the underlying Buffer
+                             [this, packet] (auto&&... args) {
                                this->handleSend(std::forward<decltype(args)>(args)...);
                              });
 }
diff --git a/daemon/face/multicast-udp-transport.hpp b/daemon/face/multicast-udp-transport.hpp
index bea7cb4..c85df82 100644
--- a/daemon/face/multicast-udp-transport.hpp
+++ b/daemon/face/multicast-udp-transport.hpp
@@ -52,11 +52,7 @@
   class Error : public std::runtime_error
   {
   public:
-    explicit
-    Error(const std::string& what)
-      : std::runtime_error(what)
-    {
-    }
+    using std::runtime_error::runtime_error;
   };
 
   /**
@@ -88,7 +84,7 @@
 
 private:
   void
-  doSend(Transport::Packet&& packet) final;
+  doSend(const Block& packet, const EndpointId& endpoint) final;
 
   void
   doClose() final;
diff --git a/daemon/face/null-link-service.hpp b/daemon/face/null-link-service.hpp
index d31304b..3823d9a 100644
--- a/daemon/face/null-link-service.hpp
+++ b/daemon/face/null-link-service.hpp
@@ -52,7 +52,7 @@
   }
 
   void
-  doReceivePacket(Transport::Packet&&) final
+  doReceivePacket(const Block&, const EndpointId&) final
   {
   }
 };
diff --git a/daemon/face/null-transport.hpp b/daemon/face/null-transport.hpp
index 9f8e54e..303b1e8 100644
--- a/daemon/face/null-transport.hpp
+++ b/daemon/face/null-transport.hpp
@@ -51,7 +51,7 @@
 
 private:
   void
-  doSend(Packet&&) OVERRIDE_WITH_TESTS_ELSE_FINAL
+  doSend(const Block&, const EndpointId&) OVERRIDE_WITH_TESTS_ELSE_FINAL
   {
   }
 };
diff --git a/daemon/face/stream-transport.hpp b/daemon/face/stream-transport.hpp
index e0a7d6d..04941b5 100644
--- a/daemon/face/stream-transport.hpp
+++ b/daemon/face/stream-transport.hpp
@@ -63,7 +63,7 @@
   deferredClose();
 
   void
-  doSend(Transport::Packet&& packet) override;
+  doSend(const Block& packet, const EndpointId& endpoint) override;
 
   void
   sendFromQueue();
@@ -180,7 +180,7 @@
 
 template<class T>
 void
-StreamTransport<T>::doSend(Transport::Packet&& packet)
+StreamTransport<T>::doSend(const Block& packet, const EndpointId&)
 {
   NFD_LOG_FACE_TRACE(__func__);
 
@@ -188,8 +188,8 @@
     return;
 
   bool wasQueueEmpty = m_sendQueue.empty();
-  m_sendQueue.push(packet.packet);
-  m_sendQueueBytes += packet.packet.size();
+  m_sendQueue.push(packet);
+  m_sendQueueBytes += packet.size();
 
   if (wasQueueEmpty)
     sendFromQueue();
@@ -255,7 +255,7 @@
     offset += element.size();
     BOOST_ASSERT(offset <= m_receiveBufferSize);
 
-    this->receive(Transport::Packet(std::move(element)));
+    this->receive(element);
   }
 
   if (!isOk && m_receiveBufferSize == ndn::MAX_NDN_PACKET_SIZE && offset == 0) {
diff --git a/daemon/face/transport.cpp b/daemon/face/transport.cpp
index e93480f..7b1bb18 100644
--- a/daemon/face/transport.cpp
+++ b/daemon/face/transport.cpp
@@ -52,12 +52,6 @@
   }
 }
 
-Transport::Packet::Packet(Block&& packet1)
-  : packet(std::move(packet1))
-  , remoteEndpoint(0)
-{
-}
-
 Transport::Transport()
   : m_face(nullptr)
   , m_service(nullptr)
@@ -97,10 +91,11 @@
 }
 
 void
-Transport::send(Packet&& packet)
+Transport::send(const Block& packet, const EndpointId& endpoint)
 {
+  BOOST_ASSERT(packet.isValid());
   BOOST_ASSERT(this->getMtu() == MTU_UNLIMITED ||
-               packet.packet.size() <= static_cast<size_t>(this->getMtu()));
+               packet.size() <= static_cast<size_t>(this->getMtu()));
 
   TransportState state = this->getState();
   if (state != TransportState::UP && state != TransportState::DOWN) {
@@ -110,22 +105,23 @@
 
   if (state == TransportState::UP) {
     ++this->nOutPackets;
-    this->nOutBytes += packet.packet.size();
+    this->nOutBytes += packet.size();
   }
 
-  this->doSend(std::move(packet));
+  this->doSend(packet, endpoint);
 }
 
 void
-Transport::receive(Packet&& packet)
+Transport::receive(const Block& packet, const EndpointId& endpoint)
 {
+  BOOST_ASSERT(packet.isValid());
   BOOST_ASSERT(this->getMtu() == MTU_UNLIMITED ||
-               packet.packet.size() <= static_cast<size_t>(this->getMtu()));
+               packet.size() <= static_cast<size_t>(this->getMtu()));
 
   ++this->nInPackets;
-  this->nInBytes += packet.packet.size();
+  this->nInBytes += packet.size();
 
-  m_service->receivePacket(std::move(packet));
+  m_service->receivePacket(packet, endpoint);
 }
 
 bool
diff --git a/daemon/face/transport.hpp b/daemon/face/transport.hpp
index aaea75a..2dd81a0 100644
--- a/daemon/face/transport.hpp
+++ b/daemon/face/transport.hpp
@@ -37,11 +37,19 @@
 class Face;
 class LinkService;
 
-/** \brief identifies an endpoint on the link
+/** \brief Identifies a remote endpoint on the link.
+ *
+ *  This ID is only meaningful in the context of the same Transport.
+ *  Incoming packets from the same remote endpoint have the same EndpointId,
+ *  and incoming packets from different remote endpoints have different EndpointIds.
+ *
+ *  Typically, a point-to-point Transport has only one meaningful EndpointId (usually 0).
+ *
+ *  \sa FaceEndpoint
  */
-typedef uint64_t EndpointId;
+using EndpointId = uint64_t;
 
-/** \brief indicates the state of a transport
+/** \brief Indicates the state of a transport.
  */
 enum class TransportState {
   NONE,
@@ -55,9 +63,9 @@
 std::ostream&
 operator<<(std::ostream& os, TransportState state);
 
-/** \brief counters provided by Transport
- *  \note The type name 'TransportCounters' is implementation detail.
- *        Use 'Transport::Counters' in public API.
+/** \brief Counters provided by a transport.
+ *  \note The type name TransportCounters is an implementation detail.
+ *        Use Transport::Counters in public API.
  */
 class TransportCounters
 {
@@ -111,43 +119,20 @@
  */
 const ssize_t QUEUE_ERROR = -2;
 
-/** \brief the lower part of a Face
+/** \brief The lower half of a Face.
  *  \sa Face
  */
 class Transport : protected virtual TransportCounters, noncopyable
 {
 public:
-  /** \brief stores a packet along with the remote endpoint
+  /** \brief Counters provided by a transport.
+   *  \sa TransportCounters
    */
-  class Packet
-  {
-  public:
-    Packet() = default;
+  using Counters = TransportCounters;
 
-    explicit
-    Packet(Block&& packet);
-
-  public:
-    /** \brief the packet as a TLV block
-     */
-    Block packet;
-
-    /** \brief identifies the remote endpoint
-     *
-     *  This ID is only meaningful in the context of the same Transport.
-     *  Incoming packets from the same remote endpoint have the same EndpointId,
-     *  and incoming packets from different remote endpoints have different EndpointIds.
-     */
-    EndpointId remoteEndpoint;
-  };
-
-  /** \brief counters provided by Transport
-   */
-  typedef TransportCounters Counters;
-
-  /** \brief constructor
+  /** \brief Default constructor.
    *
-   *  Transport constructor initializes static properties to invalid values.
+   *  This constructor initializes static properties to invalid values.
    *  Subclass constructor must explicitly set every static property.
    *
    *  This constructor initializes TransportState to UP;
@@ -184,7 +169,7 @@
   getCounters() const;
 
 public: // upper interface
-  /** \brief request the transport to be closed
+  /** \brief Request the transport to be closed
    *
    *  This operation is effective only if transport is in UP or DOWN state,
    *  otherwise it has no effect.
@@ -195,12 +180,14 @@
   void
   close();
 
-  /** \brief send a link-layer packet
-   *  \note This operation has no effect if \p getState() is neither UP nor DOWN
-   *  \warning undefined behavior if packet size exceeds MTU limit
+  /** \brief Send a link-layer packet
+   *  \param packet the packet to be sent, must be a valid and well-formed TLV block
+   *  \param endpoint the destination endpoint
+   *  \note This operation has no effect if getState() is neither UP nor DOWN
+   *  \warning Behavior is undefined if packet size exceeds the MTU limit
    */
   void
-  send(Packet&& packet);
+  send(const Block& packet, const EndpointId& endpoint = 0);
 
 public: // static properties
   /** \return a FaceUri representing local endpoint
@@ -239,7 +226,7 @@
   void
   setPersistency(ndn::nfd::FacePersistency newPersistency);
 
-  /** \return whether face is point-to-point or multi-access
+  /** \return the link type of the transport
    */
   ndn::nfd::LinkType
   getLinkType() const;
@@ -290,11 +277,13 @@
   }
 
 protected: // upper interface to be invoked by subclass
-  /** \brief receive a link-layer packet
-   *  \warning undefined behavior if packet size exceeds MTU limit
+  /** \brief Pass a received link-layer packet to the upper layer for further processing
+   *  \param packet the received packet, must be a valid and well-formed TLV block
+   *  \param endpoint the source endpoint
+   *  \warning Behavior is undefined if packet size exceeds the MTU limit
    */
   void
-  receive(Packet&& packet);
+  receive(const Block& packet, const EndpointId& endpoint = 0);
 
 protected: // properties to be set by subclass
   void
@@ -360,11 +349,12 @@
 
 private: // to be overridden by subclass
   /** \brief performs Transport specific operations to send a packet
-   *  \param packet the packet, which must be a well-formed TLV block
-   *  \pre state is either UP or DOWN
+   *  \param packet the packet to be sent, can be assumed to be valid and well-formed
+   *  \param endpoint the destination endpoint
+   *  \pre transport state is either UP or DOWN
    */
   virtual void
-  doSend(Packet&& packet) = 0;
+  doSend(const Block& packet, const EndpointId& endpoint) = 0;
 
 public:
   /** \brief minimum MTU that may be set on a transport
diff --git a/daemon/face/websocket-transport.cpp b/daemon/face/websocket-transport.cpp
index d20e54c..bd45711 100644
--- a/daemon/face/websocket-transport.cpp
+++ b/daemon/face/websocket-transport.cpp
@@ -78,17 +78,17 @@
 }
 
 void
-WebSocketTransport::doSend(Transport::Packet&& packet)
+WebSocketTransport::doSend(const Block& packet, const EndpointId&)
 {
   NFD_LOG_FACE_TRACE(__func__);
 
   websocketpp::lib::error_code error;
-  m_server.send(m_handle, packet.packet.wire(), packet.packet.size(),
+  m_server.send(m_handle, packet.wire(), packet.size(),
                 websocketpp::frame::opcode::binary, error);
   if (error)
     return processErrorCode(error);
 
-  NFD_LOG_FACE_TRACE("Successfully sent: " << packet.packet.size() << " bytes");
+  NFD_LOG_FACE_TRACE("Successfully sent: " << packet.size() << " bytes");
 }
 
 void
@@ -104,7 +104,7 @@
     return;
   }
 
-  this->receive(Transport::Packet(std::move(element)));
+  this->receive(element);
 }
 
 void
diff --git a/daemon/face/websocket-transport.hpp b/daemon/face/websocket-transport.hpp
index 0bdadb5..10f4b2a 100644
--- a/daemon/face/websocket-transport.hpp
+++ b/daemon/face/websocket-transport.hpp
@@ -83,7 +83,7 @@
 
 private:
   void
-  doSend(Transport::Packet&& packet) final;
+  doSend(const Block& packet, const EndpointId& endpoint) final;
 
   void
   schedulePing();