HMS Belfast: destroying the destroyer

7 May

by Paul Curzon, Queen Mary University of London

HMS Belfast

On the South Bank of the Thames in the centre of London lies the HMSBelfast. Now a museum ship, it once took part in one of the most significant sea battles of the Second World War. It fought the Scharnhorst in the last great sea battle based on the power of great guns. The Belfast needed more than just brilliant naval tactics to stand a chance. It needed help from computer science and electronic engineering too. In fact, without some brilliant computer science the battle would never have been fought in the first place. It came about because of the work of the code crackers at Bletchley Park.

Getting supplies across the Atlantic and then round to Russia was critical to both the British and Russian’s survival. By 1943 the threat of submarines had been countered. The battleship Tirpitz had also been disabled. However, the formidable battle cruiser Scharnhorst was left and it was the scourge of the Allied convoys. It sank 11 supply ships in one operation early in 1941. In another, it destroyed a weather station on Spitzbergen island that the Allies used to decide when convoys should set off.

By Christmas 1943 something had to be done about the Scharnhorst, but how to catch it, never mind stop it? A trap was needed. A pair of convoys going to and from Russia were a potential bait. The Nazis knew the target was there for the taking: the Scharnhorst was in a nearby port. Would they take that bait though, and how could the British battle ships be in the right place at the right time to not only stop it, but destroy it?

The Allies had an ace up their sleeve. Computer Science. By this point in the war a top secret team at Bletchley Park had worked out how to crack the Enigma encryption machine that was used to send coded messages by the German Navy. It was always easy to listen in to radio broadcasts, you just needed receivers in the right places, but if the messages were in code that didn’t help. You had to crack the day’s code to know what they were saying. Based on an improved approach, originally worked out by Polish mathematicians, the Brits could do it using special machines that were precursors to the first electronic computers. They intercepted messages that told them that Scharnhorst was preparing to leave. It was taking the bait.

The British had two groups of ships. The Belfast, the Norfolk and the Sheffield were coming from Russia protecting the returning convoy. The HMS Duke of York was tracking the new convoy heading to Russia. Both were keeping their distance so the convoys looked unprotected. They needed to know when and where the Scharnhorst would attack. Bletchley Park were listening in to everything though, and doing it so well they were reading the messages almost as soon as the Germans. At 2am on Boxing Day morning the Belfast got the message from Admiralty Head quarters that SCHARNHORST PROBABLY SAILED AT 1800 25 DECEMBER. A further radio signal from the Scharnhorst asking for a weather report allowed the spies to work out exactly where the ship was by picking up the signal from different listening stations and triangulating: drawing a line on a map from each station in the direction the radio signal came from. The point they meet is the ship’s location. This is an example of meta-data (information about a message rather than the message itself) giving vital information away. The spies had done their job. It was enough to tell Vice Admiral Burnett on the Belfast where the Scharnhorst was aiming to attack the convoys. They could lie in wait. At this point, electronic engineering mattered. The Belfast had better radar than the Scharnhorst. They detected its approach without the Scharnhorst having any idea they were there. The first the Captain of the Scharnhorst knew was when they were hit by shells from the Norfolk. The Belfast ended up out of position at the critical point though and couldn’t join in. The faster Scharnhorst turned tail and ran. The Brits had had their chance and blown it!

Burnett now needed luck and intuition. He guessed the Scharnhorst would try another attack on the convoy. They took up a new waiting position rather than actively trying to find the Scharnhorst as others wanted them to do. By midday the radar picked it up again. The trap was reset, though this time the initial surprise was lost. An all out battle began, with radar helping once again, this time as a way to aim shells even when the enemy wasn’t in sight. Having failed to reach the convoy undetected a second time the Scharnhorst retreated as the battle continued. What they didn’t know was that they were retreating deeper into the trap: heading directly towards the waiting Duke of York. The chasing Belfast stopped firing and dropped back, making the Scharnhorst crew think they were safe. In fact, they were still being followed and tracked by radar once more, though only by the Belfast as the other ships had actually been partially disabled. Had the Scharnhorst known, they could have just stopped and taken out the Belfast. After several hours of silent shadowing, the Belfast picked up the Duke of York on the radar, and were able to communicate with them. The Scharnhorst’s radar had been crippled in the battle and thought it was alone.

The Belfast fired shells that lit up the sky behind the Scharnhorst as seen from the Duke of York, then largely watched the battle. Luck was on their side: the Scharnhorst was crippled and then sunk by torpedoes. Over a thousand German sailors sadly died. The crew of the Belfast were well aware that it could just as easily have been them, sealed in to a giant metal coffin, as it sank, and so held a memorial for the dead Germans afterwards.

