Posts on Technology

Dealing with iptables errors on a Raspberry Pi


Posted by Diego Assencio on 2015.04.25 under Technology (Raspberry Pi)

If you use iptables on your Raspberry Pi but after a firmware upgrade start getting an error similar to the one below:

iptables v1.4.14: can't initialize iptables table `nat': Table does not exist (do you need to insmod?)
Perhaps iptables or your kernel needs to be upgraded.

you can handle the problem by downgrading the firmware to a version which does not have this issue. Doing this is really simple. Just go to the rpi-update repository page and choose a commit which was created before the day in which you upgraded the firmware of your Raspberry Pi. Click on this commit and then copy the sequence of characters which appears right below the commit message (for those who are unfamiliar with git, this weird-looking sequence of characters is called a commit hash and uniquely identifies a commit). To be more explicit, all you have to do is look for something like this:

commit ba4304f7bec24d5f0a4150f09a37884240f8926d2

Now open a terminal on your Raspberry Pi and run:

sudo rpi-update <commit-hash>

Here is an example with the commit hash shown above:

sudo rpi-update ba4304f7bec24d5f0a4150f09a37884240f8926d2

Reboot the Raspberry Pi and see if iptables is now working. In the unlikely case that the problem persists, just choose another commit and redo the steps above.

Comments (0) Direct link

How much power does a Raspberry Pi consume?


Posted by Diego Assencio on 2014.01.04 under Technology (Raspberry Pi)

I have recently purchased a USB current and voltage tester and decided to check how much power my Raspberry Pi typically consumes. The tester device works simultaneously as a voltmeter and as an ammeter: it goes in series with the USB device and has an LED display which shows the current and voltage being used (see figure 1).

The Raspberry Pi website claims the model B uses between 700-1000mA (depending on the connected peripherals) and needs 5V to operate. I have measured, however, significantly smaller values for the current even when the Raspberry Pi was under heavy load.

Fig. 1: Measuring the power consumption of the Raspberry Pi. The pictures show examples of the measured current ($I = 0.36\textrm{A}$) and voltage ($V = 4.96\textrm{V}$) respectively.

With the measured current $I$ and the voltage $V$, one can compute the power consumption using: $$ P = VI $$ For $V = 5\textrm{V}$ and $I = 700\textrm{mA} = 0.7\textrm{A}$, the power consumption would then be: $$ P = 5\textrm{V} \times 0.7\textrm{A} = 3.5\textrm{W} $$ However, the highest current I registered was $I_{\max} = 0.43\textrm{A}$ and the highest voltage was $V_{\max} = 4.95\textrm{V}$ (these maximum values were seen during boot time and under heavy load). The maximum power consumption I saw was then: $$ P_{\max} = V_{\max} I_{\max} \approx 2.13\textrm{W} $$ which is significantly less than the $3.5\textrm{W}$ computed above. Under normal conditions, my Raspberry Pi consumed between $1.8\textrm{W}$ and $2.0\textrm{W}$.

Comments (3) Direct link

IPv6 address space: how large is it?


Posted by Diego Assencio on 2013.11.05 under Technology (IPv6)

The IPv6 (Internet Protocol version 6) has a very large address space. In fact, since an IPv6 address is $128$ bits long, the number of possible IPv6 addresses is: $$ \boxed{ N_{\textrm{IPv6}} = 2^{128} \approx 3.4 \times 10^{38} } $$ For comparison, the number of:

In other words, the number of possible IPv6 addresses is unimaginably immense. In contrast, IPv4 addresses are only $32$ bits long, so the IPv4 address space contains only $N_{\textrm{IPv4}} = 2^{32} \approx 4.3 \times 10^{9}$ (about $4.3$ billion) addresses. This small address space is one of the causes of the IPv4 address exhaustion.

Let's compute the number of unique IPv6 addresses that could be assigned to each square meter of the Earth's surface. Since the Earth is approximately a sphere with radius $R_{\textrm{Earth}} = 6.4 \times 10^6\textrm{m}$, its area can be computed as below: $$ A_{\textrm{Earth}} = 4\pi R_{\textrm{Earth}}^2 \approx 4 \times 3.14 \times (6.4 \times 10^6 \textrm{m})^2 \approx 5.1 \times 10^{14} \textrm{m}^2 $$

The number of IPv6 addresses per square meter of the Earth's surface is then: $$ \boxed{ \lambda_{\textrm{IPv6}} := \displaystyle\frac{N_{\textrm{IPv6}}}{A_{\textrm{Earth}}} \approx 6.6\times 10^{23} \textrm{m}^{-2} } $$

Interestingly, this number is close to the Avogadro constant ($N_A = 6.022\times 10^{23}$). From this we can compute how much area a single IPv6 address would "occupy". This value is given by: $$ \boxed{ A_{\textrm{IPv6}} := \displaystyle\frac{1}{\lambda_{\textrm{IPv6}}} \approx 1.5\times 10^{-24} m^2 = 1.5 \textrm{pm}^2 } $$ since $1\textrm{pm} = 10^{-12}\textrm{m}$ ($\textrm{pm}$ stands for picometer). Given that a Helium atom, which is the smallest (electrically neutral) atom, has a maximum cross-sectional area (imagine a plane cutting through the nucleus of a Helium atom; the area of the plane inside the atom is what I mean by its "maximum cross-sectional area") of approximately: $$ A_{\textrm{He}} = \pi R_{\textrm{He}}^2 \approx 3.14 \times (31 \textrm{pm})^2 \approx 3000\textrm{pm}^2 \approx 2000A_{\textrm{IPv6}} $$ then each atom on the Earth's surface could have thousands of unique IPv6 addresses assigned to it.

To finalize, it must be said that although huge, the IPv6 address space might still be small enough to save our planet one day.

Comments (0) Direct link