NetSys / bess

BESS: Berkeley Extensible Software Switch
Other
313 stars 156 forks source link

Hi, can I generate a new packet in the middle module? #718

Closed btlcmr0702 closed 6 years ago

btlcmr0702 commented 6 years ago

Hi, i find in all examples bess use scapy to generate a template of packet, then use rewrite or flowGen module to "generate" a packet and pass it to the downstream module. Now i have a scenario that when i receive a packet (like a token) from other hosts, i need to send a reply to the hosts, but how can i do that in the bess? Can I just generate a new packet and fill it with my own designed parameters in the middle module ? Is there a example i can consult ? Thank for your reply.

chris3torek commented 6 years ago

If you are writing your own module, you can generate your own packets. The core/modules/source.cc and core/modules/flowgen.cc modules are of course examples of creating packets that aren't replies, and there are not very many examples of creating packets that are replies, but there's one I just wrote a bunch of fixes for, in core/modules/url_filter.cc. See Generate403Packet and GenerateResetPacket.