The Belfast didn’t fire the torpedoes that finally sank the Scharnhorst and was not the key player in the final battle. However, it was the one that was in the right place to save the convoy, thanks to the Enigma decrypts combined with the Vice Admiral’s intuition. It was also the one that pushed the Scharnhorst into the deadly trap, with its superior radar then giving it the advantage.

It is easy to under-estimate the importance of the Bletchley Park team to the war, but they repeatedly made the difference, as with the Scharnhorst, making Allied commanders look amazing. It is much easier to be amazing when you know everything the other side says! The Scharnhorst is just one example of how Computer Science and Electronic Engineering help win wars, and here, in the long run at least, save lives. Today having secure systems matters to everyone not just to those waging war. We rely on them for our bank system, our elections, as well as for our everyday privacy, whether from hacking newspapers or keeping our health records secret from ruthless companies wanting to exploit us. Cyber security matters.

More on …

Machines Inventing Musical Instruments

1 May

by Paul Curzon, Queen Mary University of London

based on a 2016 talk by Rebecca Fiebrink

Gesturing hands copyright www.istock.com 1876387

Machine Learning is the technology driving driverless cars, recognising faces in your photo collection and more, but how could it help machines invent new instruments? Rebecca Fiebrink of Goldsmiths, University of London is finding out.

Rebecca is helping composers and instrument builders to design new musical instruments and giving them new ways to perform. Her work has also shown that machine learning provides an alternative to programming as a way to quickly turn design ideas into prototypes that can be tested.

Suppose you want to create a new drum machine-based musical instrument that is controlled by the wave of a hand: perhaps a fist means one beat, whereas waggling your fingers brings in a different beat. To program a prototype of your idea, you would need to write code that could recognize all the different hand gestures, perhaps based on a video feed. You would then have some kind of decision code that chose the appropriate beat. The second part is not too hard, perhaps, but writing code to recognize specific gestures in video is a lot harder, needing sophisticated programming skills. Rebecca wants even young children to be able to do it!

How can machine learning help? Rebecca has developed a machine learning program with a difference. It takes sensor input – sound, video, in fact just about any kind of sensor you can imagine. It then watches, listens…senses what is happening and learns to associate what it senses with different actions it should take. With the drum machine example, you would first select one of the kinds of beats. You then make the gesture that should trigger it: a fist perhaps. You do that a few times so it can learn what a fist looks like. It learns that the patterns it is sensing are to be linked with the beat you selected. Then you select the next beat and show it the next gesture – waggling your fingers – until it has seen enough examples. You keep doing this with each different gesture you want to control the instrument. In just a few minutes you have a working machine to try. It is learning by example how the instrument you are wanting works. You can try it, and then adjust it by showing it new examples if it doesn’t quite do what you want.

It is learning by example how the instrument you are wanting works.

Rebecca realised that this approach of learning by example gives a really powerful new way to support creativity: to help designers design. In the traditional ways machine learning is used, you start with lots of examples of the things that you want it to recognize – lots of pictures of cats and dogs, perhaps. You know the difference, so label all these training pictures as cats or dogs, so it knows which to form the two patterns from. Your aim is for the machine to learn the difference between cat and dog patterns so it can decide for itself when it sees new pictures.

When designing something like a new musical instrument though, you don’t actually know exactly what you want at the start. You have a general idea but will work out the specifics as you go. You tinker with the design, trying new things and keeping the ideas that work, gradually refining your thoughts about what you want as you refine the design of the instrument. The machine learning program can even help by making mistakes – it might not have learnt exactly what you were thinking but as a result makes some really exciting sound you never thought of. You can then explore that new idea.

One of Rebecca’s motivations in wanting to design new instruments is to create accessible instruments that people with a wide range of illness and disability can play. The idea is to adapt the instrument to the kinds of movement the person can actually do. The result is a tailored instrument perfect for each person. An advantage of this approach is you can turn a whole room, say, into an instrument so that every movement does something: an instrument that it’s impossible not to play. It is a play space to explore.

Playing an instrument suddenly really is just playing.

Return of the killer robot? Evil scientist?! Helpless woman?!?

30 Apr

by Paul Curzon, Queen Mary University of London

Digital blond copyright www.istock.com 439194

In an early issue of the cs4fn magazine we looked at how robots, female scientists and women generally were portrayed in 20th century science fiction movies. It wasn’t great. Robots were killers, scientists evil. Computer scientist’s were introverted and thickheaded. Women were either sexbots or helpless love interest to be rescued by the hunky male star. 1995’s film Hackers was about as good as it got. At last a woman had expert computing skills. It’s hardly surprising some girls are led to believe computing isn’t for them with a century-long conspiracy aiming to convince them their role in life is to be helpless.

