FreeBSD 9.0: higher MTU & NIC bonding

Here’s is some information that took me a good while to gather.

With the igb driver in FreeBSD, the mbuf cluster size needed is a mathematical formula involving the number of CPUs & the desired MTU. Unfortunately, it is currently hard set. On enterprise machines with many cores and higher MTUs, it is quite easy to reach this set limit. It will express itself with the following error message after an ifconfig:

igb0: Could not setup receive structures

This limit can be overridden with the following in /etc/sysctl.conf

kern.ipc.nmbclusters=131072
kern.ipc.nmbjumbo9=38400

These are the value that worked for 16 cores & an MTU of 9000.

While we’re at it, it took me a while to nail the exact syntax require for NIC bonding so here it is:

/etc/rc.conf

if_lagg_load="YES"
ifconfig_igb0="mtu 9000 UP"
ifconfig_igb1="mtu 9000 UP"
cloned_interfaces="lagg0"
ifconfig_lagg0="laggproto failover laggport igb0 laggport igb1 192.168.0.123 netmask 255.255.255.0"

As far as I can tell, capitalization matters…

Chicken Coop!

It’s been over a year since our move away from the city and we’re finally getting back into chickens. Things take time, starting fresh at the other end of the country doesn’t happen overnight. We only got 5 layers  as we’re pretty late in the season, we’ll start meat birds next spring.

The coop still needs some polish and a window but here it is in all its current glory:

With a bunch of Rhode-Island Reds

Works for toddlers as well

As with the beehive, I drafted everything on Google Sketchup and it made building it completely devoid of surprises. The plan can be downloaded here.

The impairing lack of light pollution

When we lived in the city, ambient light pollution was such that I could set my CCTV cams to a certain brightness/contrast and the limited auto adjustments they did were enough to cope with day & night. In the middle of the forest, the night gets full on #000000 dark. The poor cams can’t adjust and I need to pick whether I want to record at night and get white frames during the day, or at daytime and get black frames during the night.

I wrote the following script which computes the average brightness of a cam’s current frame and issues more drastic adjustments if needed. It is obviously tailored for my FI8918Ws but the same idea can be used for others.

#!/usr/bin/php
<?php

$img = @imagecreatefromjpeg( 'http://192.168.1.203:8003/snapshot.cgi?user=<username>&pwd=<password>' ) ;
if( $img===false ) {
    die( "Unable to open image" ) ;
}

$w = imagesx( $img ) ;
$h = imagesy( $img ) ;

$total_r = 0 ;
$total_g = 0 ;
$total_b = 0 ;
for( $i=0 ; $i<$w ; $i++ ) {
    for( $j=0 ; $j<$h ; $j++ ) {
        $rgb = imagecolorat( $img, $i, $j ) ;
        $total_r += ($rgb >> 16) & 0xFF;
        $total_g += ($rgb >> 8) & 0xFF;
        $total_b += $rgb & 0xFF;
    }
}

$average_brightness = round( ( $total_r / ($w*$h) + $total_g / ($w*$h) + $total_b / ($w*$h) ) / 3 ) ;
echo $average_brightness, "n" ;

if( $average_brightness<30 ) {
    echo "night time!n" ;
    echo "moden" ;
    $result = file_get_contents( 'http://192.168.1.203:8003/camera_control.cgi?param=3&value=0&user=<username>&pwd=<password>' ) ;
    sleep( 10 ) ;
    echo "contrastn" ;
    $result = file_get_contents( 'http://192.168.1.203:8003/camera_control.cgi?param=2&value=6&user=<username>&pwd=<password>' ) ;
    sleep( 10 ) ;
    echo "brightnessn" ;
    $result = file_get_contents( 'http://192.168.1.203:8003/camera_control.cgi?param=1&value=240&user=<username>&pwd=<password>' ) ;
} else if( $average_brightness>170 ) {
    echo "day time!n" ;
    echo "moden" ;
    $result = file_get_contents( 'http://192.168.1.203:8003/camera_control.cgi?param=3&value=2&user=<username>&pwd=<password>' ) ;
    sleep( 10 ) ;
    echo "contrastn" ;
    $result = file_get_contents( 'http://192.168.1.203:8003/camera_control.cgi?param=2&value=4&user=<username>&pwd=<password>' ) ;
    sleep( 10 ) ;
    echo "brightnessn" ;
    $result = file_get_contents( 'http://192.168.1.203:8003/camera_control.cgi?param=1&value=64&user=<username>&pwd=password>' ) ;
}

?>[/code]