diff --git a/daemon/face/ethernet-face.cpp b/daemon/face/ethernet-face.cpp
index 2b6e2bc..2ea6ca9 100644
--- a/daemon/face/ethernet-face.cpp
+++ b/daemon/face/ethernet-face.cpp
@@ -5,9 +5,11 @@
  */
 
 #include "ethernet-face.hpp"
+#include "core/network-interface.hpp"
 
 #include <pcap/pcap.h>
 
+#include <cstring>        // for std::strncpy()
 #include <arpa/inet.h>    // for htons() and ntohs()
 #include <net/ethernet.h> // for struct ether_header
 #include <net/if.h>       // for struct ifreq
@@ -15,30 +17,21 @@
 #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 shared_ptr<NetworkInterfaceInfo>& interface,
                            const ethernet::Address& address)
-  : Face(FaceUri("ether://" + interface + "/" + address.toString(':')))
+  : Face(FaceUri("ether://" + interface->name + "/" + address.toString(':')))
   , m_socket(socket)
-  , m_interface(interface)
+  , m_interfaceName(interface->name)
+  , m_srcAddress(interface->etherAddress)
   , m_destAddress(address)
 {
+  NFD_LOG_INFO("Creating ethernet face on " << m_interfaceName << ": "
+               << m_srcAddress << " <--> " << m_destAddress);
   pcapInit();
 
   int fd = pcap_get_selectable_fd(m_pcap);
@@ -50,11 +43,8 @@
   // 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
+  NFD_LOG_DEBUG("[id:" << getId() << ",endpoint:" << m_interfaceName
                 << "] Interface MTU is: " << m_interfaceMtu);
 
   char filter[100];
@@ -62,7 +52,7 @@
              "(ether proto 0x%x) && (ether dst %s) && (not ether src %s)",
              ETHERTYPE_NDN,
              m_destAddress.toString(':').c_str(),
-             m_sourceAddress.toString(':').c_str());
+             m_srcAddress.toString(':').c_str());
   setPacketFilter(filter);
 
   m_socket->async_read_some(boost::asio::null_buffers(),
@@ -105,12 +95,9 @@
 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);
+  m_pcap = pcap_create(m_interfaceName.c_str(), errbuf);
   if (!m_pcap)
     throw Error("pcap_create(): " + std::string(errbuf));
 
