Wednesday, 1 June 2016

On Linux, difference between network commands, like "ip route show" vs "route"

Apparently, Linux tool "route" performs very similar role with the "ip route" command. They both can show and manipulate a routing table of Linux. So, what is difference?

Simple answer is; "ip" command replaces the old "route" command. "ip" is a command line tool in "iproute2" suite which substitutes "net-tools" package. "iproute2" suit integrates more functionality and a single interface through "ip" command.

Thus, if you can do something with route command, you can do exactly same thing with ip command.

More details of one-to-one match between old and new command can be found on this article: https://dougvitale.wordpress.com/2011/12/21/deprecated-linux-networking-commands-and-their-replacements/


Thursday, 26 May 2016

WiFi 802.11ac/n/g speed in theory and practice

When you are looking for a new fancy WiFi router, you can see a lot of bloated numbers in their model name. There are several technologies specified in IEEE 802.11, such as a, g, b, n, ac (the latter, the newer).

WiFi manufacturer put those alphabets to the model name to make customer easy to recognize up to which technology it supports, and most times put a number after that, such as N600, AC1300, AC1600, etc., to indicate what their maximum speed is.

Customers, like me, easily believe that N600, for example, would support 600 Mbps max speed for a connection between one device and the router theoretically. You probably have heard that this 600 Mbps is not a realistic, but still theoretically possible.

Wrong.

This number does not provide much information about the speed of 'a single connection'. It rather gives theoretical maximum speed that the router can support for 'all connections'.

For example, the maximum speed of a single connection in WD MyNet N600 is 300Mbps, not 600Mbps. They used N600 in the model name because the device can support up to 300 Mbps for 2.4Ghz and 5Ghz respectively. The maximum speed (more like throughput) of the router, 600Mbps, can be achieved when two devices are connected at 300Mbps on 2.4Ghz and 5Ghz respectively.

This is tricky and hard to be aware for a non-professionals, as many people would just believe that AC1900 would perform much better than N300 with their MacBook Air or Nexus 5.

In addition to the WiFi technology, like AC or N, there is another crucial part that determines the maximum WiFi speed of a device: the number of radios.

For the older 802.11 technologies, such as a/b/g, a device can only use a single radio. Therefore, the maximum speed was fixed to 54Mbps in 802.11g for example.

On the other hand, newer technologies including n and ac employ MIMO concept which can utilize multiple radios to achieve higher speed. (Note that this is a different concept from dual-band support like 2.4Ghz and 5Ghz). Only when both of your mobile device and WiFi router are equipped with multiple radios, you can get a higher speed. It totally depends on how many radios your mobile device is equipped with.

For example, if you connect your Nexus 5X (2x2 MIMO support) to a N600 (300 for 2.4GHz plus 300 for 5GHz, 2x2 antenna) router with 802.11n 5Ghz, the maximum speed can be up to 300 Mbps. However, if you connect the old Nexus 5 (no MIMO) to the same router, the maximum speed is only 150 Mbps, because 150 Mbps is the max speed at 1x1 radio of the Nexus 5. Nexus 5 supports 802.11ac though. If the Nexus 5 is connected to AC1300 router, for example, it can have at most 433 Mbps (Max speed of 802.11ac with 1x1 radio).

The table below shows the maximum speed of 802.11 standards at different radio settings.

Radio configuration1x12x23x3
802.11ac 5GHz4338661300
802.11n 5GHz150300450
802.11n 2.4GHz72144

Also, the radio configuration of a few well-known devices are presented.

DeviceSupport modeRadio confMax speed (ac)
Nexus 5n, ac1x1433
iPad Air, iPhone 6n, ac2x2866
Macbook Airn, ac2x2866
Nexus 5Xn, ac2x2866

At last, I should emphasize again that all these speeds are theoretical. In practice, it's not rare that 144Mbps speed at Macbook Air (connected with 802.11n, 2.4Ghz) is far quicker than 300Mbps-connected Nexus 5X. This is because laptops usually embed a big antenna compared to the smaller mobile devices. Also, laptops can have higher power range at WiFi chip-set which performs better.

For your information, this is a bench-marked network speed in reality. All devices are connected to N600 router which supports only 802.11n up to 300Mbps (2x2 config).

Band2.4 (144/72)5 (300/150)
Macbook Air (2x2)103113
iPad (2x2)78110
Nexus5 (1x1)4599

