diff --git a/daemon/face/ethernet-channel-factory.cpp b/daemon/face/ethernet-channel-factory.cpp
new file mode 100644
index 0000000..4c47f85
--- /dev/null
+++ b/daemon/face/ethernet-channel-factory.cpp
@@ -0,0 +1,102 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (C) 2014 Named Data Networking Project
+ * See COPYING for copyright and distribution information.
+ */
+
+#include "ethernet-channel-factory.hpp"
+#include "core/global-io.hpp"
+
+#include <boost/algorithm/string/predicate.hpp>
+#include <pcap/pcap.h>
+
+namespace nfd {
+
+NFD_LOG_INIT("EthernetChannelFactory")
+
+shared_ptr<EthernetFace>
+EthernetChannelFactory::createMulticast(const ethernet::Endpoint& interface,
+                                        const ethernet::Address& address)
+{
+  std::vector<ethernet::Endpoint> ifs = findAllInterfaces();
+  if (std::find(ifs.begin(), ifs.end(), interface) == ifs.end())
+    throw Error(interface + " does not exist");
+
+  if (!address.isMulticast())
+    throw Error(address.toString() + " is not a multicast address");
+
+  shared_ptr<EthernetFace> face = findMulticast(interface, address);
+  if (face)
+    return face;
+
+  shared_ptr<boost::asio::posix::stream_descriptor> socket =
+    make_shared<boost::asio::posix::stream_descriptor>(boost::ref(getGlobalIoService()));
+
+  face = make_shared<EthernetFace>(boost::cref(socket),
+                                   boost::cref(interface),
+                                   boost::cref(address));
+  face->onFail += bind(&EthernetChannelFactory::afterFaceFailed,
+                       this, interface, address);
+  m_multicastFaces[std::make_pair(interface, address)] = face;
+
+  return face;
+}
+
+std::vector<ethernet::Endpoint>
+EthernetChannelFactory::findAllInterfaces()
+{
+  std::vector<ethernet::Endpoint> interfaces;
+  char errbuf[PCAP_ERRBUF_SIZE];
+  errbuf[0] = '\0';
+
+  pcap_if_t* alldevs;
+  if (pcap_findalldevs(&alldevs, errbuf) < 0)
+    {
+      NFD_LOG_WARN("pcap_findalldevs() failed: " << errbuf);
+      return interfaces;
+    }
+
+  for (pcap_if_t* device = alldevs; device != 0; device = device->next)
+    {
+      if ((device->flags & PCAP_IF_LOOPBACK) != 0)
+        // ignore loopback devices
+        continue;
+
+      ethernet::Endpoint interface(device->name);
+      if (interface == "any")
+        // ignore libpcap "any" pseudo-device
+        continue;
+      if (boost::starts_with(interface, "nflog") ||
+          boost::starts_with(interface, "nfqueue"))
+        // ignore Linux netfilter devices
+        continue;
+
+      // maybe add interface addresses too
+      // interface.addAddress ...
+      interfaces.push_back(interface);
+    }
+
+  pcap_freealldevs(alldevs);
+  return interfaces;
+}
+
+void
+EthernetChannelFactory::afterFaceFailed(const ethernet::Endpoint& interface,
+                                        const ethernet::Address& address)
+{
+  NFD_LOG_DEBUG("afterFaceFailed: " << interface << "/" << address);
+  m_multicastFaces.erase(std::make_pair(interface, address));
+}
+
+shared_ptr<EthernetFace>
+EthernetChannelFactory::findMulticast(const ethernet::Endpoint& interface,
+                                      const ethernet::Address& address) const
+{
+  MulticastFacesMap::const_iterator i = m_multicastFaces.find(std::make_pair(interface, address));
+  if (i != m_multicastFaces.end())
+    return i->second;
+  else
+    return shared_ptr<EthernetFace>();
+}
+
+} // namespace nfd
diff --git a/daemon/face/ethernet-channel-factory.hpp b/daemon/face/ethernet-channel-factory.hpp
new file mode 100644
index 0000000..4f655bd
--- /dev/null
+++ b/daemon/face/ethernet-channel-factory.hpp
@@ -0,0 +1,77 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (C) 2014 Named Data Networking Project
+ * See COPYING for copyright and distribution information.
+ */
+
+#ifndef NFD_FACE_ETHERNET_CHANNEL_FACTORY_HPP
+#define NFD_FACE_ETHERNET_CHANNEL_FACTORY_HPP
+
+#include "ethernet-face.hpp"
+
+namespace nfd {
+
+class EthernetChannelFactory
+{
+public:
+  /**
+   * \brief Exception of EthernetChannelFactory
+   */
+  struct Error : public std::runtime_error
+  {
+    Error(const std::string& what) : std::runtime_error(what) {}
+  };
+
+  /**
+   * \brief Create an EthernetFace to communicate with the given multicast group
+   *
+   * If this method is called twice with the same endpoint and group, only
+   * one face will be created. Instead, the second call will just retrieve
+   * the existing face.
+   *
+   * \param interface Local network interface
+   * \param address   Ethernet broadcast/multicast destination address
+   *
+   * \returns always a valid shared pointer to an EthernetFace object,
+   *          an exception will be thrown if the creation fails
+   *
+   * \throws EthernetChannelFactory::Error or EthernetFace::Error
+   */
+  shared_ptr<EthernetFace>
+  createMulticast(const ethernet::Endpoint& interface,
+                  const ethernet::Address& address);
+
+  /**
+   * \brief Get a list of devices that can be opened for a live capture
+   *
+   * This function is a wrapper for pcap_findalldevs()/pcap_freealldevs()
+   */
+  static std::vector<ethernet::Endpoint>
+  findAllInterfaces();
+
+private:
+  void
+  afterFaceFailed(const ethernet::Endpoint& endpoint,
+                  const ethernet::Address& address);
+
+  /**
+   * \brief Look up EthernetFace using specified interface and address
+   *
+   * \returns shared pointer to the existing EthernetFace object or
+   *          empty shared pointer when such face does not exist
+   *
+   * \throws never
+   */
+  shared_ptr<EthernetFace>
+  findMulticast(const ethernet::Endpoint& interface,
+                const ethernet::Address& address) const;
+
+private:
+  typedef std::map< std::pair<ethernet::Endpoint, ethernet::Address>,
+                    shared_ptr<EthernetFace> > MulticastFacesMap;
+  MulticastFacesMap m_multicastFaces;
+};
+
+} // namespace nfd
+
+#endif // NFD_FACE_ETHERNET_CHANNEL_FACTORY_HPP
diff --git a/daemon/face/ethernet-face.cpp b/daemon/face/ethernet-face.cpp
new file mode 100644
index 0000000..a6e089f
--- /dev/null
+++ b/daemon/face/ethernet-face.cpp
@@ -0,0 +1,332 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (C) 2014 Named Data Networking Project
+ * See COPYING for copyright and distribution information.
+ */
+
+#include "ethernet-face.hpp"
+
+#include <pcap/pcap.h>
+
+#include <arpa/inet.h>    // for htons() and ntohs()
+#include <net/ethernet.h> // for struct ether_header
+#include <net/if.h>       // for struct ifreq
+#include <stdio.h>        // for snprintf()
+#include <sys/ioctl.h>    // for ioctl()
+#include <unistd.h>       // for dup()
+
+#ifndef SIOCGIFHWADDR
+#include <net/if_dl.h>    // for struct sockaddr_dl
+// must be included *after* <net/if.h>
+#include <ifaddrs.h>      // for getifaddrs()
+#endif
+
+namespace nfd {
+
+NFD_LOG_INIT("EthernetFace")
+
+static const uint8_t MAX_PADDING[ethernet::MIN_DATA_LEN] = {
+  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+};
+
+
+EthernetFace::EthernetFace(const shared_ptr<boost::asio::posix::stream_descriptor>& socket,
+                           const ethernet::Endpoint& interface,
+                           const ethernet::Address& address)
+  : m_socket(socket)
+  , m_interface(interface)
+  , m_destAddress(address)
+{
+  setLocal(false);
+  pcapInit();
+
+  int fd = pcap_get_selectable_fd(m_pcap);
+  if (fd < 0)
+    throw Error("pcap_get_selectable_fd() failed");
+
+  // need to duplicate the fd, otherwise both pcap_close()
+  // and stream_descriptor::close() will try to close the
+  // same fd and one of them will fail
+  m_socket->assign(::dup(fd));
+
+  m_sourceAddress = getInterfaceAddress();
+  NFD_LOG_DEBUG("[id:" << getId() << ",endpoint:" << m_interface
+                << "] Local MAC address is: " << m_sourceAddress);
+  m_interfaceMtu = getInterfaceMtu();
+  NFD_LOG_DEBUG("[id:" << getId() << ",endpoint:" << m_interface
+                << "] Interface MTU is: " << m_interfaceMtu);
+
+  char filter[100];
+  ::snprintf(filter, sizeof(filter),
+             "(ether proto 0x%x) && (ether dst %s) && (not ether src %s)",
+             ETHERTYPE_NDN,
+             m_destAddress.toString(':').c_str(),
+             m_sourceAddress.toString(':').c_str());
+  setPacketFilter(filter);
+
+  m_socket->async_read_some(boost::asio::null_buffers(),
+                            bind(&EthernetFace::handleRead, this,
+                                 boost::asio::placeholders::error,
+                                 boost::asio::placeholders::bytes_transferred));
+}
+
+EthernetFace::~EthernetFace()
+{
+  close();
+}
+
+void
+EthernetFace::sendInterest(const Interest& interest)
+{
+  sendPacket(interest.wireEncode());
+}
+
+void
+EthernetFace::sendData(const Data& data)
+{
+  sendPacket(data.wireEncode());
+}
+
+void
+EthernetFace::close()
+{
+  if (m_pcap)
+    {
+      boost::system::error_code error;
+      m_socket->close(error); // ignore errors
+      pcap_close(m_pcap);
+      m_pcap = 0;
+    }
+}
+
+void
+EthernetFace::pcapInit()
+{
+  NFD_LOG_TRACE("[id:" << getId() << ",endpoint:" << m_interface
+                << "] Initializing pcap");
+
+  char errbuf[PCAP_ERRBUF_SIZE];
+  errbuf[0] = '\0';
+  m_pcap = pcap_create(m_interface.c_str(), errbuf);
+  if (!m_pcap)
+    throw Error("pcap_create(): " + std::string(errbuf));
+
+  if (pcap_activate(m_pcap) < 0)
+    throw Error("pcap_activate() failed");
+
+  errbuf[0] = '\0';
+  if (pcap_setnonblock(m_pcap, 1, errbuf) < 0)
+    throw Error("pcap_setnonblock(): " + std::string(errbuf));
+
+  if (pcap_setdirection(m_pcap, PCAP_D_IN) < 0)
+    throw Error("pcap_setdirection(): " + std::string(pcap_geterr(m_pcap)));
+
+  if (pcap_set_datalink(m_pcap, DLT_EN10MB) < 0)
+    throw Error("pcap_set_datalink(): " + std::string(pcap_geterr(m_pcap)));
+}
+
+void
+EthernetFace::setPacketFilter(const char* filterString)
+{
+  bpf_program filter;
+  if (pcap_compile(m_pcap, &filter, filterString, 1, PCAP_NETMASK_UNKNOWN) < 0)
+    throw Error("pcap_compile(): " + std::string(pcap_geterr(m_pcap)));
+
+  int ret = pcap_setfilter(m_pcap, &filter);
+  pcap_freecode(&filter);
+  if (ret < 0)
+    throw Error("pcap_setfilter(): " + std::string(pcap_geterr(m_pcap)));
+}
+
+void
+EthernetFace::sendPacket(const ndn::Block& block)
+{
+  if (!m_pcap)
+    {
+      NFD_LOG_WARN("[id:" << getId() << ",endpoint:" << m_interface
+                   << "] Trying to send on closed face");
+      onFail("Face closed");
+      return;
+    }
+
+  /// @todo Fragmentation
+  if (block.size() > m_interfaceMtu)
+    throw Error("Fragmentation not implemented");
+
+  /// \todo Right now there is no reserve when packet is received, but
+  ///       we should reserve some space at the beginning and at the end
+  ndn::EncodingBuffer buffer(block);
+
+  if (block.size() < ethernet::MIN_DATA_LEN)
+    {
+      buffer.appendByteArray(MAX_PADDING, ethernet::MIN_DATA_LEN - block.size());
+    }
+
+  // construct and prepend the ethernet header
+  static uint16_t ethertype = htons(ETHERTYPE_NDN);
+  buffer.prependByteArray(reinterpret_cast<const uint8_t*>(&ethertype), ethernet::TYPE_LEN);
+  buffer.prependByteArray(m_sourceAddress.data(), m_sourceAddress.size());
+  buffer.prependByteArray(m_destAddress.data(), m_destAddress.size());
+
+  // send the packet
+  int sent = pcap_inject(m_pcap, buffer.buf(), buffer.size());
+  if (sent < 0)
+    {
+      throw Error("pcap_inject(): " + std::string(pcap_geterr(m_pcap)));
+    }
+  else if (static_cast<size_t>(sent) < buffer.size())
+    {
+      throw Error("Failed to send packet");
+    }
+
+  NFD_LOG_TRACE("[id:" << getId() << ",endpoint:" << m_interface
+                << "] Successfully sent: " << buffer.size() << " bytes");
+}
+
+void
+EthernetFace::handleRead(const boost::system::error_code& error, size_t)
+{
+  if (error)
+    return processErrorCode(error);
+
+  pcap_pkthdr* pktHeader;
+  const uint8_t* packet;
+  int ret = pcap_next_ex(m_pcap, &pktHeader, &packet);
+  if (ret < 0)
+    {
+      throw Error("pcap_next_ex(): " + std::string(pcap_geterr(m_pcap)));
+    }
+  else if (ret == 0)
+    {
+      NFD_LOG_WARN("[id:" << getId() << ",endpoint:" << m_interface
+                   << "] pcap_next_ex() timed out");
+    }
+  else
+    {
+      size_t length = pktHeader->caplen;
+      if (length < ethernet::HDR_LEN + ethernet::MIN_DATA_LEN)
+        throw Error("Received packet is too short");
+
+      const ether_header* eh = reinterpret_cast<const ether_header*>(packet);
+      if (ntohs(eh->ether_type) != ETHERTYPE_NDN)
+        throw Error("Unrecognized ethertype");
+
+      packet += ethernet::HDR_LEN;
+      length -= ethernet::HDR_LEN;
+      NFD_LOG_TRACE("[id:" << getId() << ",endpoint:" << m_interface
+                    << "] Received: " << length << " bytes");
+
+      /// \todo Eliminate reliance on exceptions in this path
+      try {
+        /// \todo Reserve space in front and at the back
+        ///       of the underlying buffer
+        ndn::Block element(packet, length);
+        if (!decodeAndDispatchInput(element))
+          {
+            NFD_LOG_WARN("[id:" << getId() << ",endpoint:" << m_interface
+                         << "] Received unrecognized block of type ["
+                         << element.type() << "]");
+            // ignore unknown packet
+          }
+      } catch (const tlv::Error&) {
+        NFD_LOG_WARN("[id:" << getId() << ",endpoint:" << m_interface
+                     << "] Received input is invalid or too large to process");
+      }
+    }
+
+  m_socket->async_read_some(boost::asio::null_buffers(),
+                            bind(&EthernetFace::handleRead, this,
+                                 boost::asio::placeholders::error,
+                                 boost::asio::placeholders::bytes_transferred));
+}
+
+void
+EthernetFace::processErrorCode(const boost::system::error_code& error)
+{
+  if (error == boost::system::errc::operation_canceled)
+    // when socket is closed by someone
+    return;
+
+  if (!m_pcap)
+    {
+      onFail("Face closed");
+      return;
+    }
+
+  std::string msg;
+  if (error == boost::asio::error::eof)
+    {
+      msg = "Face closed";
+      NFD_LOG_INFO("[id:" << getId() << ",endpoint:" << m_interface << "] " << msg);
+    }
+  else
+    {
+      msg = "Send or receive operation failed, closing face: "
+          + error.category().message(error.value());
+      NFD_LOG_WARN("[id:" << getId() << ",endpoint:" << m_interface << "] " << msg);
+    }
+
+  close();
+  onFail(msg);
+}
+
+ethernet::Address
+EthernetFace::getInterfaceAddress() const
+{
+#ifdef SIOCGIFHWADDR
+  ifreq ifr = {};
+  ::strncpy(ifr.ifr_name, m_interface.c_str(), sizeof(ifr.ifr_name));
+
+  if (::ioctl(m_socket->native_handle(), SIOCGIFHWADDR, &ifr) < 0)
+    throw Error("ioctl(SIOCGIFHWADDR) failed");
+
+  uint8_t* hwaddr = reinterpret_cast<uint8_t*>(ifr.ifr_hwaddr.sa_data);
+  return ethernet::Address(hwaddr);
+#else
+  ifaddrs* addrlist;
+  if (::getifaddrs(&addrlist) < 0)
+    throw Error("getifaddrs() failed");
+
+  ethernet::Address address;
+  for (ifaddrs* ifa = addrlist; ifa != 0; ifa = ifa->ifa_next)
+    {
+      if (std::string(ifa->ifa_name) == m_interface
+          && ifa->ifa_addr != 0
+          && ifa->ifa_addr->sa_family == AF_LINK)
+        {
+          sockaddr_dl* sa = reinterpret_cast<sockaddr_dl*>(ifa->ifa_addr);
+          address = ethernet::Address(reinterpret_cast<uint8_t*>(LLADDR(sa)));
+          break;
+        }
+    }
+
+  ::freeifaddrs(addrlist);
+  return address;
+#endif
+}
+
+size_t
+EthernetFace::getInterfaceMtu() const
+{
+  size_t mtu = ethernet::MAX_DATA_LEN;
+
+#ifdef SIOCGIFMTU
+  ifreq ifr = {};
+  ::strncpy(ifr.ifr_name, m_interface.c_str(), sizeof(ifr.ifr_name));
+
+  if (::ioctl(m_socket->native_handle(), SIOCGIFMTU, &ifr) < 0)
+    {
+      NFD_LOG_WARN("[id:" << getId() << ",endpoint:" << m_interface
+                   << "] Failed to get interface MTU, assuming " << mtu);
+    }
+  else
+    {
+      mtu = std::min(mtu, static_cast<size_t>(ifr.ifr_mtu));
+    }
+#endif
+
+  return mtu;
+}
+
+} // namespace nfd
diff --git a/daemon/face/ethernet-face.hpp b/daemon/face/ethernet-face.hpp
new file mode 100644
index 0000000..a6394ce
--- /dev/null
+++ b/daemon/face/ethernet-face.hpp
@@ -0,0 +1,96 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (C) 2014 Named Data Networking Project
+ * See COPYING for copyright and distribution information.
+ */
+
+#ifndef NFD_FACE_ETHERNET_FACE_HPP
+#define NFD_FACE_ETHERNET_FACE_HPP
+
+#include "ethernet.hpp"
+#include "face.hpp"
+
+#ifndef HAVE_PCAP
+#error "Cannot include this file when pcap is not available"
+#endif
+
+// forward declarations
+struct pcap;
+typedef pcap pcap_t;
+
+namespace nfd {
+
+/**
+ * \brief Implementation of Face abstraction that uses raw
+ *        Ethernet frames as underlying transport mechanism
+ */
+class EthernetFace : public Face
+{
+public:
+  /**
+   * \brief EthernetFace-related error
+   */
+  struct Error : public Face::Error
+  {
+    Error(const std::string& what) : Face::Error(what) {}
+  };
+
+  EthernetFace(const shared_ptr<boost::asio::posix::stream_descriptor>& socket,
+               const ethernet::Endpoint& interface,
+               const ethernet::Address& address);
+
+  virtual
+  ~EthernetFace();
+
+  /// send an Interest
+  virtual void
+  sendInterest(const Interest& interest);
+
+  /// send a Data
+  virtual void
+  sendData(const Data& data);
+
+  /**
+   * \brief Close the face
+   *
+   * This terminates all communication on the face and cause
+   * onFail() method event to be invoked
+   */
+  virtual void
+  close();
+
+private:
+  void
+  pcapInit();
+
+  void
+  setPacketFilter(const char* filterString);
+
+  void
+  sendPacket(const ndn::Block& block);
+
+  void
+  handleRead(const boost::system::error_code& error,
+             size_t nBytesRead);
+
+  void
+  processErrorCode(const boost::system::error_code& error);
+
+  ethernet::Address
+  getInterfaceAddress() const;
+
+  size_t
+  getInterfaceMtu() const;
+
+private:
+  shared_ptr<boost::asio::posix::stream_descriptor> m_socket;
+  ethernet::Endpoint m_interface;
+  ethernet::Address m_sourceAddress;
+  ethernet::Address m_destAddress;
+  size_t m_interfaceMtu;
+  pcap_t* m_pcap;
+};
+
+} // namespace nfd
+
+#endif // NFD_FACE_ETHERNET_FACE_HPP
diff --git a/daemon/face/ethernet.hpp b/daemon/face/ethernet.hpp
new file mode 100644
index 0000000..66ee715
--- /dev/null
+++ b/daemon/face/ethernet.hpp
@@ -0,0 +1,136 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (C) 2014 Named Data Networking Project
+ * See COPYING for copyright and distribution information.
+ */
+
+#ifndef NFD_FACE_ETHERNET_HPP
+#define NFD_FACE_ETHERNET_HPP
+
+#include "common.hpp"
+
+#include <boost/array.hpp>
+
+#define ETHERTYPE_NDN 0x8624
+
+namespace nfd {
+namespace ethernet {
+
+typedef std::string Endpoint;
+
+const size_t ADDR_LEN     = 6;      ///< Octets in one Ethernet address
+const size_t TYPE_LEN     = 2;      ///< Octets in Ethertype field
+const size_t HDR_LEN      = 14;     ///< Total octets in Ethernet header (without 802.1Q tag)
+const size_t TAG_LEN      = 4;      ///< Octets in 802.1Q tag (TPID + priority + VLAN)
+const size_t MIN_DATA_LEN = 46;     ///< Min octets in Ethernet payload (assuming no 802.1Q tag)
+const size_t MAX_DATA_LEN = 1500;   ///< Max octets in Ethernet payload
+const size_t CRC_LEN      = 4;      ///< Octets in Ethernet frame check sequence
+
+
+class Address : public boost::array<uint8_t, ADDR_LEN>
+{
+public:
+  /// Constructs a null Ethernet address (00-00-00-00-00-00)
+  Address();
+
+  /// Constructs a new Ethernet address with the given octets
+  Address(uint8_t a1, uint8_t a2, uint8_t a3,
+          uint8_t a4, uint8_t a5, uint8_t a6);
+
+  /// Constructs a new Ethernet address with the given octets
+  explicit
+  Address(const uint8_t octets[ADDR_LEN]);
+
+  /// Copy constructor
+  Address(const Address& address);
+
+  /// True if this is a broadcast address (FF-FF-FF-FF-FF-FF)
+  bool
+  isBroadcast() const;
+
+  /// True if this is a multicast address
+  bool
+  isMulticast() const;
+
+  std::string
+  toString(char sep = '-') const;
+};
+
+/// Returns the Ethernet broadcast address (FF-FF-FF-FF-FF-FF)
+inline Address
+getBroadcastAddress()
+{
+  static Address bcast(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF);
+  return bcast;
+}
+
+/// Returns the default Ethernet multicast address for NDN
+inline Address
+getDefaultMulticastAddress()
+{
+  static Address mcast(0x01, 0x00, 0x5E, 0x00, 0x17, 0xAA);
+  return mcast;
+}
+
+inline
+Address::Address()
+{
+  assign(0);
+}
+
+inline
+Address::Address(uint8_t a1, uint8_t a2, uint8_t a3, uint8_t a4, uint8_t a5, uint8_t a6)
+{
+  elems[0] = a1;
+  elems[1] = a2;
+  elems[2] = a3;
+  elems[3] = a4;
+  elems[4] = a5;
+  elems[5] = a6;
+}
+
+inline
+Address::Address(const uint8_t octets[])
+{
+  std::copy(octets, octets + size(), begin());
+}
+
+inline
+Address::Address(const Address& address)
+{
+  std::copy(address.begin(), address.end(), begin());
+}
+
+inline bool
+Address::isBroadcast() const
+{
+  return elems[0] == 0xFF && elems[1] == 0xFF && elems[2] == 0xFF &&
+         elems[3] == 0xFF && elems[4] == 0xFF && elems[5] == 0xFF;
+}
+
+inline bool
+Address::isMulticast() const
+{
+  return (elems[0] & 1) != 0;
+}
+
+inline std::string
+Address::toString(char sep) const
+{
+  char s[18]; // 12 digits + 5 separators + null terminator
+  ::snprintf(s, sizeof(s), "%02x%c%02x%c%02x%c%02x%c%02x%c%02x",
+             elems[0], sep, elems[1], sep, elems[2], sep,
+             elems[3], sep, elems[4], sep, elems[5]);
+  return std::string(s);
+}
+
+static std::ostream&
+operator<<(std::ostream& o, const Address& a)
+{
+  return o << a.toString();
+}
+
+} // namespace ethernet
+} // namespace nfd
+
+#endif // NFD_FACE_ETHERNET_HPP
diff --git a/tests/face/ethernet.cpp b/tests/face/ethernet.cpp
new file mode 100644
index 0000000..6803a1a
--- /dev/null
+++ b/tests/face/ethernet.cpp
@@ -0,0 +1,107 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (C) 2014 Named Data Networking Project
+ * See COPYING for copyright and distribution information.
+ */
+
+#include "face/ethernet-channel-factory.hpp"
+
+#include <ndn-cpp-dev/security/key-chain.hpp>
+
+#include <boost/test/unit_test.hpp>
+
+namespace nfd {
+
+BOOST_AUTO_TEST_SUITE(FaceEthernet)
+
+BOOST_AUTO_TEST_CASE(MulticastFacesMap)
+{
+  EthernetChannelFactory factory;
+
+  std::vector<ethernet::Endpoint> interfaces = EthernetChannelFactory::findAllInterfaces();
+  if (interfaces.size() > 0)
+    {
+      shared_ptr<EthernetFace> face1 = factory.createMulticast(interfaces[0],
+                                                               ethernet::getBroadcastAddress());
+      shared_ptr<EthernetFace> face1bis = factory.createMulticast(interfaces[0],
+                                                                  ethernet::getBroadcastAddress());
+      BOOST_CHECK_EQUAL(face1, face1bis);
+
+      if (interfaces.size() > 1)
+        {
+          shared_ptr<EthernetFace> face2 = factory.createMulticast(interfaces[1],
+                                                                   ethernet::getBroadcastAddress());
+          BOOST_CHECK_NE(face1, face2);
+        }
+      else
+        {
+          BOOST_WARN_MESSAGE(interfaces.size() < 2, "Cannot test second EthernetFace creation, "
+                             "only one interface available for pcap");
+        }
+
+      shared_ptr<EthernetFace> face3 = factory.createMulticast(interfaces[0],
+                                                               ethernet::getDefaultMulticastAddress());
+      BOOST_CHECK_NE(face1, face3);
+    }
+  else
+    {
+      BOOST_WARN_MESSAGE(interfaces.empty(), "Cannot perform MulticastFacesMap tests, "
+                         "no interfaces are available for pcap");
+    }
+}
+
+BOOST_AUTO_TEST_CASE(SendPacket)
+{
+  EthernetChannelFactory factory;
+
+  std::vector<ethernet::Endpoint> interfaces = EthernetChannelFactory::findAllInterfaces();
+  if (interfaces.empty())
+    {
+      BOOST_WARN_MESSAGE(interfaces.empty(),
+                         "No interfaces are available for pcap, cannot perform SendPacket test");
+      return;
+    }
+
+  shared_ptr<EthernetFace> face =
+    factory.createMulticast(interfaces[0], ethernet::getDefaultMulticastAddress());
+
+  BOOST_REQUIRE(static_cast<bool>(face));
+  BOOST_CHECK_EQUAL(face->isLocal(), false);
+
+  Interest interest1("ndn:/TpnzGvW9R");
+  Data     data1    ("ndn:/KfczhUqVix");
+  data1.setContent(0, 0);
+  Interest interest2("ndn:/QWiIMfj5sL");
+  Data     data2    ("ndn:/XNBV796f");
+  data2.setContent(0, 0);
+
+  ndn::SignatureSha256WithRsa fakeSignature;
+  fakeSignature.setValue(ndn::dataBlock(tlv::SignatureValue, reinterpret_cast<const uint8_t*>(0), 0));
+
+  // set fake signature on data1 and data2
+  data1.setSignature(fakeSignature);
+  data2.setSignature(fakeSignature);
+
+  BOOST_CHECK_NO_THROW(face->sendInterest(interest1));
+  BOOST_CHECK_NO_THROW(face->sendData    (data1    ));
+  BOOST_CHECK_NO_THROW(face->sendInterest(interest2));
+  BOOST_CHECK_NO_THROW(face->sendData    (data2    ));
+
+//  m_ioRemaining = 4;
+//  m_ioService.run();
+//  m_ioService.reset();
+
+//  BOOST_REQUIRE_EQUAL(m_face1_receivedInterests.size(), 1);
+//  BOOST_REQUIRE_EQUAL(m_face1_receivedDatas    .size(), 1);
+//  BOOST_REQUIRE_EQUAL(m_face2_receivedInterests.size(), 1);
+//  BOOST_REQUIRE_EQUAL(m_face2_receivedDatas    .size(), 1);
+
+//  BOOST_CHECK_EQUAL(m_face1_receivedInterests[0].getName(), interest2.getName());
+//  BOOST_CHECK_EQUAL(m_face1_receivedDatas    [0].getName(), data2.getName());
+//  BOOST_CHECK_EQUAL(m_face2_receivedInterests[0].getName(), interest1.getName());
+//  BOOST_CHECK_EQUAL(m_face2_receivedDatas    [0].getName(), data1.getName());
+}
+
+BOOST_AUTO_TEST_SUITE_END()
+
+} // namespace nfd
diff --git a/wscript b/wscript
index b7f96c9..7d654ab 100644
--- a/wscript
+++ b/wscript
@@ -44,7 +44,7 @@
                        cxxflags="-I%s/include" % conf.options.ndn_cpp_dir,
                        linkflags="-L%s/lib" % conf.options.ndn_cpp_dir,
                        mandatory=True)
