Posts from ‘Python’

Mar
23

bwMeterCaseThe home and small business routers these days that us geeks would be interested in buying are shipping with SNMP server functionality built in as standard, and when their not there’s normally some way of breaking into the Busybox Linux distro (that most of them use) and installing some kind of SNMP daemon.

However there’s always cases where that options not available for some reason or another, in these cases you can use a setup like Kurt’s, where he decided to build a passive bandwidth monitor (even through the router in his pictures does support SNMP?!).

See a basic video of it in operation here:

The basic setup consists of a passive network tap; This is basically just a fancy way of saying that you’ve cut into the pairs of a Cat5e network cable and added in an extension of the pairs to your own device. The device that you add in should be doing nothing other than monitoring, so that it’s not transmitting any data on to the cable that would confuse the other two host which assume their are directly connected to each other with no other hosts on the network segment. The limitation of this setup is you need physical access to the cable, and due to the nature of high speed ethernet it would only work on 100Mbps connections or less.

The electronic brains behind the setup is a ENC624J600 chip to interface with the ethernet layer, chosen because of it’s raw ethernet functionality, this was connected up to an Atmega128 using the SPI interface which would run the core code to count packets and plot on the LED display.

To have a look at Kurt’s full write up on the project, head over to here.

Dec
22

I have recently been playing around with python in my lack of “spare time”, it’s quite a powerful and very useful programming language to have knowledge of, as it’s fairly platform independent meaning no matter what servers I am working on the scripts should work, if python is installed of course.

Further more the structure of the code is designed to be “hacker friendly”, and I don’t mean that it’s great for script kiddies that want to run port scans etc, i mean it’s designed for the people that quickly want to write a program to hack together a solution for a problem, something thats probably going to give me some real world value. This can be seen when you look into the coding further:

What Semicolon?

Most program languages dont really pay much attention to how humans structure their code, this means things have to me made clear to them. An example of this is most languages will request an end of line to be marked with a semicolon “;”. Python is more intuitive and actually looks for where a new line starts/ends, therefore semicolons are now optional. Infact it’s considered bad practice by Python coders to use them at all in their scripts.

In PHP:

echo "Hello world!";

In Python:

print "Hello world!"

Belt and Braces, no thanks!

Another great example is the use of indentation, typically developers will have to wrap functions and statements in braces “{}”, they will then also indent the code using tabs/spaces to make it more humanly readable. In reality this becomes redundant as your trying to please both the interpreter and the human reading your code.

Python therefore removes the braces in favour of what humans are already going to use, indentations! Another advantage of this is your code becomes more readable, as good structure no longer becomes a best practice it actually becomes a requirement for your code to run as you intend!

In PHP:

function test(){
  echo "test";
}

In Python:

def test():
  print "test"

Finally probably one of the best things is that is so easy to learn, because they have embraced what many programers already do most of the coding becomes almost natural, and there are less language rules or idiosyncrasies to incorporate into your code.

I will probably be doing some more posts on python as my knowledge hopefully expands in it.

Our Sponsors