20.01.2014 Views

Lectures notes for 2010 - KTH

Lectures notes for 2010 - KTH

Lectures notes for 2010 - KTH

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

print PTMP "$time $RSSId\n";<br />

$count++;<br />

print "sourcename is $sourcename; sourcename1 is $sourcename1 \n";<br />

}<br />

else {<br />

if ($sourcename =~ $sourcename1) {<br />

print PTMP "$time $RSSId\n";<br />

}<br />

else {<br />

print "sourcename is $sourcename, old sourcename is $sourcename1\n";<br />

close PTMP;<br />

chmod 0664, ’/tmp/ptmp’;<br />

system("mv /tmp/ptmp $sourcename1");<br />

$sourcename1 = $sourcename;<br />

&create_tmp_file;<br />

print PTMP "$time $RSSId\n";<br />

}<br />

}<br />

}<br />

}<br />

close PTMP;<br />

chmod 0664, ’/tmp/ptmp’;<br />

system("mv /tmp/ptmp $sourcename1");<br />

close DATA_FILE;<br />

sub create_tmp_file {<br />

# open(PTMP, ">/tmp/ptmptmp$$") || die "Can’t create tmp file $!\n";<br />

# close (PTMP);<br />

# $locked = link("/tmp/ptmptmp$$", ’/tmp/ptmp’);<br />

# unlink "/tmp/ptmptmp$$";<br />

# $locked || die "Can’t lock temporary file.\n";<br />

open(PTMP, ">/tmp/ptmp") || die "Can’t open tmp file $! <strong>for</strong> writing\n";<br />

}<br />

This script process captured IEEE 802.11 packets to put measurements of the<br />

different sources into their own files, based upon the source MAC address.<br />

(In this case the program assumes that the file has already been sorted based upon<br />

the source MAC address.)<br />

Maguire Using a Perl script 1: 85 of 104<br />

maguire@kth.se <strong>2010</strong>.03.21 Internetworking/Internetteknik

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!