As our area on women in computing shows the truth is far more interesting. Women have always played a big part in the development of modern technology. So have things improved in films? There are more films with strong action-heroine stars now, though few films pass the Bechdel test: do two women ever talk together about anything other than a man? So can we at least find any 21st century films with realistic main character roles for women as computer experts? Here goes…

1999-2003: Matrix Trilogy

Hero Neo discovers reality isn’t what it seems. It is all a virtual reality. Trinity is there to be his romantic interest – she’s been told by the Oracle that she will fall in love with the “One” (that’s him). It’s not looking good. In film 2 Neo has to save her. Oh dear. At least she is supposed to be a super-hacker famous for cracking an uncrackable database. Oh well.

2009: The Girl With the Dragon Tattoo

This is the story of super-hacker Lisbeth Salander. Both emotionally and sexually abused as a child she looks after herself, and that includes teaching herself to be an expert with computers. She uses her immense skills to get what she wants. She is cool and clever and absolutely not willing to let the men treat her as a victim. Wonderful.

2014: Captain America: The Winter Soldier

This film is all about a male hunk, so it’s not looking good, but then early on we see Agent Natasha Romanoff, (also known as superheroine the Black Widow). She is the brains to Captain America’s brawn and from the start she is clearly the expert with computers. While Captain America beats people up, her mission is to collect data. Let’s hope she gets her own film series!

2015: Star Wars: Episode VII – the Force Awakens

Rey is a scavenger with engineering skills. She is very smart, and can look after herself without expecting men to save her. She’s not a hacker! Instead, she creates and mends things. She repurposes parts she finds on wrecked spaceships to sell to survive. She learnt her engineering skills tinkering in old ships and fixes the Millennium Falcon’s electro-mechanical problems. She is even the main character of the whole film!

 

There are plenty of moronic films, made by men who can’t portray women in remotely realistic ways, but at least things are a bit better than they were last century. The women are already here in the real world. They are slowly getting there in the movies. Let’s just hope the trend speeds up, and we have more female leads who create things, like the real female computer scientists.

Email your reviews of female characters in science fiction films (good or bad) to cs4fn@eecs.qmul.ac.uk

Who invented Morse code?

29 Apr

by Paul Curzon, Queen Mary University of London

Morse code tapper: www.istock.com 877875

Who invented Morse code? Silly question, surely! Samuel Morse, of course. He is one of the most celebrated inventors on the planet as a result. Morse code helped revolutionise global communications. It was part of the reason the telegraph made fast, world-wide communication a practical reality. Morse did invent a code to use for the telegraph, but not Morse code. His code was, by comparison, a poor, inflexible solution. He was a great businessman, focussed on making his dream a reality, but perhaps not so good at computational thinking! The code that bears his name was largely invented by his partner Alfred Vail.

Samuel Morse was originally a painter. However, his life changed when his wife died suddenly. He was away doing a portrait commission at the time. On hearing of his wife’s illness he rushed home, but the message, delivered by a horse rider had taken too long to reach him and she died and was buried before he got there. He dedicated his life to giving the world a better way of communicating as a result. Several different people were working on the idea of a way to send messages by electricity over wires, but no one had really come up with a usable, practical system. The physics had largely been sorted, but the engineering was still lacking.

Morse came up with a basic version of an electrical telegraph system and he demonstrated it. Alfred Vail saw the demonstration and persuaded Morse to take him on as a partner. His father built a famous ironworks, and so he had worked as a machinist. He improved Morse’s system enormously including making the tapping machine used to send messages.

He wasn’t just good at engineering though. He was good at computational thinking, so he also worked on the code used for sending messages. Having a machine that can send taps down a wire is no use unless you can also invent a simple, easy to use algorithm that turns words into those taps, and back again once it arrives. Morse came up with a code based on words not letters. It was a variation of the system already used by semaphore operators. It involved a code book: essentially a list of words. Each word in the book was given a number. A second code turned numbers in to taps – in to dots and dashes. The trouble with this system is it is not very general. If the word you want to send isn’t in the code book you are stuffed! To cover every possibility it has to be the size of a dictionary, with every word numbered. But that would make it very slow to use. Vail came up with a version where the dots and dashes represented letters instead of numbers, allowing any message to be sent letter by letter.

He also realised that some letters are more common than others. He therefore included the results of what we now call “frequency analysis” to make the system faster, working out the order of letters based on how common they are. He found a simple way to do it. He went to his local newspaper offices! To print a page of text, printing presses used metal letters called movable type. Each page was built up out of the individual metal letters slotted in to place. Vail realised that the more common a letter was, the more often it appeared on any page, and the more metal versions the newspaper office would therefore need if they wasn’t to keep running out of the right letters before the page was done. He therefore counted how many of each “movable type” letter the newspaper printers had in their trays. He gave the letters that were most common the shortest codes. So E, for example, is just a single dot as it is the most common letter in American English. T, which is also common, is a single dash. It is this kind of attention to detail that made Morse code so successful. Vail was really good at computational thinking!

