简体   繁体   中英

Two processes sharing same pcap file

I have a c++ program (executing on linux) which makes use of a pcap file. Each packet from this pcap file is processed and results are generated in a text file. I have written a script that run two instances of this program with different input arguments . One instance of this program runs on one CPU and the other instance runs on second CPU.

The problem is that in my program I have hard coded the pcap file name. As a result, on both CPUs the pcap file is opened and packets are read from it.

I want that instead both of the programs open up the same pcap file for reading, this thing happens just once that one time a pcap file is opened and each of its packet is send to both the processes running on CPU1 and CPU2.

Please give me some direction that how can I achoeve this task.

It sounds like you want your processes to do something like this:

  1. Open up your pcap file
  2. Read some packet out of it
  3. Pass that packet onto two threads of your process, each one configured differently

You could have your script read the pcap file and pass binary data on stdin to your c++ program which then processes it. Or you could use a socket, shared memory a pipe instead of stdin.

I'm assuming that you have access to the code for the program of which you speak.

If not, then it's much more complicated.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM