47
Evolving Custom Communication Protocols by Wes Faler of Part-Time Scientists for 28C3, Berlin Germany, 2011 [email protected]

Evolving Custom Communication Protocols

Embed Size (px)

DESCRIPTION

Presentation from 28C3 in Berlin, Germany December 2011. Automated creation of communication protocols using Cartesian Genetic Programming.

Citation preview

Page 1: Evolving Custom Communication Protocols

Evolving Custom Communication Protocols

by Wes Faler of Part-Time Scientistsfor 28C3, Berlin Germany, 2011

[email protected]

Page 2: Evolving Custom Communication Protocols

<presentation>

Why

What

How

Code and Details

Results

Your turn!

Page 3: Evolving Custom Communication Protocols

Why

Part-Time Scientists needed a communication protocol between our Earth stations and our rover on the moon.

Page 4: Evolving Custom Communication Protocols

What

Given:◦ A fixed set of hardware components for a packet transmitter and receiver.

◦ Video and telemetry streams that must go from the moon to Earth.

◦ A stream of commands that must go from Earth to the rover on the moon.

Create:◦ A finite state machine that provides the network and application layer control of a transceiver used on both earth and the moon.

Page 5: Evolving Custom Communication Protocols

What - Complications

Must be a published open protocol.

Cannot use encryption.

Long latency.

High packet cost and value.

Bandwidth is limited and saturated.

May tunnel through another protocol.

TCP/IP is not an option.

Page 6: Evolving Custom Communication Protocols

Easy as 1…

Page 7: Evolving Custom Communication Protocols

Easy as 1…2…

Create parameterized algorithm

One-at-time simulation

Page 8: Evolving Custom Communication Protocols

Easy as 1…2…3…

Parameter sweep

int driver_movesPerTransaction[] = { 1, 20 };int driver_wheelTicksPerCommand[] = { 512, 4096 };int driver_commandsPerPacket[] = { 1, 25 };int driver_moveCommandsPerCameraCommand[] = { 0, 10 };float earth_packetTimeout[] = { 5, 30 };int earth_maxAllowedBacklogCount[] = { 10 };float burst_upstreamBurstErrorChance[] = { 0, 0.05 };float burst_downstreamBurstErrorChance[] = { 0, 0.05 };float rover_naggleDuration[] = { 0.5 };int rover_packetQueueSize[] = { 10, 0 };int rover_shouldFinishMoveQueueBeforeCommRecovery[] = { 1, 0 };float rover_commRecoveryDuration[] = { 5, 30 };float rover_moveCommandCommOutageChance[] = { 0.01, 0 };float rover_steerCommandCommOutageChance[] = { 0.01, 0 };

Page 9: Evolving Custom Communication Protocols

Easy as 1…2…3…4.

GPU

Before: 1 simulation/second

Port unoptimized C++ code to GPU◦ Least programming effort possible

◦ Just for parameter sweeps

After: 700 seconds for 5200 simulations◦ 7.4 simulations/second

Run a million simulations

Page 10: Evolving Custom Communication Protocols

Results – Distance Travelled

Page 11: Evolving Custom Communication Protocols

Just a few small changes…

Page 12: Evolving Custom Communication Protocols

What, rev.2

Given:◦ A fixed set of hardware components for a packet

transmitter and receiver.

◦ Video and telemetry streams that must go from the moon to Earth.

◦ A stream of commands that must go from Earth to the rover on the moon.

◦ Changing requirements from stakeholders.

While(!Launched yet)◦ Create: A finite state machine that provides the network and

application layer control.

Page 13: Evolving Custom Communication Protocols

Can you pass the data?

http://xkcd.com/974/“The General Problem”

Page 14: Evolving Custom Communication Protocols

Invention – GP

Given:◦ A partial existing system structure

Inputs

Output(s)

Formula structure

◦ Test cases

◦ Constraints

Create:◦ The optimal set of parameters

◦ An equation or algorithm

Page 15: Evolving Custom Communication Protocols

Invention - GP

Page 16: Evolving Custom Communication Protocols

How – CGP

Cartesian Genetic Programming (CGP)◦ Generates equations like circuits.◦ Parallelizable results.◦ FPGA friendly.◦ Operators for simple math and logic. Constant

Add, Subtract, Negative

Add Constant, Subtract Constant

NOP, !, &&, ||,

> Constant, >= Constant,== Constant

>, >=, ==

Page 17: Evolving Custom Communication Protocols

How – CGP

Make a random “circuit”.

+

*

+

&&

-

>

Page 18: Evolving Custom Communication Protocols

How – CGP

Score the circuit.

+

*

+

&&

-

> Test #1: TerribleTest #2: TerribleTest #3: Terrible

Score: Terrible*3

Page 19: Evolving Custom Communication Protocols

How – CGP

Make random changes and rescore.

+

*

+

+

-

/ Test #1: TerribleTest #2: Terrible-4Test #3: Terrible

Score: Terrible*3-4

Page 20: Evolving Custom Communication Protocols

How - CGP

Start with 1 parent.

500

Page 21: Evolving Custom Communication Protocols

How - CGP

Start with 1 parent.

Make mutant children.

500 500

Page 22: Evolving Custom Communication Protocols

How - CGP

Start with 1 parent.

Make mutant children.

Score everyone.

500 500

500

725

Page 23: Evolving Custom Communication Protocols

How - CGP

Start with 1 parent.

Make mutant children.

Score everyone.

Promote the best child that isn’t worse than the parent.◦ Must promote anything equal to the parent!

500 500

500

725

500

Page 24: Evolving Custom Communication Protocols

How - CGP

Start with 1 parent.

Make mutant children.

Score everyone.

Promote the best child that isn’t worse than the parent.◦ Must promote anything equal to the parent!

500 500

500

725

500

85

97

85

Page 25: Evolving Custom Communication Protocols

Terminology

Ni

No

Nr

Nc

+Operator typeConstantInput indexes

Gene

Page 26: Evolving Custom Communication Protocols

Runtime Optimization

+

*

+

&&

-

>

Page 27: Evolving Custom Communication Protocols

Code – CGP Core

Individual

Executor and Optimizer

Mutator

Population

Support◦ Threadsafe, GPU-friendly random numbers

◦ Save, Load

◦ Images

Page 28: Evolving Custom Communication Protocols

How – Attacker’s Goals

Mission Enders◦ Make rover execute attacker’s commands

◦ Prevent rover execution of real commands

◦ Prevent acceptance of video data

High Risk◦ Make mission control accept false telemetry

◦ Delay rover execution of real commands

Page 29: Evolving Custom Communication Protocols

How – Simulation structure

Discrete Event System simulation◦ Priority queue of events ordered by time

◦ Set of Actors creating and handling events

Packet is control flag array and payload

Outer Space as random Actor◦ Lose

◦ Replay

◦ Echo

◦ Corrupt

Page 30: Evolving Custom Communication Protocols

How – Simulation structure

Transceiver as set of Actors◦ Data Ready To Transmit

◦ Data Received

◦ Packet Expired in Transmit History

Attacker as Actor

Actors == Chromosomes◦ Scored separately

◦ Promoted separately

◦ Combines partial solutions for next generation

Page 31: Evolving Custom Communication Protocols

How - Attacker

Coevolved

Full knowledge of packet structure

Can crack private keys

Sees all packets

Cannot prevent packet delivery◦ No “man in the middle” attacks

Able to send to anyone

Risk when transmitting

Page 32: Evolving Custom Communication Protocols

How – Attacker Structure

Stateful and large for complex strategy

Single Chromosome in feedback loop

Packet In

Packet Out

TimerAttacker

State

Page 33: Evolving Custom Communication Protocols

How - Fitness

Generational fitness Best fitness Validated fitness

Penalties/Rewards◦ Accepted bad signature◦ Accepted attacker packet◦ Accepted unknown data◦ Accepted data more than once◦ Never accepted data◦ Accepted data with wrong data type◦ Command packet accepted successfully

Page 34: Evolving Custom Communication Protocols

Tip – Validate Fitness

R² = 0.8807

Spearman's Rank (p) = 0.9188

0

100000

200000

300000

400000

500000

600000

700000

0 50000 100000 150000 200000 250000 300000 350000

Valid

ate

d F

itn

ess

Fitness

Validated Fitness vs. Fitness

Page 35: Evolving Custom Communication Protocols

How - Questions to answer

Can the control logic be automatically created by Cartesian Genetic Programming (CGP)?

If so, is the logic robust?◦ Can it work with poor signal quality?

◦ Can it work with an attacker?

Should the control logic be created:◦ In isolation?

◦ Considering only poor signal quality cases?

◦ Considering an attacker?

Can an attacker’s control logic be created at a faster pace than the network logic?

Page 36: Evolving Custom Communication Protocols

Code – Simulation Core

Experiment

Worlds◦ Data schedule

◦ Actors

Execution

Fitness◦ Generational fitness

◦ Best fitness

◦ Validated fitness

Page 37: Evolving Custom Communication Protocols

Can CGP make control logic?

Page 38: Evolving Custom Communication Protocols

Can CGP make control logic?

Page 39: Evolving Custom Communication Protocols

More Tips

Randomize everything!

Reduce randomness in fitness

Threadsafe random numbers

Incentivize◦ “Mute” attackers

Increase population size

Dust-off your statistics books

Page 40: Evolving Custom Communication Protocols

Population Size Effects

Population 4 Population 8

Fitness Evaluations

2x

Run time 3x

Samegenerations

Much better fitness

Same run time Equal fitness Equal fitness

Page 41: Evolving Custom Communication Protocols

Does an attacker help?

0

20000

40000

60000

80000

100000

120000

140000

0 20000 40000 60000 80000 100000 120000 140000 160000 180000 200000

Generation fitness without an attacker

fitness

bestFitness

validatedFitness

Page 42: Evolving Custom Communication Protocols

Does an attacker help?

0

10000

20000

30000

40000

50000

60000

70000

80000

90000

100000

0 20000 40000 60000 80000 100000 120000 140000 160000 180000 200000

Generation fitness with an attacker

fitness

bestFitness

validatedFitness

Page 43: Evolving Custom Communication Protocols

Does an attacker help?

Does an attacker’s presence produce a better transceiver?

No attacker With attacker

Best fitness 18316 23208

Validated fitness 134542 137494

Active genes +50%

Fitness:Generationcorrelation

Medium Near Zero

Other Fitness:Generation Medium Medium

Val. Fitness:Gen. Slope 2x

Page 44: Evolving Custom Communication Protocols

Results - Questions answered

Can the control logic be automatically created by Cartesian Genetic Programming (CGP)?

If so, is the logic robust?◦ Can it work with poor signal quality?

◦ Can it work with an attacker?

Should the control logic be created:◦ In isolation?

◦ Considering only poor signal quality cases?

◦ Considering an attacker?

Can an attacker’s control logic be created at a faster pace than the network logic?

Page 45: Evolving Custom Communication Protocols

Future

CGP on GPU

Worlds on GPU

Finer-grain Chromosomes

New “best” selection with an attacker

Islands

Freezing transceiver or attacker

Attacker detection and countermeasures

Page 46: Evolving Custom Communication Protocols

</presentation>

Danke!

<shameless recruiting ad>

◦Join us at ptscientists.com! </shameless recruiting ad>

Wes Faler of Part-Time Scientists◦ [email protected]

Page 47: Evolving Custom Communication Protocols

Resources

Code and presentation◦ http://wp.me/pGgFl-V

Julian Miller (inventor of CGP)◦ http://sites.google.com/site/julianfrancismiller/prof

essional

“Cartesian Genetic Programming” book◦ http://www.springer.com/computer/theoretical+co

mputer+science/book/978-3-642-17309-7

“Evolved to Win” e-book◦ http://www.moshesipper.com/etw/

“Communication Protocol Engineering” book by Miroslav Popovic