aregm / nff-go

NFF-Go -Network Function Framework for GO (former YANFF)
BSD 3-Clause "New" or "Revised" License
1.38k stars 154 forks source link

How to send packet to raw socket device? #599

Open mkfsn opened 5 years ago

mkfsn commented 5 years ago

Hi, thanks for introducing the raw socket, it's a very cool feature! :)

I'm now trying to use the raw socket but having a problem that I couldn't find a way to send packets to that device.

Before I was using SetReceiver and SetSender for dpdk devices, and then I'm able to send a new packet to that port, for example:

pkt, _ := packet.NewPacket()
packet.GeneratePacketFromByte(pkt, []byte(data))
pkt.SendPacket(port)

But I suppose if I use raw socket I don't have the port, so how can I send a new generate packet to the device?

aregm commented 5 years ago

SetReceiverOS, SetSenderOS. Example is here https://github.com/intel-go/nff-go/blob/master/examples/OSforwarding.go

ifilippov commented 5 years ago

Now we don't have a functionality for sending packet directly without flow graph to Raw socket.

You can use SetGenerator->SetSenderOS for lots of packets, however if you would like to send individual packets directly from Flow Functions we will need to add this functionality.

Do you want us to add this functionality?

guesslin commented 5 years ago

@ifilippov that sounds good to us, we'll try to use the SetGenerator

vulcanfan commented 3 years ago

Hi, I would like to see an equivalent of SendPacket() but directed at non-Ports, ie OS, XDP etc. Did that project get kicked off at all? Currently, without it, it isn't possible to 'seamlessly' swap between DPDK ports, OS and other types of interfaces as, for example, whilst the ARP and ICMP functions can send one-off packets to a port it's not possible to do so to an AF_PACKET interface as it currently stands.
Thanks