【发布时间】:2014-01-20 23:14:30
【问题描述】:
我有一个perl程序,可以从pcap文件中读取流的数据包,但是需要很多时间,我想让它并行,但我不知道它是否可能?如果是可以我用 MPI 来做?还有另一个问题,使这段代码并行的最佳方法,这是我的代码片段(我认为我应该在这部分工作以进行并行,但我不知道最好的方法!)
while (!eof($inFileH))
{
#inFileH is the handler of the pcap file
#in each while I read one packet
$ts_sec = readBytes($inFileH,4);
$ts_usec = readBytes($inFileH,4);
$incl_len = readBytes($inFileH,4);
$orig_len = readBytes($inFileH,4);
if ($totalLen == 0) # it is the 1st packet
{
$startTime = $ts_sec + $ts_usec/1000000;
}
$timeStamp = $ts_sec + $ts_usec/1000000 - $startTime;
$totalLen += $orig_len;
$#packet = -1; n # initing the array
for (my $i=0 ; $i<$incl_len ; $i++) #read all included octects of the current packet
{
read $inFileH, $packet[$i], 1;
$packet[$i] = ord($packet[$i]);
}
#and after that I will work on the "packet" and analyze it
那么我应该如何发送文件内容以供其他处理器并行处理.....
【问题讨论】:
标签: perl parallel-processing mpi