About carroarmato0

Born in Belgium in 1987, me and my family lived in Africa for 6 years and in Italy for 8. Now I’m back in Belgium since 2004. I finished my General Secondary Education in Economics and Modern Languages at the College van Melle. Graduated as a bachelor in Electronics – IT at the university college Katholieke Hogeschool Sint-Lieven. My primary interests are Operationg Systems, specially Unix based/like. This means, any flavors of Gnu/Linux, to more closed or exotic ones like, OpenSolaris, Mac OS, Windows, BSD’s, TriangleOS, etc… I also like to learning about the complex and vast world of computer networking and security.

Got some devolo’s

At home I have a special situation when it comes down to having internet.

My current ISP is Belgacom, and their service (VDSL) relies on the telephone line which comes from the street into my home.

The situation I’m in, is that, instead of the primary cable, or local loop, coming from the street into the wall at the ground floor, my cable does quite some distance, all the way to the first floor.

Not that there’s anything really special about that, except that it’s a bit of an inconvenience as I also have Digital Tv in the living room downstairs.

The decoder needs to have a UTP cable connected into the tv ethernet port on my modem, the bbox2 provided by my ISP. The only way for me to have both internet and digital tv at the same time, was to place the modem downstairs on a secondary RJ11 jack.

This situation isn’t optimal, as the advertised speeds I should get are 30Mbps down and 3,5Mbps up, while in reality, I only get 20Mbps down and 3,5Mbps. That’s only getting 66% out of my line.

The ideal situation would be to plug the modem upstairs, directly on the splitter connected to my local loop, and have the decoder in some way connected to it.

These are some of the options I had:

  • Drill holes in the wall to extend the Ethernet cable of the decoder to the first floor where the modem is.
  • Cut the local loop and place it somewhere on the ground floor.
  • Connect the modem upstairs on the local loop and use Powerline communication for the decoder

Making holes and other things were out of the question, which led me to try out the third option: Powerline communication.

Belgacom sells sets of 2 at 80€ (current prices when this was posted).

Image

They are a white-labelled product from a well known German company who specialises in making Powerline solutions.

In case you haven’t checked yet what Powerlines are, it’s basically a technology to use your household electric circuit as your LAN Network.

This is ideal in houses or small offices where there are many rooms with network devices that can’t be connected through conventional networking like Ethernet cables or WiFi.

This is a very elegant solution although it comes with a speed trade-off.

If you would connect 2 computers together who have 100baseTX network cards, the theoretical speed should be 100Mbps. In reality, the effective speed you’ll achieve is about 96,5Mbps.

To test the speed over the powerline, I’ve connected my home pc running Ubuntu in one such adaptor, and my laptop in the second one, each in a power outlet.

I’ve installed a network speed measuring tool on both systems called iperf.

sudo apt-get install iperf

I’ve given a static IP address to my fixed home pc so that I didn’t have to wait or mess with DHCP, so I could just plug the cable in anywhere I wanted, wait for the signal to be green and go ahead and test.

On the fixed pc, I ran the following command:

iperf -s -D -p 65000

This tells iperf to run in server mode (-s), listen for connections on port 65000 (-p), and run as a daemon service (-D) (this is optional).

On my laptop, I just run this command every time I’m plugged on another power outlet when the light turns green:

iperf -c <ip_of_fixed_pc> -p 65000

Here’s a sample output:

————————————————————
Client connecting to 10.42.0.29, TCP port 65000
TCP window size: 23.5 KByte (default)
————————————————————
[ 3] local 10.42.0.1 port 33421 connected with 10.42.0.29 port 65000
[ ID] Interval Transfer Bandwidth
[ 3] 0.0-10.0 sec 114 MBytes 95.5 Mbits/sec

Here are some speed measurements I made:

Direct connection with pc’s:      96,6Mbps

Plugs next to eachother:          49Mbps

Outlet in the next room(5m):     25Mbps

Further in the next room(11m):  47Mbps

Downstairs kitchen (8m):          46Mbps

Downstairs dining room(14):      46Mbps

Of course this isn’t really significant for your situation, let alone the distances in meters as that actually depends on the electrical wiring inside your house.

One thing we can see from these measurements, is that the speeds are pretty much consistent around my house:  ~47Mbps

While you can certainly say that those speeds are pretty low for connecting computers with each other, one mustn’t forget that the idea is that only the Decoder gets connected that way to the modem!

In fact, Digital Tv doesn’t require a lot of speed to operate as intented ( about 4-8Mbps ), let alone that my maximum internet connection speed is 30Mbps.

