4G vs 5G

The UK has just launched its first 5G network. EE has today rolled out 5G in a number of major cities: London, Manchester, Birmingham, Cardiff, Edinburgh and Belfast. But what is the real difference between 5G and 4G, which we all currently have on our phones.

Firstly, the marketing spiel, 5G is the next evolution and will be even faster than 4G. It will provide better support for small cells in urban environments and it will have lower latency.

But what about at the technical level? 4G uses a technology called LTE, there is also an improvement on this technology called LTE-Advanced or LTE-A, this is often branded as 4G+. Finally 5G uses a technology called “5G New Radio” or “5G NR”

Let’s firstly look at speed. Speed is equal to the bandwidth multiplied by the spectral density multiplied by the number of channels. Its the same formula for wired and wireless connections: here is a diagram showing ethernet over twisted pair

Comparison of twisted pair based ethernet technologies

You can increase speed (equivalent to the volume in the diagram) by increasing any of the three parameters.

Parameter4G (LTE)4G+ (LTE-A)5G (5G NR)
Max bandwidth20MHz40MHz400MHz
Spectral density4.5b/Hz4.5b/Hz6b/Hz
Number of channels244
Max theoretical speed180Mb/s720Mb/s9600Mb/s

As you can see, the maximum theoretical speed of 5G is many times greater than that of 4G and 4G+.

What about in the real world? Well EE has launched with only 40MHz of bandwidth. Spectral density will rarely go above 4b/Hz in a real world environment but all 5G phones support 4 channels (if signal strength is good enough). This means speeds of 640Mb/s is about as much as you can reasonably expect (and this ties in with what journalists have found)

So can you get just as fast speed with 4G+? Well possibly, EE also supports up to 40MHz of 4G+ bandwidth for up to 4 channels and spectral density should be fairly similar. The two reasons why journalists aren’t getting high speed 4G+ but are getting high speed 5G is because more devices are connected to the 4G+ network than the 5G network and the connection to the base station is upgraded from a 1Gb/s connection for 4G+ to a 10Gb/s connection for 5G.

Speculating about Speculative Execution

A couple of days ago there were rumours swirling about a proposed change to the way the Linux operating systems handles memory. Today we had the first confirmation that there really is a problem. Intel released a press release telling us that “software analysis methods … have the potential to improperly gather sensitive data from computing devices that are operating as designed” however they haven’t released the full details yet. We will most likely see a full disclosure early next week.

In the mean time, we can have a go at speculating what the issue might be. Intel has given us some cryptic hints: that the vulnerability is not unique to Intel products and that its not really a flaw at all. Essentially they are telling us that the processor is working as designed but the design was flawed from a security perspective.

Lets look at the other evidence, there are fixes in the works for Linux for both ARM CPUs and Intel CPUs, Microsoft and Apple have also patched their systems with similar code. Both relate to something called KAISER which stands for Kernel Address Isolation to have Side-channels Efficiently Removed although this has now been renamed KPTI or Kernel Page-Table Isolation. Essentially it relates to a paper written in early 2017 about how newly invented side channel attacks can be used to mitigate a common security defence used by operating systems called ASLR or Address Space Layout Randomisation.

ASLR is a technique that is used to prevent memory corruption vulnerabilities (which are not particularly uncommon) from being used to fully exploit a device (for example through privilege escalation). Essentially it moves around important code randomly within the memory space of the device in order to prevent an attacker from knowing where it is.

Whilst ASLR certainly helps secure a system, it is well known that it is a relatively weak protection. In fact ASLR was only properly implemented in the Linux kernel in 2014. So why the big deal around finding out that something we knew was an ineffective security defence? And why the sudden rush to get it fixed given we knew all this almost a year ago?

The reason is probably because another more serious vulnerability was found which is in some ways related to the side channels used to get around ASLR. The vulnerability was probably found as a result of some research produced by Anders Fogh (who has worked with with Michael Schwarz and Daniel Gruss, the authors of the KAISER paper).

At this point in my writing I looked up Michael Schwarz on twitter and found out he had just published details of the vulnerability so I’m going to check if my speculation was right!

And of course the vulnerability (actually one of two) is called Spectre so my speculation about speculation was right. And you can read about it here.