Although theoretical max-speed of Macbook and iPad, 300Mbps, is twice as the Nexus 5's max speed (150Mbps), the actual speed is almost same across all the three devices.

Wednesday, 18 May 2016

Battery capacity comparison from MacBook to Xiaomi Powerbank to Eneloop.

All portable devices need a battery for their power source. We learned basic electric units such as Watts, Ampere, Voltage, Watts-Hour, etc. However, when the device specification listed 2700mAh, or 54Wh battery, we get somewhat confused what it literally means. Here I want to compare those different units and the actual capacity of the batteries.

First of all, there are two different units the manufacturers use to describe the battery capacity: Watts and Amperes. You remember the equation to calculate Watts from Ampere.

Watts (W) = Ampere (A) * Voltage (V)

Apple uses Watts, instead of Ampere, to describe their charger capacity instead of Ampere. For example, Apple's 12W iPad charger is equivalent to 2.4A adapter, as the output of this charger is 5V (standard USB voltage). Similarly 5W iPhone charger outputs 1A at maximum. This is why you can't use iPhone charger for iPad as the output currents is too low for iPad, while you can use iPad charger to charge iPhones.

Similarly Watts-hours can be calculated with Ampere-hours because the voltage is constant regardless of time for the device.

Watt-hours (Wh) = Ampere-hours (Ah) * Voltage (V)

Most mobile devices nowadays use lithium-ion battery. A single cell of the lithium-ion battery has around 3.7 Volts, which is applicable to the most mobile phones and tablets. Therefore, iPhone 6s' 1715 mAh battery is equivalent to 6.35 Wh. We can use Wh or mAh interchangeably for the most case if the device is equipped with 3.7V single cell (or multi-cell with parallel connectivity) battery.

However, laptops needs more power than other portable devices to run the many integrated functions, which is the reason why MacBook Air's battery has higher voltage: 7.4V. This is actually equivalent to the dual cell lithium ion battery in serial connection. Therefore, 54 Wh MacBook Air battery's Ampere-hour is 7300 mAh, not 14,600 mAh.

The attached 'hours' in these unit mean that it can constantly provide such amount of Watts or Amperes for one hour. For example, 54 Wh means the battery can provide 54 Watts power for an hour. If the device consumes only 5.4 Watts, this device can survive for 10 hours with the 54 Wh battery. Power adapter does not use these 'hours' units, as they can supply unlimited power, whereas batteries can provide only for a certain amount of hours.

MacBook Air 13": 54 Wh = 7.4 V * 7,300 mAh
MacBook Pro 13": 74.9 Wh = 7.4 V * 10,120 mAh

iPhone 6s: 1,715 mAh * 3.7V = 6.35 Wh
iPhone 6s Plus: 2,750 mAh * 3.7V = 10.18 Wh
Nexus 5X: 2,700 mAh * 3.7V = 9.99 Wh
Nexus 6P: 3,450 mAh * 3.7V = 12,77 Wh
iPad Air 2: 7,340 mAh * 3.7V = 27.16 Wh
Xiaomi Powerbank 16000mAh: 16,000mAh * 3.7V = 59.2 Wh

Eneloop AA (NiMH): 2000mAh * 1.2V = 2.4 Wh

Note that Xiaomi's 16000 mAh powerbank specifies 16000 mAh capacity based on the battery cell, not the output level. Its output Volt is 5V, not 3.7V, thus it has 11840 mAh output capacity.

Thursday, 4 February 2016

CAUTION! Think twice before joining GreenShareCar!

If you are looking for a car share membership, you have to consider again before joining GreenShareCar membership.

On their homepage they advertise that there is no joining fee. That is "literally" true, but not really. When you join the membership, you do not have to pay any fee for joining. Thus there is no joining fee. However, they will charge you "Termination of Membership / Plan" fee no matter how often or how long you have used their cars.

Be aware that you will be charged $55 when you quit the membership, no exceptions. Everyone should pay $55 to terminate this membership!

This crucially important information, however, cannot be found anywhere on their website. You can find it only in their Membership User Agreement PDF file, on the last page, as the last element in the fee/charge table.

If you do not want to pay for $55 termination fee, do not go for this company!

Wednesday, 13 January 2016

How to setup a personal SSTP VPN server on Azure Ubuntu using SoftEther

1. What is VPN and why to use?


