0

I'm building an artificial bridge and in order for packets to pass through it it has to send an arp response as if it's the target computer in order for packets that are aimed at the other side of the network to pass through it.

I found a way to send an ARP request broadcast Sending my own ARP packet using SharpPcap and Packet.Net

however I can't find any API descriptions on how to send a response.

thanks

Community
  • 1
  • 1
Foxman
  • 189
  • 13
  • Is this question about Pcap.Net or SharpPcap? Tag and title says pcap.net but content says SharpPcap. – brickner Sep 19 '15 at 07:43
  • @brickner Sorry, I didn't notice that the code I linked was in SharpPcap. Both are okay as solutions. – Foxman Sep 20 '15 at 11:01

1 Answers1

0

I've looked for an example ARP pcap file and found this: http://packetlife.net/captures/icmp_in_l2tpv3.cap (search for arp in Wireshark).

Here is the Pcap.Net code that should create an equivalent packet to the ARP reply packet in this file:

Packet packet = PacketBuilder.Build(
    DateTime.Now,
    new EthernetLayer
    {
        Source = new MacAddress("00:50:56:a5:64:4d"),
        Destination = new MacAddress("00:50:56:9a:78:c7"),
        EtherType = EthernetType.Arp
    },
    new ArpLayer
    {
        ProtocolType = EthernetType.IpV4,
        SenderHardwareAddress = new byte[] {0x00, 0x50, 0x56, 0xa5, 0x64, 0x4d}.AsReadOnly(),
        SenderProtocolAddress = new byte[] {0x0a, 0xd8, 0x64, 0xd2}.AsReadOnly(),
        TargetHardwareAddress = new byte[] {0x00, 0x50, 0x56, 0x9a, 0x78, 0xc7}.AsReadOnly(),
        TargetProtocolAddress = new byte[] {0x0a, 0xd8, 0x64, 0xd3}.AsReadOnly(),
        Operation = ArpOperation.Reply,
    });
brickner
  • 6,595
  • 3
  • 41
  • 54