@@ -147,7 +134,7 @@
 {
   if (!m_pcap)
     {
-      NFD_LOG_WARN("[id:" << getId() << ",endpoint:" << m_interface
+      NFD_LOG_WARN("[id:" << getId() << ",endpoint:" << m_interfaceName
                    << "] Trying to send on closed face");
       onFail("Face closed");
       return;
@@ -156,7 +143,8 @@
   /// \todo Fragmentation
   if (block.size() > m_interfaceMtu)
     {
-      NFD_LOG_ERROR("Fragmentation not implemented: dropping packet larger than MTU");
+      NFD_LOG_ERROR("[id:" << getId() << ",endpoint:" << m_interfaceName
+                    << "] Fragmentation not implemented: dropping packet larger than MTU");
       return;
     }
 
@@ -166,13 +154,14 @@
 
   if (block.size() < ethernet::MIN_DATA_LEN)
     {
-      buffer.appendByteArray(MAX_PADDING, ethernet::MIN_DATA_LEN - block.size());
+      static const uint8_t padding[ethernet::MIN_DATA_LEN] = {0};
+      buffer.appendByteArray(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_srcAddress.data(), m_srcAddress.size());
   buffer.prependByteArray(m_destAddress.data(), m_destAddress.size());
 
   // send the packet
@@ -186,7 +175,7 @@
       throw Error("Failed to send packet");
     }
 
-  NFD_LOG_TRACE("[id:" << getId() << ",endpoint:" << m_interface
+  NFD_LOG_TRACE("[id:" << getId() << ",endpoint:" << m_interfaceName
                 << "] Successfully sent: " << buffer.size() << " bytes");
 }
 
@@ -205,7 +194,7 @@
     }
   else if (ret == 0)
     {
-      NFD_LOG_WARN("[id:" << getId() << ",endpoint:" << m_interface
+      NFD_LOG_WARN("[id:" << getId() << ",endpoint:" << m_interfaceName
                    << "] pcap_next_ex() timed out");
     }
   else
@@ -220,7 +209,7 @@
 
       packet += ethernet::HDR_LEN;
       length -= ethernet::HDR_LEN;
-      NFD_LOG_TRACE("[id:" << getId() << ",endpoint:" << m_interface
+      NFD_LOG_TRACE("[id:" << getId() << ",endpoint:" << m_interfaceName
                     << "] Received: " << length << " bytes");
 
       /// \todo Eliminate reliance on exceptions in this path
@@ -230,14 +219,14 @@
         ndn::Block element(packet, length);
         if (!decodeAndDispatchInput(element))
           {
-            NFD_LOG_WARN("[id:" << getId() << ",endpoint:" << m_interface
-                         << "] Received unrecognized block of type ["
-                         << element.type() << "]");
+            NFD_LOG_WARN("[id:" << getId() << ",endpoint:" << m_interfaceName
+                         << "] 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");
+      }
+      catch (const tlv::Error&) {
+        NFD_LOG_WARN("[id:" << getId() << ",endpoint:" << m_interfaceName
+                     << "] Received block is invalid or too large to process");
       }
     }
 
@@ -264,66 +253,30 @@
   if (error == boost::asio::error::eof)
     {
       msg = "Face closed";
-      NFD_LOG_INFO("[id:" << getId() << ",endpoint:" << m_interface << "] " << msg);
+      NFD_LOG_INFO("[id:" << getId() << ",endpoint:" << m_interfaceName << "] " << msg);
     }
   else
     {
-      msg = "Send or receive operation failed, closing face: "
-          + error.category().message(error.value());
-      NFD_LOG_WARN("[id:" << getId() << ",endpoint:" << m_interface << "] " << msg);
+      msg = "Receive operation failed, closing face: " + error.category().message(error.value());
+      NFD_LOG_WARN("[id:" << getId() << ",endpoint:" << m_interfaceName << "] " << 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));
+  ifreq ifr = {0};
+  std::strncpy(ifr.ifr_name, m_interfaceName.c_str(), sizeof(ifr.ifr_name) - 1);
 
   if (::ioctl(m_socket->native_handle(), SIOCGIFMTU, &ifr) < 0)
     {
-      NFD_LOG_WARN("[id:" << getId() << ",endpoint:" << m_interface
+      NFD_LOG_WARN("[id:" << getId() << ",endpoint:" << m_interfaceName
                    << "] Failed to get interface MTU, assuming " << mtu);
     }
   else
diff --git a/daemon/face/ethernet-face.hpp b/daemon/face/ethernet-face.hpp
index a6394ce..a42f889 100644
--- a/daemon/face/ethernet-face.hpp
+++ b/daemon/face/ethernet-face.hpp
@@ -20,6 +20,8 @@
 
 namespace nfd {
 
+class NetworkInterfaceInfo;
+
 /**
  * \brief Implementation of Face abstraction that uses raw
  *        Ethernet frames as underlying transport mechanism
@@ -36,7 +38,7 @@
   };
 
   EthernetFace(const shared_ptr<boost::asio::posix::stream_descriptor>& socket,
-               const ethernet::Endpoint& interface,
+               const shared_ptr<NetworkInterfaceInfo>& interface,
                const ethernet::Address& address);
 
   virtual
@@ -76,16 +78,13 @@
   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;
+  std::string m_interfaceName;
+  ethernet::Address m_srcAddress;
   ethernet::Address m_destAddress;
   size_t m_interfaceMtu;
   pcap_t* m_pcap;
diff --git a/daemon/face/ethernet-factory.cpp b/daemon/face/ethernet-factory.cpp
index 78adf6f..2801c4f 100644
--- a/daemon/face/ethernet-factory.cpp
+++ b/daemon/face/ethernet-factory.cpp
@@ -6,6 +6,7 @@
 
 #include "ethernet-factory.hpp"
 #include "core/global-io.hpp"
+#include "core/network-interface.hpp"
 
 #include <boost/algorithm/string/predicate.hpp>
 #include <pcap/pcap.h>
@@ -15,17 +16,14 @@
 NFD_LOG_INIT("EthernetFactory")
 
 shared_ptr<EthernetFace>
-EthernetFactory::createMulticastFace(const ethernet::Endpoint& interface,
-                                     const ethernet::Address& address)
+EthernetFactory::createMulticastFace(const shared_ptr<NetworkInterfaceInfo> &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 = findMulticastFace(interface, address);
+  const std::string& name = interface->name;
+  shared_ptr<EthernetFace> face = findMulticastFace(name, address);
   if (face)
     return face;
 
@@ -36,66 +34,25 @@
                                    boost::cref(interface),
                                    boost::cref(address));
   face->onFail += bind(&EthernetFactory::afterFaceFailed,
-                       this, interface, address);
-  m_multicastFaces[std::make_pair(interface, address)] = face;
+                       this, name, address);
+  m_multicastFaces[std::make_pair(name, address)] = face;
 
   return face;
 }
 
-std::vector<ethernet::Endpoint>
-EthernetFactory::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;
-      if (boost::starts_with(interface, "fw"))
-        // ignore OSX firewire interface
-        continue;
-
-      // maybe add interface addresses too
-      // interface.addAddress ...
-      interfaces.push_back(interface);
-    }
-
-  pcap_freealldevs(alldevs);
-  return interfaces;
-}
-
 void
-EthernetFactory::afterFaceFailed(const ethernet::Endpoint& interface,
+EthernetFactory::afterFaceFailed(const std::string& interfaceName,
                                  const ethernet::Address& address)
 {
-  NFD_LOG_DEBUG("afterFaceFailed: " << interface << "/" << address);
-  m_multicastFaces.erase(std::make_pair(interface, address));
+  NFD_LOG_DEBUG("afterFaceFailed: " << interfaceName << "/" << address);
+  m_multicastFaces.erase(std::make_pair(interfaceName, address));
 }
 
 shared_ptr<EthernetFace>
-EthernetFactory::findMulticastFace(const ethernet::Endpoint& interface,
+EthernetFactory::findMulticastFace(const std::string& interfaceName,
                                    const ethernet::Address& address) const
 {
-  MulticastFacesMap::const_iterator i = m_multicastFaces.find(std::make_pair(interface, address));
+  MulticastFacesMap::const_iterator i = m_multicastFaces.find(std::make_pair(interfaceName, address));
   if (i != m_multicastFaces.end())
     return i->second;
   else
diff --git a/daemon/face/ethernet-factory.hpp b/daemon/face/ethernet-factory.hpp
index 2eeca7b..b8e4511 100644
--- a/daemon/face/ethernet-factory.hpp
+++ b/daemon/face/ethernet-factory.hpp
@@ -12,6 +12,8 @@
 
 namespace nfd {
 
+class NetworkInterfaceInfo;
+
 class EthernetFactory : public ProtocolFactory
 {
 public:
@@ -23,10 +25,16 @@
     Error(const std::string& what) : ProtocolFactory::Error(what) {}
   };
 
+  // from ProtocolFactory
+  virtual void
+  createFace(const FaceUri& uri,
+             const FaceCreatedCallback& onCreated,
+             const FaceConnectFailedCallback& onConnectFailed);
+
   /**
    * \brief Create an EthernetFace to communicate with the given multicast group
    *
-   * If this method is called twice with the same endpoint and group, only
+   * If this method is called twice with the same interface and group, only
    * one face will be created. Instead, the second call will just retrieve
    * the existing face.
    *
@@ -39,27 +47,12 @@
    * \throws EthernetFactory::Error or EthernetFace::Error
    */
   shared_ptr<EthernetFace>
-  createMulticastFace(const ethernet::Endpoint& interface,
+  createMulticastFace(const shared_ptr<NetworkInterfaceInfo>& 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();
-
-  // from Factory
-
-  virtual void
-  createFace(const FaceUri& uri,
-             const FaceCreatedCallback& onCreated,
-             const FaceConnectFailedCallback& onConnectFailed);
-
 private:
   void
-  afterFaceFailed(const ethernet::Endpoint& endpoint,
+  afterFaceFailed(const std::string& interfaceName,
                   const ethernet::Address& address);
 
   /**
@@ -71,11 +64,11 @@
    * \throws never
    */
   shared_ptr<EthernetFace>
-  findMulticastFace(const ethernet::Endpoint& interface,
+  findMulticastFace(const std::string& interfaceName,
                     const ethernet::Address& address) const;
 
 private:
-  typedef std::map< std::pair<ethernet::Endpoint, ethernet::Address>,
+  typedef std::map< std::pair<std::string, ethernet::Address>,
                     shared_ptr<EthernetFace> > MulticastFacesMap;
   MulticastFacesMap m_multicastFaces;
 };
diff --git a/daemon/face/ethernet.hpp b/daemon/face/ethernet.hpp
index 573ea56..c72e742 100644
--- a/daemon/face/ethernet.hpp
+++ b/daemon/face/ethernet.hpp
@@ -16,8 +16,6 @@
 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)
diff --git a/daemon/mgmt/face-manager.cpp b/daemon/mgmt/face-manager.cpp
index 28f8a16..bbd495e 100644
--- a/daemon/mgmt/face-manager.cpp
+++ b/daemon/mgmt/face-manager.cpp
@@ -489,7 +489,7 @@
                   try
                     {
                       shared_ptr<EthernetFace> newFace =
-                        factory->createMulticastFace(nic->name, mcastGroup);
+                        factory->createMulticastFace(nic, mcastGroup);
                       NFD_LOG_INFO("Created multicast Face ID " << newFace->getId());
                     }
                   catch (const EthernetFactory::Error& factoryError)
diff --git a/tests/face/ethernet.cpp b/tests/face/ethernet.cpp
index 4859da2..12eef0f 100644
--- a/tests/face/ethernet.cpp
+++ b/tests/face/ethernet.cpp
@@ -5,80 +5,102 @@
  */
 
 #include "face/ethernet-factory.hpp"
-#include <ndn-cpp-dev/security/key-chain.hpp>
-
+#include "core/network-interface.hpp"
 #include "tests/test-common.hpp"
 
+#include <ndn-cpp-dev/security/key-chain.hpp>
+#include <pcap/pcap.h>
+
 namespace nfd {
 namespace tests {
 
 BOOST_FIXTURE_TEST_SUITE(FaceEthernet, BaseFixture)
 
-BOOST_AUTO_TEST_CASE(MulticastFacesMap)
+class InterfacesFixture : protected BaseFixture
+{
+protected:
+  InterfacesFixture()
+  {
+    std::list< shared_ptr<NetworkInterfaceInfo> > ifs = listNetworkInterfaces();
+    for (std::list< shared_ptr<NetworkInterfaceInfo> >::const_iterator i = ifs.begin();
+         i != ifs.end();
+         ++i)
+      {
+        if (!(*i)->isLoopback() && (*i)->isUp())
+          {
+            pcap_t* p = pcap_create((*i)->name.c_str(), 0);
+            if (!p)
+              continue;
+
+            if (pcap_activate(p) == 0)
+              m_interfaces.push_back(*i);
+
+            pcap_close(p);
+          }
+      }
+  }
+
+protected:
+  std::list< shared_ptr<NetworkInterfaceInfo> > m_interfaces;
+};
+
+
+BOOST_FIXTURE_TEST_CASE(MulticastFacesMap, InterfacesFixture)
 {
   EthernetFactory factory;
 
-  std::vector<ethernet::Endpoint> interfaces = EthernetFactory::findAllInterfaces();
-  if (interfaces.size() > 0)
+  if (m_interfaces.empty())
     {
-      shared_ptr<EthernetFace> face1;
-      BOOST_REQUIRE_NO_THROW(face1 =
-                             factory.createMulticastFace(interfaces[0],
-                                                     ethernet::getBroadcastAddress()));
-      shared_ptr<EthernetFace> face1bis;
-      BOOST_REQUIRE_NO_THROW(face1bis =
-                             factory.createMulticastFace(interfaces[0],
-                                                         ethernet::getBroadcastAddress()));
-      BOOST_CHECK_EQUAL(face1, face1bis);
-
-      if (interfaces.size() > 1)
-        {
-          shared_ptr<EthernetFace> face2;
-          BOOST_REQUIRE_NO_THROW(face2 =
-                                 factory.createMulticastFace(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;
-      BOOST_REQUIRE_NO_THROW(face3 =
-                             factory.createMulticastFace(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)
-{
-  EthernetFactory factory;
-
-  std::vector<ethernet::Endpoint> interfaces = EthernetFactory::findAllInterfaces();
-  if (interfaces.empty())
-    {
-      BOOST_WARN_MESSAGE(interfaces.empty(),
-                         "No interfaces are available for pcap, cannot perform SendPacket test");
+      BOOST_WARN_MESSAGE(false, "No interfaces available, cannot perform MulticastFacesMap test");
       return;
     }
 
-  shared_ptr<EthernetFace> face =
-    factory.createMulticastFace(interfaces[0], ethernet::getDefaultMulticastAddress());
+  shared_ptr<EthernetFace> face1;
+  BOOST_REQUIRE_NO_THROW(face1 = factory.createMulticastFace(m_interfaces.front(),
+                                                             ethernet::getBroadcastAddress()));
+  shared_ptr<EthernetFace> face1bis;
+  BOOST_REQUIRE_NO_THROW(face1bis = factory.createMulticastFace(m_interfaces.front(),
+                                                                ethernet::getBroadcastAddress()));
+  BOOST_CHECK_EQUAL(face1, face1bis);
+
+  if (m_interfaces.size() > 1)
+    {
+      shared_ptr<EthernetFace> face2;
+      BOOST_REQUIRE_NO_THROW(face2 = factory.createMulticastFace(m_interfaces.back(),
+                                                                 ethernet::getBroadcastAddress()));
+      BOOST_CHECK_NE(face1, face2);
+    }
+  else
+    {
+      BOOST_WARN_MESSAGE(false, "Cannot test second EthernetFace creation, "
+                         "only one interface available");
+    }
+
+  shared_ptr<EthernetFace> face3;
+  BOOST_REQUIRE_NO_THROW(face3 = factory.createMulticastFace(m_interfaces.front(),
+                                                             ethernet::getDefaultMulticastAddress()));
+  BOOST_CHECK_NE(face1, face3);
+}
+
+BOOST_FIXTURE_TEST_CASE(SendPacket, InterfacesFixture)
+{
+  EthernetFactory factory;
+
+  if (m_interfaces.empty())
+    {
+      BOOST_WARN_MESSAGE(false, "No interfaces available for pcap, cannot perform SendPacket test");
+      return;
+    }
+
+  shared_ptr<EthernetFace> face = factory.createMulticastFace(m_interfaces.front(),
+                                                              ethernet::getDefaultMulticastAddress());
 
   BOOST_REQUIRE(static_cast<bool>(face));
 
   BOOST_CHECK(!face->isOnDemand());
   BOOST_CHECK_EQUAL(face->isLocal(), false);
   BOOST_CHECK_EQUAL(face->getUri().toString(),
-                    "ether://" + interfaces[0] + "/" +
+                    "ether://" + m_interfaces.front()->name + "/" +
                     ethernet::getDefaultMulticastAddress().toString(':'));
 
   Interest interest1("ndn:/TpnzGvW9R");
