in reply to Re: Check udp stream coming in
in thread Check udp stream coming in

Hi All,
Thanks for the reply.

Let me explain once again. I will be getting udp packets on my machine say 192.168.1.1 (eth1). I will verify this using
tcpdump
command. The output would look like this.

tcpdump -i eth1 dst 225.1.1.152 tcpdump: verbose output suppressed, use -v or -vv for full protocol de +code listening on eth1, link-type EN10MB (Ethernet), capture size 96 bytes + 00:54:45.314015 IP 192.0.0.152.sieve > 225.1.1.152.sieve: UDP, length +1316 00:54:45.314234 IP 192.0.0.152.sieve > 225.1.1.152.sieve: UDP, length +1316 00:54:45.314580 IP 192.0.0.152.sieve > 225.1.1.152.sieve: UDP, length +1316 00:54:45.314768 IP 192.0.0.152.sieve > 225.1.1.152.sieve: UDP, length +1316

Now 'tcpdump' is a tool which can snif tcp/udp packets, to show that its is coming in properly. I can't every time login to system and run tcpdump and redirect the output to some file, parse the file, extract packet and see whether its fine or not. So i was thinking some script in Perl i can write to automate this. I don't want to use | (pipe) to tcpdump, get the output to a file etc. All i wanted to know is there any way in Perl to see packets are coming in to system? , say bind to system ip , listen for perticular port , check any data is coming in from destination ip etc(Some body told me about Socket programin, i thought i should try that before giving up on Perl). Since i am a newbie.. , Please guide me what kind of packages, tools do i need to use to achive this.
Your help is appreciated...

Thanks

Replies are listed 'Best First'.
Re^3: Check udp stream coming in
by mjscott2702 (Pilgrim) on Oct 13, 2010 at 08:16 UTC
    What was being suggested was creating a script that would execute the tcpdump command for you, parse its output, and display whatever you want, based upon the results - no intermediate files, or anything. Without knowing what you are looking for, I can't specify an actual test for the desired output.

    use strict; use warnings; open(my $tcp, "/usr/sbin/tcpdump |"); my $ok = undef; while(<$tcp>) { $ok = 1 if m/\w/; # your test here } print "All things groovy\n" if $ok;