Morse and Vail worked really well as a team, though Morse then took all the credit because the original idea to solve the problem had been his, and their agreement meant the main rights were with Morse. They almost certainly worked together to some extent on everything to do with the telegraph. It is the small details that meant their version of the telegraph was the one that took over the world though and that was largely down to Vail. Morse maybe the famous one but the invention of the telegraph needed them both working together.

More on …

Cyber Security at the Movies: Guardians of the Galaxy (Fail Secure security)

28 Apr

by Paul Curzon, Queen Mary University of London

[Spoiler Alert]

Guardians of the Galaxy  Poster

If you are so power hungry you can’t stand the idea of any opposition; if you want to make a grab for total power, so decide to crush everyone in your way, then you might want to think about the security of your power supply first. Luckily, all would-be dictators who crush everyone who gets in their way as they march towards total domination of the galaxy, tend to be very naive about cyber-security.

Take Ronan the Accuser in the original Guardian of the Galaxy film. He’s a villain with a religious streak, whose belief that strength is virtue and weakness is sin leads to his totally corrupted morality. To cut to the guts of the story he manages to get the “Infinity Stone” that gives unimaginable power to its owner. With it he can destroy anyone who gets in his way so sets out to do so.

Luckily for the Galaxy, good-guy Peter Quill, or Star-Lord as he wants to be known, and his fellow Guardians have a plan. More to the point they have Gamora. She is an assassin originally sent to kill Quill, but who changes sides early on. She is an insider who knows how Ronan’s security system works, and it has a flaw: its big, heavy security doors into his control room.


Security Lesson 1. It should still be secure even when the other side know everything about how it works. If your security relies on no one knowing, its almost certainly bad security!


Once inside his ship, to get to Ronan the Guardians will need to get through those big heavy security doors. Now once upon a time big, heavy doors were locked and barred with big, heavy bolts. Even in Roman times you needed a battering ram to get in to a besieged city if they had shut the doors before you got there. Nowadays, how ever big and heavy the door, you may just need some cyber skills to get in if the person designing it didn’t think it through.

Electromagnetic locks are used all over the place and they give some big advantages, such as the fact that they mean you can program who is and isn’t allowed entry. Want to keep someone out – you can just cancel their keycard in the system. They are held locked by electromagnets: magnets that are switched on and off using an electric current. That means computers can control them. As the designer of an electromagnetic lock you have a choice, though. You can make them either “fail safe” or “fail secure”. With a fail safe lock, when the power goes, the doors automatically unlock. With fail secure, instead they lock. Its just a matter of whether the magnet is holding the door open or closed. Which you choose when designing the lock depends on your priorities.

Fail safe is a good idea, for example, if you want people to be able to escape in an emergency. If a fire cuts the electricity you want everyone to still be able to get out, not be locked in with no chance of escape. Fail secure on the other hand is good if you don’t want thieves to be able to get in just by cutting the power. The magnets hold the bolts open, so when the power goes, the spring shut.


Security Lesson 2. If you want the important things to stay secure, you need a fail secure system.


This is Ronan’s problem. Zamora knows that if you cut the power supply then the doors preventing attackers getting to him just open! He needed a fail secure door, but instead had a fail safe one installed. On such small things are galaxies won and lost! All Zamora has to do is cut the power and they can get to him. This of course leads to the next flaw in his security system. It wouldn’t have mattered if the power supply was on the secure side of that door, but it wasn’t. Ronan locks himself in and Zamora can cut the power from the outside … Dhurr!

There is one last thing that could have saved Ronan. It needed an uninterruptible power supply.


Security Lesson 3. If your system is reliant on the power supply, whether a door, your data, your control system or your life-support system, then it should keep going even if the power is switched off.


After all, what if the space ships cleaners (you never see them but they must be there somewhere!) unplug the door lock by mistake just because they need somewhere to plug in the hoover.

The solution is simple: use an “uninterruptible power supply”. They are just very fast electricity storage systems that immediately and automatically take over if the main power cuts out. The biggest on Earth keeps the power going for a whole city in Alaska (you do not want to lose the power running your heating mid-winter if you live in Alaska!). Had Ronan’s doors had a similar system, the doors wouldn’t have just opened as the power would not have been cut off.It’s always the small details that matter in cyber security (and in successfully destroying your enemies and so ruling the universe). As with all computational thinking, you have to think about everything in advance. If you don’t look after your power supply, then you may well lose all your power over the galaxy too (and your life)!


More on …