I'm trying to send ethernet packet to choosed destination MAC address using jPcap
:
public void sendPacket(Packet packet, byte[] srcMac, byte[] dstMac, Interface i) throws IOException
{
JpcapSender sender = JpcapSender.openDevice(i.netInterface);
EthernetPacket ether = new EthernetPacket();
ether.frametype = EthernetPacket.ETHERTYPE_IP;
ether.src_mac = srcMac; // MAC address of selected interface
ether.dst_mac = dstMac; // MAC addr. choosed somwhere on form
packet.datalink = ether;
sender.sendPacket(packet);
sender.close();
}
It works, but it's always sent to the selected interface not to the dst_mac
!
So I don't understand the relation between selected interface and scr_mac
:
- why I have to choose both (
interface
andscr_mac
)? - why I have to add
dst_mac
even if it's not used? - how to send packet out of my computer then?