Friday, 21 August 2015

Under the hood of a Dell S3048-ON

The Dell S3048-ON (Dell Datasheet) is a very interesting switch with 48 GE ports and four 10GE ports. Firstly it runs the Open Networking Install Environment (ONIE) which allows you to install the network operating system of your choice(well not really you have a choice of Dell OS or Cumulus and possibly Big Switch). In theory you should be able to install any network operating system that works with ONIE and supports your ASIC.....
Secondly it has GE ports, while typically ONIE switches are usually top of rack designs with only 10GE ports or a mix of 10 and 40GE ports. 
ONIE was developed by Cumulus Networks and is now part of the Open Compute Project. Another huge step in the direction of fully open source top of rack Ethernet switches has been the development of Open Networking Linux (ONL), originally started by Big Switch Networks ONL is also now part of the Open Compute Project like ONIE. Hence with a combination of the appropriate bare metal switch, ONIE and ONL you could build your own Ethernet switch if you were so inclined. This is a significant change in a very conservative market. In the past we had proprietary server hardware and software (Solaris/SPARC etc) until Intel x86 hardware and Linux/BSD/Microsoft came on the seen. Are we witnessing the same in the Ethernet switch market?
 
 The following picture shows the ONIE mSATA card mounted on the CPU motherboard.


I found it difficult to find out what Broadcom ASIC was used in the S3048-ON, so I had a quick peak. The Broadcom ASIC is a BCM56340 StrataXGS system on chip. This SoC is from the Helix family rather than any of the Trident series. If you want to use VXLAN in hardware you need the Broadcom Trident II chipsets. Currently ONL does not support the Dell S3048, but it does support other Dell Trident II Dell switches. There is some details on the Broadcom website here:bcm56340 and here:PR

 

The CPU is a dual core Intel Atom.SR1S8




Picture of the whole thing. The CPU is a daughter card that sits on top of the main board. The Broadcom 5634 is mounted on the main board and is underneath the daughter board.




Fun with Mojolicious UserAgent and DOM


The best solution I have found for scraping webpages has got to be without any doubt Mojolicious. http://mojolicio.us/
Mojolicious is a Perl framework which includes among many things a fully functioning UserAgent. The Mojolicious UserAgent allows you to easily scrape pages and feed the results to Mojolicious's DOM parser.

The problem I was trying to solve was to log into a website and pull details from my account. Parse the results and e-mail myself the details once a month.

Mojolicious comes with everything you need in one cpan bundle. Check out  http://mojolicio.us/ on how to install. The only extra things I needed to install were OpenSSL, Libio-socket-ssl-perl, libssl-dev, and Net::SSLeay.


The way I always start to scrape a page is to use Chrome or Firefox to find the headers I am interesting in.

For Google Chrome this is - Tools-->More Tools-->Developer Tools.
Browse to the webpage you want to scrape, select Network from the developer tools panel and then refresh the page you want to scrape. Then view the headers for the transaction you are interested in.
The Page I am interesting in is:  https://www.zurichlife.ie/bgsi/log_on/login.jsp

From Google Chrome Developer Tools, we can see that the interesting bits are:
Request URL:
https://www.zurichlife.ie/bgsi/servlet/com.eaglestar.servlets.LoginServlet
Request Method:
POST
Content-Type:
application/x-www-form-urlencoded
Referer:
https://www.zurichlife.ie/bgsi/log_on/login.jsp
userName: xxxxxxxxx
password: xxxxxx
pin: xxxxxx


Now for the fun with MOJO::UserAgent.


my %params = (
userName => 'xxxxxxxx',
password => 'xxxxxx',
pin => 'xxxx',
);
my $ua = Mojo::UserAgent->new;
$ua->transactor->name('Mozilla/5.0');
$ua->max_redirects(5);

my $tx = $ua->build_tx(POST => 'https://www.zurichlife.ie/bgsi/servlet/com.eaglestar.servlets.LoginServlet', form => \%params);

$tx->req->headers->referrer('https://www.zurichlife.ie/bgsi/log_on/login.jsp');
$tx = $ua->start($tx);

 
my $filtered_dom;
if (my $res = $tx->success) {
#    print $res->body;
my $dom = $res->dom;
$filtered_dom = $dom
        ->find('p')
        ->grep(qr/Current Transfer/)
        ->join("\n");
#print $filtered_dom;
}
else {
    my ($err, $code) = $tx->error;
    print $code ? "$code response: $err\n" : "Connection error: $err\n";
}

$res contains the raw HTML page. I then use Mojo::DOM to parse the page. Mojo::DOM uses CSS selectors. I expect there is a much nicer way to use DOM and CSS to filter out the details I am looking for.

I then use Cron and Perl to e-mail the results to me monthly. Mojolicious keeps on surprising me:-)

There is a great tutorial here from Brian D Foy.
http://perltricks.com/article/143/2015/1/8/Extracting-from-HTML-with-Mojo--DOM