So now I have the modem upstairs connected directly on the local loop and being able to surf at full speed while the decoder downstairs is connected to the modem over the powerline with enough bandwidth to spare!

How to change DNS in DHCP on the BBox2

If you are like me and have a Bbox2 from Belgacom, chances are you’d like to change the DNS server the router is suggesting to connecting clients through DHCP.

Unfortunately, Belgacom has lobotomised the OpenWRT version they are using on their internet modems to the point where it’s not possible to configure certain ( from my point of view ) basic things. At least not directly!

On their web interface they seem to give you the possibility to change the DNS server, but you’ll soon realise that the cake is a lie.

Image

Even if you change the Primary DNS Server to something else, it’ll still serve you the IP address of the router itself.

You might be wondering why one should change that in the first place since everything pretty much works.

Here is a shameless excerpt from Steve Gibson’s Podcast, Security Now at http://www.grc.com/sn/sn-226.txt who talks about the subject:

The problem is that, if you remoted your DNS to the router, now it's sort of your proxy. 
And so your computers all just get one DNS address, meaning the router, and are at the mercy of the router doing the right thing. 
It's certainly possible for a smart router to be doing a good job with DNS resolution and be passing that back to the clients that are using it to provide that service. 
But the fact that we've seen flaky router operation, and in fact the DNS benchmark has revealed that some routers are much slower than going direct. 
That is, the router is actually a speed problem for that.
So just from a point of view of network performance, it’s often a good idea to let your router not handle DNS on your behalf.
Without further ado, here are the steps you need to take to change the DNS server address served by your Bbox2 through DHCP.
  1. Connect to your Bbox2 using telnet (example: telnet 192.168.1.1)
  2. Login with admin and password BGCVDSL2
  3. To see the currently served DNS address: rg_conf_print /dev/br0/dhcps/dns/0/ (output example:  (0(192.168.1.1))
  4. Change the address like so: rg_conf_set /dev/br0/dhcps/dns/0/ 8.8.8.8
  5. Save the configuration by issuing the command: save

Image

Reconnect to your network and check to see that the router gave you the DNS address you wanted through DHCP.

Fork-CMS and Lighttpd

Fork-CMS is a young open source content management system which can be found at http://www.fork-cms.com/

The day this is posted, Fork will only work completely out of the box if you use Apache as your webserver.

This is due to the fact that Fork needs to tell Apache through a .htaccess file to be treated specially in order to use prettier URLs.

For everything to work properly in Lighttpd, one must add some directives into Lighttpds configuration to obtain the same result.

Here is a sample configuration

server.modules = (
            "mod_simple_vhost",
            "mod_rewrite",
            ...
)
...
## Fork-CMS
$HTTP["host"] == "mydomain.com" {
    simple-vhost.server-root   = "/var/www/mydomain.com/forkcms"
    simple-vhost.document-root = "/default_www/"
    dir-listing.activate = "disable"
    url.rewrite = (
        "^/(.*)\.(.+)$" => "$0",
        "^/(.+)/?$" => "/index.php/$1"
    )
}

Here I’ve used a vHost because Fork needs to rewrite its URLs using the  root folder of your webserver as its root path, but because Fork is placed inside a subfolder, it needs to be tricked. Using vHosts will tell Lighttpd to treat a folder as a root folder for a certain domain name.

These are the minimal requirements to have Fork-CMS set up and functioning properly as it’s supposed to with regards to configuring Lighttpd as your webserver.

Additional configuration options can be added to Lighttpds configuration file to approximate the behaviour under Apache with regards to caching and compressing and so on.

Fork-CMS: can’t load /private /blog…

If you’re giving  Fork-CMS a try (which can be found at www.fork-cms.be), and are experiencing problems loading a lot of different pages, it might be because your Apache ignores the special .htaccess file the folks at Fork made to make some magic work.

To make sure Apache looks into that file, you need to add the directive “AllowOverride All“, and restart Apache.

Use Vlan Tagging on your Linux Server

This tutorial was tested on a Ubuntu server, some commands and configuration files may vary.

To begin you need to install the following to be able to create and use Vlans on your Ethernet card:

sudo apt-get install vlan

Next, make sure that the dot1Q data encapsulation has been enabled in the kernel:

lsmod | grep 8021q –> ’8021q’

If you don’t see  ’8021q you need to enable it:

sudo modprobe 8021q

At this point, the module should be loaded, however, it won’t be enabled again after a reboot. To ensure that the module will always be loaded after reboots, you need to add it to the module loading list:

sudo sh -c ‘grep -q 8021q /etc/modules || echo 8021q >> /etc/modules’

Now you are able to add Vlans and configure them. You can create Vlans in the following way:

sudo vconfig add eth0 99

This will create Vlan99 and bind it with your eth0  Ethernet card.

To assign an address to it, you use the same commands to configure a network card except for 1 small detail:

sudo ifconfig eth0.99 192.168.99.1 netmask 255.255.255.0

Notice the fact that we added the  .99 to  our  ethernet card device:  ethO.99  to  assign the address to our Vlan instead of our ethernet card.

Your Vlan99 will be active when your ethernet card itself will be active, obviously.

However note that, just like the enabling of the 8021q module, your Vlan configuration isn’t permanent yet.

To make it permanent, you need to add the configuration to /etc/network/interfaces

sudo nano /etc/network/interfaces

auto eth0.99

iface eth0.99 inet static

address 192.168.99.1

netmask 255.255.255.0

vlan-raw-device eth0

AS3: Positioning and Size problems in Sprites and MovieClips

Struggling with your Sprites or MovieClips which don’t seem to be placed in the right spot or be of the right size?

Don’t worry, if there’s something I’ve learned from Flash, it’s to distrust Flash’s own positioning and size properties.

Instead, use your own getters and setters and get your piece of mind.

import flash.display.Sprite;

public class MyCoolObject : Sprite {

private var posX:int;

private var posY:int;

private var posZ:int;

private var sHeight:int;

private var sWidth:int;

public function MyCoolObject() {

}

/* Getters and Setters */

public function set X(val:int) {  this.posX = val; }

public function get X():int { return this.posX; }

public function set Y(val:int) {  this.posY = val; }

public function get Y():int { return this.posY; }

public function set Z(val:int) {  this.posZ = val; }

public function get Z():int { return this.posZ; }

public function set Height(val:int) {  this.sHeight = val; }

public function get Height():int { return this.sHeight; }

public function set Width(val:int) {  this.sWidth = val; }

public function get Width():int { return this.sWidth; }

}

It’s a bit of overhead, but trust me, you’ll thank me later…

AS3: XML, the easy way

Haven’t been able to find a tutorial on how to make XML objects that would be worth writing about in a “XML for Dummies™” book.

So hopefully after this you’ll be able to writting XML strings like crazy :D

XML is already part of Flash globaly, so you don’t need to import it.

To make this easier to understand, I’ll use a ComicBook as an example since I’m currently working on that project which requires the usage of XML objects.

In my project a ComicBook consists of the following:

  • Comic Object
  • Comic object contains an Array of Pages
  • A Page object contains an Array of PageObjects (Sprites… MovieClips… etc….)

Now as you could assume, all these objects are nested inside our Comic object. Using nested for-loops, you can access all the information and perform different sorts of operations.

Comic will therefor, be our main Node. A Parent of sorts.

We create our first XML object tag:

var comicNode:XML = new XML(“<Comic/>”);

People who know a little bit of XML and/or some knowledge about xHTML, will recognize <Comic/> as being a closing tag.

Infact, when we try to view the resulting string, we get this:

trace( comicNode.toXMLString() ); // –>  <Comic/>

This is perfectly normal and you shouldn’t worry yet that the output isn’t  like  <Comic><Comic/>

Later when you’ll be adding elements to the Comic Node, you’ll see that Flash will automatically adapt the XML structure to what you’re feeding it.

A really nice thing is that you can dynamically add properties to your nodes, like giving it an ID, or a Name.

For example, every Comic book I generate needs to have a name. I can do so like this:

comicNode.@name = comic.Name; // –>  <Comic name=”TheNameOfMyComic” />

As you can see, using  node.@ we can generate any attribute name we want! comic.Name happens to be a String variable in the field of my  Comic class where I store the name of it.

Now for the real work! Adding different Nodes to our Parent Node.

Because Comic  contains an Array of Pages, we need to create a For-Loop which runs through all the objects within our Array. The creation of our PageNode, is exactly the same as our ParentNode.

for (var index:Number = 0; index < comic.Length; index++) {
var pageNode:XML = new XML(“<Page/>”); // –>  <Page/>
pageNode.@id = index; //  –>  <Page id=”0″ />
……
comic.Length is simply the length of my Page Array.
Now! We add our PageNode to our ComicNode!
comicNode.appendChild(pageNode); //  –>  <Comic name=”theNameOfTheComic”>
//   –>         <Page id=”0″/>
//   –>  <Comic/>
If you understand all this, then you’ve done it!  You should now be able to easily make your own XML structures :)
Here’s a complete excerpt of my code so you get the general picture:
//Create XML
comicNode = new XML(“<Comic/>”); // <Comic/>
comicNode.@name = comic.Name;    //Adding attibute -> <Comic name=”theNameOfTheComic”/>
//Add the Page objects
for (var index:Number = 0; index < comic.Length; index++) {
var page:XML = new XML(“<Page/>”); // <Page/>
page.@id = index; // <Page id=”0″/>
comicNode.appendChild(page); //<Comic name=”theNameOfTheComic”>
//   <Page id=”0″/>
//<Comic/>
//Add the PageObjects
for (var index2:Number = 0; index2 < comic.getPageByIndex(index).Length; index2++) {
var pageObjNode:XML = new XML(“<PageObject/>”);
var pageObj:PageObject = PageObject(comic.getPageByIndex(index).getChildAt(index2));
pageObjNode.@id = pageObj.name;
if (pageObj.movieClip.inputField != null) pageObjNode.@input = pageObj.movieClip.inputField.text;
pageObjNode.@type = pageObj.Type;
pageObjNode.@posX = pageObj.x;
pageObjNode.@posY = pageObj.y;
pageObjNode.@posZ = pageObj.z;
pageObjNode.@Width = pageObj.width;
pageObjNode.@Height = pageObj.height;
page.appendChild(pageObjNode);
}
}

AS3: Default parameter value

In ActionScript 3 it’s possible to automatically assign a default value to parameters in a function.

Parameters with optional value should be placed at the end of the function parameter list, while all the required ones at the begining.

Parameters with default values can be ommitted. This gives us the following possibilities:

function twoPlusTwoIs (result:int = 2) {

trace( “Result: ” + result );

}

twoPlusTwoIs();    —>  2

twoPlusTwoIs(3);  —>  3

Likewise, a more plausable usage:

function enable ( val:Boolean = true ) {

someVariable = val;

}

MyFancyObject.enable();           —>  true

MyFancyObject.enable(true);     —> true

MyFancyObject.enable(false);     —> false

AS3: How to use Flash Cookies

At some point, you would like to store some data on the client side, say for example, to know if it’s the first time a user is accessing your Flash application/animation, and show him/her different content based on the data.

Just like a Web Cookie, Flash Cookies can be used. The best or evil part of it, is that Flash cookies are harder to remove. In fact, they don’t go away even if the client clears all his browser cookies. That’s because it’s the Flash Player that manages those cookies obviously.

Making these cookies is super easy:

  1. add the import:   import flash.net.SharedObject;
  2. create your cookie object (SharedObject):    var cookie:SharedObject = SharedObject.getLocal(“myFlashCookie”);

The handy thing about it, is that you can add any kind of info in it (Note that the amount of data that you can store is limited to the size that the user has chosen in the configuration of his Flash Player, normally that’s 100Kb).

Here are some handy things to know:

  • cookie.size :  See if our cookie contains anything ( 0 means we have a fresh cookie… mmmh fresh cookie…. :D )
  • cookie.data :  Array containing any object that we want (please not the size limitation described above)
  • cookie.data.VariableName = object :  we can add any variable name to .data.
  • cookie.data.VariableName :  if  VariableName exists, it will return the object it is containing
  • cookie.flush() :  save our cookie immediately to a file (otherwise, our cookie only exists in memory during the length of the session and not being stored on the clients machine)
  • cookie.clear() :  deletes/clears the cookie (  :(  )

Another useful thing to know is that you can call the cookie remotely.

Here’s a live example that I use,  I want to show the user a tutorial on how to use my application. The tutorial will only be show when the cookie is empty.

import flash.net.SharedObject;

public class ComicGenerator extends MovieClip {

//Our Flash Cookie

var cookie:SharedObject = SharedObject.getLocal(“ComicBookGenerator”);

var forceTutorial:Boolean = false;

//Constructor

public function ComicGenerator() {

super();

initialiseStage();

//Force Cookie Deletion

if (forceTutorial) cookie.clear();

//Is this the first time the user sees our app?

if (cookie.size == 0) {

showTutorial();

cookie.data.FirstTime = true;

}

else {

showOperatingMode();

}

}

For more information, you can go take a look at the API documentation: http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/flash/net/SharedObject.html