Brexit: Why I Couldn’t Choose Which Way to Vote

I wrote the following almost exactly a year ago, just before the referendum on Britain’s membership of the European Union:

I can’t choose which way to vote in the upcoming EU referendum and here is why. The question which will be on the ballot paper doesn’t give British citizens much say over the future relationship between Britain, the EU, wider Europe and the rest of the world.

Here’s my analogy: imagine your family wants a new car. The family wants everyone’s input on what the new car should be but there are too many options. The head of the family decides to arrange a vote, the vote is for either a petrol car or a diesel car. Based on the outcome of this vote, the head of the family will go out and negotiate with a car dealer to buy a car.

In this situation the head of the family clearly has far more power than the rest of the family. They can vote for what they think will be a sporty petrol car and the head of the family can go out and get a petrol powered Toyota Prius. Or they could vote for a small economical diesel and get a huge diesel powered off road vehicle.

The same applies to the EU vote. A huge proportion of the country might vote to leave on the basis of reducing migration and having more democracy only to find that the government negotiates an EU exit which means we will have to keep the freedom of movement and pass EU laws without having as much say in them.

Another large proportion of the country might vote to remain in the EU on the basis of having peace, collaboration and free movement to Europe only to find that an escalating migrant crisis and an unwillingness to accept refugees means that countries start closing their borders, conflicts break out between neighbouring European states and budgets are cut for the funding of collaborative projects.

I think we can safely say that less will change if we remain in the EU than if we leave. But the EU isn’t perfect, if we leave the EU we could end up with a much better relationship with the rest of the EU states and the wider world.

I want Britain to have a more open relationship with the rest of the world. We should choose to have freedom of movement between more countries than just those in the EU. We should have more trade with developing countries and allow them low cost access to our markets.

Going back to my analogy, I want the Toyota Prius whereas most of the other people in my family voting “petrol” are voting on the basis that they will get a powerful sports car.

So maybe I should vote depending on how I think the head of the family, or in Britain’s case the government’s will choose to interpret the vote.

This is where it gets interesting because an overwhelming number of MPs support remaining in the EU. Even in the Governments conservative party about 55% support remaining in the EU. Any way you shuffle the numbers (even factoring in another general election), there won’t be a government which supports leaving the EU after the referendum. So we will end up in the strange position of having a pro-EU government having to negotiate to leave the EU.

Even a majority of ministers supporting the leave campaign would still support the freedom of movement and an ongoing trade agreement with the EU.

A vote for Leave would put Britain into a political, legal, constitutional  and economic mess. Constitutionally, the government must act on the outcome of the referendum but exactly how far the government goes in disassociating itself from the EU would depend on many factors. Will David Cameron resign? Will Jeremy Corbyn be forced to resign? Will there be another general election? Will we have another referendum on the terms of the negotiation.

The repealing of EU laws could cause huge amounts of legal uncertainty. Businesses generally don’t like uncertainty so the country could easily go into a period of recession as everyone works out what the exit means for them. Civil servants, lawyers and business strategists will likely be tied up for many years working out how best to proceed.

It would be foolish however to just look at the short term effects. I’m hopefully going to be around for another few decades. A few years of economic and political turmoil now could be better than a future exit from the EU when there are even more EU laws and even more ties to the rest of Europe.

The EU is actually incredibly democratic. It has proportionally represented members of parliament (our MEPs are more representative of British views than our Westminster MPs). All positions in the EU are elected, some would argue they are elected indirectly but that is the same as a lot of positions in almost every country’s political system. Our prime minister is indirectly elected for example.

The EU is very much a one size fits all approach though. The free movement of workers may have contributed to a more multi-cultural and inclusive society but it has also led to the inequality of nations. In Greece, migration to other EU countries has hugely increased especially amongst skilled young people. It simply doesn’t make sense for young Greeks to work in their home country because of the low cost of being employed elsewhere in Europe and getting paid significantly more.

Most people don’t know that the largest proportion (about a third) of the EU budget goes to subsidising the agricultural industry through the Common Agricultural Policy (CAP). It is a one size fits all policy which applies to all EU countries. With a scheme which is tailored to British needs we could reduce the cost of food and increase environmental benefits.

The EU is generally observed to favour big businesses. They can afford to lobby the EU directly whereas smaller UK businesses typically have limited resources to influence European policy but have some influence on local policy making through local MPs and council decisions.

In the least exiting situation. Britain could continue to have access to the European market, would keep and adopt almost all EU legislation, would make almost the same contribution to the EU budget and have some limited influence on EU legislation but would not be under the jurisdiction of the EU court of justice. In this scenario Britain would retain almost all collaborative projects and common policies with Europe but would be able to reject some EU laws at the expense of having less say in their creation.

It seems a shame that a whole year later I’m still in the same position. There is still no consensus on what leaving the EU means. Whilst Brexit hasn’t really even started, one change is that slowly the people of Britain are understanding what the EU is and what the real impact of leaving it will be.

Perhaps in another year, when the negotiations are well under way, there will finally be clarity on what leaving the EU actually means. Only then will it be possible for me to make a meaningful vote on whether we should stay or go. And maybe, as unlikely as it is, we might get another vote.

Panning shots are easy

It’s been some time since I last wrote a blog post. A couple of weeks ago I went to Marrakesh, whilst I was out there I tried to take some panning shots of the Moroccan traffic.


Panning shots are where you take the photo whilst rotating the camera to track a moving object. This should blur out the background of the shot whilst keeping the moving object in focus. The shot is great for giving a sense of movement and dynamism whilst keeping the detail of the moving object.

The key for getting a good panning shot is patience and plenty of subjects. You don’t need a special camera, simply one where you can control the shutter speed. The best way to practise panning is to find a seat set back from a busy road. Depending on the speed of the traffic and the distance away from the camera you will need to choose a shutter speed between 1/5 to 1/50th of a second. There is no simple rule, you will need to experiment with different shutter speeds to get the best outcome.

In bright sunlight, such as in Morocco you might need to use a filter to prevent saturating the camera sensor at such slow shutter speeds. I use a very cheap variable neutral density filter which allows me to get a 1/10th of a second shutter speed with an aperture of f/8 in bright light. If you can’t get hold of a cheap folder you can simply wait for the light levels to go down.

Following a moving target is the hardest part of taking this type of shot. Some cameras will help you by giving you panning  image stabilisation. You need to rotate the camera steadily, to do this you need to start tracking the subject when it is as far away as possible. Make sure you are smoothly tracking it, before pressing the shutter and try not to press the shutter with too much force such that you introduce camera shake. Some photographers use a tripod or monopod to get the smoothest pan however a tripod head with a smooth movement can be quite expensive.

To get the whole of the subject in focus, you need to press the shutter release when it is travelling perpendicular to the camera lens. If the object is moving at an angle to the lens you will likely get some parts in focus and others out of focus. You can see this effect in the photo below.

The reality is that luck plays a huge part even amongst experienced photographers. I took about 100 photos to get the 5 images I’ve posted here. It’s quite likely that 90% of your photos will be blurry but with enough patience you should get some great shots.




Disappearing Time

Time seems to disappear so quickly and I always have so many things to do. I get ready for work, go to work, come back from work, go swimming, go shopping, cook, eat and wash up dinner, watch the news, write an entry on my blog, read a bit of my book and go to bed.

I seem to need a lot more time. I’d like some time to work on my side projects, some time to make and write Christmas cards. What I’m probably not very good at is prioritising. I’m writing this blog post when I could be doing something more important. Never mind, there’s always tomorrow!

Fake owls

Today whilst I was out I thought I saw an owl. The owl appeared to be sat on top of some high voltage wires in the railway substation. I took a couple of photos with my phone, a train came past, and the owl hardly moved. I got a bit suspicious so I went on Google Street View to see what the owl was actually sitting on and this is what I saw:

The owl is of course a complete fake. It’s there to deter other birds from sitting on the wires in the substation which could lead to them shorting out the power.

In my defence it was getting quite dark so I couldn’t see the fake owl very clearly. Next time I’ll just look out for the foxes, they’re definitely real.

Training Schedule

I’m starting to get back to fitness. I’m able to run at a moderate pace for 10 miles but I’m still lacking my old strength and endurance. I need a proper training schedule to ensure I’m going to be ready for my marathon in just 4 months time.