VPN is getting popular not only for enterprise and virtual network usage, but also for personal purpose which can secure all connections and data transferred from your PC. Those who plan to use VPN service usually subscribe for VPN service by paying some $$. It is convenient to get VPN connection, but you should pay the usage cost to the VPN provider, also might concern that whether you can trust the VPN provider.

To avoid the cost and the dodge VPN providers, you can set up your own VPN server on a cloud service, if you can get a free instance on the cloud. Amazon's AWS has a trial plan which you can get t1.micro instance for free for the first year. Also, Microsoft provides free instances or free credits for students and start-up companies, so that you can run your own virtual machines there. If you can access AWS, it's easier to set up VPN server (PPTP or L2TP) by just following some tutorials online as they support more wide range of IP protocols for their virtual instances.

2. Creating VPN server on Clouds: Microsoft Azure VS Amazon AWS


Azure is a cloud platform service by Microsoft that provides virtual machines where you can run any application you want. Users can create Windows, Ubuntu, or any other system with a few mouse clicks. However, Azure does not support non-trivial protocols on top of IP for L2TP or PPTP, but only TCP and UDP can be used. For example, L2TP/IPSec uses several UDP/TCP ports plus protocol 50 (ESP). Users can open those specific UDP/TCP ports for the virtual machine in Azure to allow traffic to goes through the Azure's firewall, but there is no way to open protocol 50 on IP, as it is not controllable by the user. Similarly, PPTP uses TCP 1723 as well as protocol 47 (GRE) which cannot be opened on the firewall settings. Unlike Auzre, Amazon's AWS supports opening these IP ports. In AWS you can change security settings to allow the traffic on protocol 50 (ESP) or protocol 47 (GRE) going through the firewall.

Unless Microsoft changes their policy, there is no way to use those protocols in Azure. Therefore, we cannot set up the famous L2TP or PPTP in Azure. However, we still have a few options. SSTP and OpenVPN can be used in Azure, as they do not use any protocol other than TCP or UDP. OpenVPN is easy to set up on Linux, but it requires installing their own client program on Windows and other O/S, because none of them supports OpenVPN in their native system. If you do not want to install any third party VPN client on your operating system, the last option is SSTP. SSTP is Microsoft's protocol to support VPN. It is provided in Windows Server by default, so that you can easily set up the server if you create Windows Server virtual machine in Azure.

In this article, we will set up SSTP server on Microsoft Azure cloud using Ubuntu OS, not on Windows Server. We set up SSTP because we want to connect to it from Windows desktop without installing any other client software. It is also secure as the VPN server is fully controlled by ourselves. If you are using Windows on your desktop and want to build your own VPN server on Azure, but if you do not want to install another VPN client, this article is for you.

3. Configuring SSTP Server on Ubuntu using SoftEther


On Linux, there is a software project called SoftEther which provides SSTP server function.You can follow the Nima's article in the following site up to Step 10 to set up SoftEther server on Linux, with some cautions.

https://www.digitalocean.com/community/tutorials/how-to-setup-a-multi-protocol-vpn-server-using-softether

Before starting the configuration, you have to alter some parts from the original article to allow Windows' default SSTP to work with your SoftEther server program.


1) In Step 6, instead of creating a new virtual hub, you have to use DEFAULT hub that is already created by SoftEther. Instead of "HubCreate VPN" and "Hub VPN" command, simply put "Hub DEFAULT" command which will choose the DEFAULT hub.

2) As we setup SSTP only, you can skip Step 9, and the OpenVPN part in Step 10.

3) Once you finish up to Step 10, restart SoftEther service by using the following command.

sudo /etc/init.d/vpnserver restart

4) Also, don't forget to open TCP port 443 in Microsoft Azure's portal to let the packets pass through the firewall.

4. Configuring SSTP Client on Windows


After the server configuration, simply use Windows' default VPN setup wizard in Network Settings to connect to the new SSTP server.

If you see "A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider." error message, the certificate of your SoftEther server has to be installed on your Windows client PC to allow the connection. You can simply download "cert.cer" created during the SoftEther setup procedure (Step 10) to the Windows, and import it to the root certificate. (Link to how to import Certificate chain)

There will be no issue if you set up SoftEther successfully using its DEFAULT virtual hub. Now, enjoy the free VPN through your own VPN server hosted in Azure.

Android Battery Drain issue - How to dig and find the root cause?

Mobile phones is getting more and more powerful silicons and processors, which causes more and more issues on battery management. It is unav...