问题描述
#!/usr/bin/perluseNet::sFlow;useIO::Socket;my$sock=IO::Socket::INET->new(LocalPort=>'6343',Proto=>'udp')ordie"can'tbind:$@n";while($sock->recv($packet,1548)){&processPacket($packet);}die"Socketrecv:$!";subprocessPacket{my$sFlowPacket=shift;my($sFlowDatagramRef,$sFlowSamplesRef,$errorsRef)=Net::sFlow::decode($sFlowPacket);#printerrorsforeachmy$error(@{$errorsRef}){warn"$error";}#printsflowdata;print"===Datagram===n";print"sFlowversion:$sFlowDatagramRef->{sFlowVersion}n";print"datagramsequencenumber:$sFlowDatagramRef->{datagramSequenceNumber}n";foreachmy$sFlowSample(@{$sFlowSamplesRef}){print"n";print"---Sample---n";print"samplesequencenumber:$sFlowSample->{sampleSequenceNumber}n";}}
时间: 2024-09-20 04:05:49