Here’s what my schedule looks like:

Monday: Swimming for 1 hour, running every day is not a good idea and a swim is great for stretching and endurance.

Tuesday: Reps run with Worthing Harriers, this is typically hills, fartleks or some other sort of reps session.

Wednesday: Rest day, I will probably use this for a shorter run as I get into 2016. Use Wednesday to do strength work at home working on the core and upper body.

Thursday: Moderately long run with Worthing Harriers, this is typically a 8-11 mile run around the streets of Worthing.

Friday: Long afternoon run if possible, I get the afternoon off work on a Friday so I need to try and use the light in the afternoon to go for a run going into the countryside.

Saturday: Race (if there is one) otherwise short tempo run. Need to run 10+ miles at race pace starting around 8 minute miling upping to 6:30 miling by March time.

Sunday: Morning long run with Worthing Harriers, I need to start around 12 miles, upping this to 20+ miles in March.

That’s my plan and I will try to stick to it as close as possible from now on (eek).

Level crossings part 2

Two weeks ago, I discussed an outline of how to predict when then level crossing near my flat is open or closed. I made an aside that I could use a camera to detect when the crossing is open or closed.

I’ve realised that I have an old tablet that will work great for this purpose. I can put it on the windowsill plugged into it’s charger and use it to report back on the level crossing.

Now I just need to implement the technology to make that happen. I’ve got two choices here: it’s a windows based tablet so I can create an executable using something like openCV or I can create a browser based application.

A while back I started doing a project which relied on HTML5 to do some basic image recognition. I’ve decided I’m going to try that approach again because it makes my solution so easy to port. If I get a new device, as long as it runs the Chrome web browser then it should be able to do the exact same task. The development also requires only two really simple tools, the browser and a text editor to write code in.

Here’s the plan of attack:

  1. I’m going to create a page with a HTML5 video element and a 2D canvas element
  2. The video from the device’s camera is set to be the source of the video
  3. At fixed time periods the video is copied into the canvas
  4. Once an image is loaded into the canvas, the individual pixels can be read
  5. The pixels are read in an intelligent way to determine if the level crossing lights are flashing or not.
  6. This data is sent to the server

The first four steps are fairly trivial to implement once you know what you are doing. The fifth step is where the magic happens.

This image recognition task is actually quite simple. Determining if a light is on or off is a simple task. What makes the task more difficult is the fact that the lights are sufficiently far away from my flat that they are quite small, they are also right behind a set of traffic lights and the lighting conditions change dramatically throughout the day.

My first approach is to try to resolve the barrier lights from the traffic lights. Its just about possible with the camera on the tablet. I simply need to compare the red value of the point where the lights are against the red value of another reference point just to the side of the barrier lights. I need to make sure I choose this reference point such that it is always darker than the lights no matter what the illumination conditions.

Now I just need to set the camera very still on my windowsill!

I set the webpage to requests a PHP page whenever the state of the crossing changes. The PHP page updates a MySQL database. I’ve then created another simple PHP page which reads the data from the database and displays a pretty graph. In my third post I’ll report on my data findings.


It’s the first of December so it’s time to get out the advent calendar. I’m not a huge fan of the “traditional” advent calendar. What’s the point of tiny poor quality chocolates? If I wanted the chocolate I wouldn’t buy it in over-priced calendar form.

I do have a more contemporary advent calendar. I’m participating in the Advent of Code. Instead of chocolates, two puzzles are served up each day which must be solved using code. The challenges are all Christmas themed and are (at least so far) fairly easy and fun. Even a programming beginner could have a go, it’s a great way to get started.

Great cities

Yesterday I went to a talk about the mathematics of relationships and why people congregate in cities. The speaker argued that the average probability of two people having a relationship (any sort of relationships: client, employer, lover, friend…) is inversely promotional to the number of people in their social sphere. His definition of a social sphere was the people that are located in the area which you can travel to in less time than the other person.

The main point that came out of the talk is that distance in terms of time is more important than real distance. The best cities are those with a good transport network which allow many opportunities for relationships.

The talk explained why over 50 million people migrate to cities each year. Cities offer so many more potential relationships than the surrounding population.

I’d like to look into this topic in closer detail but I’m on holiday at the moment.