Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Script to resolve MAC address to Vendor list

Posted on 2004-04-29
4
Medium Priority
?
4,374 Views
Last Modified: 2010-08-05
Hello, I have a list of 6000 mac address. I have downloaded the oui.txt file from IEEE of the vendors. I would like to run the 6000 mac address against the oui.txt. What would be th best way to go ?
I have tries to sort them and get the names of the Vendors. I would like to just get the counts/persentage of the vendor mac for a pie chart. The Mac addr are the wireless card used in our enterprise. To draw the pie chart I have a php script.

http://standards.ieee.org/regauth/oui/oui.txt it looks like this..
00-00-00   (hex)            XEROX CORPORATION
000000     (base 16)            XEROX CORPORATION
                        M/S 105-50C
                        800 PHILLIPS ROAD
                        WEBSTER NY 14580

00-00-01   (hex)            XEROX CORPORATION
000001     (base 16)            XEROX CORPORATION
                        ZEROX SYSTEMS INSTITUTE
                        M/S 105-50C 800 PHILLIPS ROAD
                        WEBSTER NY 14580
---------------------------------------------------------------------------------------
my mac addr .txt file looks like this..
00e098a32b78
00e098a32bd0
00e098a34b4c
00e098a34c4c
00e098a34c5a
00e098a35d68
00e098a36598
...
---------------------

Thanks in advance.
0
Comment
Question by:amitubale
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 7

Expert Comment

by:fim32
ID: 10952166
well, as you can see, the vendor string is the first 6 hex digits... so i would go through your mac list and organize them by the first 6 digits, and count those.  then it'll be a lot easier to compare them against the oui.txt list.

in fact, i'm sure you'll reduce yourself to a handful of vendors...
0
 
LVL 10

Accepted Solution

by:
Mercantilum earned 200 total points
ID: 10958146
Maybe something like

use strict;

my %mac;

# get mac data
open F, "mac.txt" or die "mac.txt: $!";
while (<F>) { $mac{lc(substr($_,0,6))}++; }
close F;

my %oui;

# get oui data
open F, "oui.txt" or die "oui.txt: $!";
while (<F>)
{
  if (/^[0-9a-f][0-9a-f]-[0-9a-f][0-9a-f]-[0-9a-f][0-9a-f]/i)
  {
     chomp;
     @_ = split /[()]/;
     $_[0] =~ s/-//g;
     $_[2] =~ s/^[\t\s]+//;
     $oui{lc(substr($_[0], 0, 6))} = $_[2];
  }
}
close F;

# print list of mac sorted
for (sort { $mac{$a} <=> $mac{$b} } keys %mac)
{
   my $vendor = (exists $oui{$_} ? $oui{$_}:"???");
   print "Mac: $_ Vendor: $vendor Number: $mac{$_}\n";
}
0
 
LVL 1

Author Comment

by:amitubale
ID: 10962502
Hello Mercantilum
Thank you for the soution, I hardly know any perl but I wrote 4 different scripts to do various functions on my mac address list. You solution is perfect for what I am trying to do. FYI the list of MAC are all the wireless users in our enterprise ..not i will dig out a php script to chart a nice pie chart on a web server.

Thank you.
Amit

I also found another one http://net.doit.wisc.edu/~plonka/mac2vendor/

0
 
LVL 10

Expert Comment

by:Mercantilum
ID: 10962536
My pleasure :)
Interesting file Mac / vendors.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question