def send_packet(self, dev, packet):
        '''
        Send a Switchyard Packet object on the given device 
        (string name of device).

        Raises ValueError if packet object isn't valid, or device
        name isn't recognized.
        '''
        if packet is None:
            raise ValueError("No packet object given to send_packet")
        if not isinstance(packet, Packet):
            raise ValueError("Object given to send_packet is not a Packet (it is: {})".format(type(packet)))
 
        intf = None
        if isinstance(dev, int):
           dev = self._lookup_devname(dev)

        if isinstance(dev, Interface):
            intf = dev
            dev = dev.name
        elif dev in self._devinfo:
            intf = self.interface_by_name(dev)
        else:
            raise ValueError("Unrecognized device name for packet send: {}".format(dev))

        if intf.iftype == InterfaceType.Loopback:
            pdev = self._localsend.get(dev, None)
            pdev.send_packet(packet)
        else:
            pdev = self._pcaps.get(dev, None)
            rawpkt = packet.to_bytes()
            log_debug("Sending packet on device {}: {}".format(dev, str(packet)))
            pdev.send_packet(rawpkt)
Send a Switchyard Packet object on the given device 
        (string name of device).

        Raises ValueError if packet object isn't valid, or device
        name isn't recognized.