-        
+
     boost_libs='system'
     if conf.options.with_tests:
         conf.env['WITH_TESTS'] = 1
@@ -60,8 +60,10 @@
         return
 
     conf.load('unix-socket')
-    
+
     conf.check_cxx(lib='rt', uselib_store='RT', define_name='HAVE_RT', mandatory=False)
+    if conf.check_cxx(lib='pcap', uselib_store='PCAP', define_name='HAVE_PCAP', mandatory=False):
+        conf.env['HAVE_PCAP'] = True
 
     conf.load('coverage')
 
@@ -72,14 +74,19 @@
         target = "nfd-objects",
         features = "cxx",
         source = bld.path.ant_glob(['daemon/**/*.cpp'],
-                                   excl=['daemon/**/unix-*.cpp', 'daemon/main.cpp']),
+                                   excl=['daemon/face/ethernet-*.cpp',
+                                         'daemon/face/unix-*.cpp',
+                                         'daemon/main.cpp']),
         use = 'BOOST NDN_CPP RT',
         includes = [".", "daemon"],
         )
 
+    if bld.env['HAVE_PCAP']:
+        nfd_objects.source += bld.path.ant_glob('daemon/face/ethernet-*.cpp')
+        nfd_objects.use += ' PCAP'
+
     if bld.env['HAVE_UNIX_SOCKETS']:
-        nfd_objects.source += bld.path.ant_glob(['daemon/**/unix-*.cpp'],
-                                                excl=['daemon/main.cpp'])
+        nfd_objects.source += bld.path.ant_glob('daemon/face/unix-*.cpp')
 
     bld(target = "nfd",
         features = "cxx cxxprogram",
@@ -94,21 +101,25 @@
             source = ['tools/%s' % (str(app))],
             use = 'BOOST NDN_CPP RT',
             )
-                
+
     # Unit tests
     if bld.env['WITH_TESTS']:
-        unit_tests = unittests = bld.program (
+        unit_tests = unittests = bld.program(
             target="unit-tests",
             features = "cxx cxxprogram",
             source = bld.path.ant_glob(['tests/**/*.cpp'],
-                                       excl=['tests/**/unix-*.cpp']),
+                                       excl=['tests/face/ethernet.cpp',
+                                             'tests/face/unix-*.cpp']),
             use = 'nfd-objects',
             includes = [".", "daemon"],
             install_prefix = None,
           )
 
+        if bld.env['HAVE_PCAP']:
+            unit_tests.source += bld.path.ant_glob('tests/face/ethernet.cpp')
+
         if bld.env['HAVE_UNIX_SOCKETS']:
-            unit_tests.source += bld.path.ant_glob(['tests/**/unix-*.cpp'])
+            unit_tests.source += bld.path.ant_glob('tests/face/unix-*.cpp')
 
 @Configure.conf
 def add_supported_cxxflags(self, cxxflags):
@@ -136,4 +147,3 @@
         bld.fatal("ERROR: cannot build documentation (`doxygen' is not found in $PATH)")
     bld(features="doxygen",
         doxyfile='docs/doxygen.conf')
-
