This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Network Decontamination using Cellular Automata
Livaniaina Hary Rakotomalala
Thesis submitted to the
Faculty of Graduate and Postdoctoral Studies
in partial fulfillment of the requirements
for the Doctorate in Philosophy (Ph.D.) degree in
Computer Science
Ottawa-Carleton Institute for Computer Science
School of Electrical Engineering and Computer Science
1.2.1. Decontamination by Mobile Agents ......................................................... 2
1.2.2. Network Topology and Graph approach .................................................. 2 1.2.3. The Cellular Automaton approach ............................................................ 3
1.3. Cellular Automata ................................................................................................. 3 1.3.1. Definition and structure ............................................................................ 3 1.3.2. Cellular Automata and network topology ................................................ 5
1.3.3. Decontamination using Cellular Automata .............................................. 6
1.4. Motivation and Pertinence .................................................................................... 7 1.5. Research Questions and Requirements ................................................................. 8
1.5.1. State of the art and challenges .................................................................. 8 1.5.2. Our research and contributions ............................................................... 10
2. Literature Review ...................................................................................................... 12 2.1. Network Decontamination and approach classification ..................................... 12
2.2. External Decontamination .................................................................................. 13 2.2.1. Graph Search and the Search Number .................................................... 13 2.2.2. Network Decontamination by Mobile Agents ........................................ 14
2.3.1. Decontamination using Cellular Automata ............................................ 17
2.3.2. 2D Cellular Automaton Neighbourhood ................................................ 17 2.3.2.1. The von Neumann neighbourhood ...................................................... 17
2.3.2.2. The Moore neighbourhood................................................................. 18 2.3.3. Basic Network Decontamination under CA ........................................... 19 2.3.3.1. Horizontal flow under the von Neumann neighbourhood .................. 19
2.3.3.2. Horizontal flow under the Moore neighbourhood ............................. 21 2.3.4. Network Decontamination under CA with Time Immunity ................... 21
2.3.4.1. Strategies under the von Neumann neighbourhood ............................ 21 2.3.4.2. Strategies under the Moore neighbourhood ........................................ 23
2.4. Theory of Cellular Automata .............................................................................. 24
2.4.3. Applications using Cellular Automata .................................................... 26 2.4.4. A selected review of simulation software ............................................... 27
3. The Model ................................................................................................................... 29 3.1. The Cellular Automaton model .......................................................................... 29
3.1.1. 2D CA as State space .............................................................................. 29 3.1.2. Network Host state as Transition State ................................................... 30 3.1.3. Decontamination algorithms as Cellular Automaton Transition Rules . 31 3.1.4. Conflicting rules and Non-determinism ................................................. 32
vi
3.2. New dimensions to the definition of a Cellular Automaton radius .................... 32
3.2.1. The Visibility Hop Vh ............................................................................. 33
3.2.2. The Contamination Distance Cd ............................................................. 33 3.2.3. Relationship between Vh and Cd ............................................................ 34
3.3. Recontamination and Immunity model .............................................................. 35 3.3.1. The contamination model ....................................................................... 35 3.3.2. The re-contamination model .................................................................. 36
3.3.3. The immunity model .............................................................................. 36 3.4. Terms and Notations ........................................................................................... 37
3.4.1. Transition state notation and representation in grayscale/color mode .... 38 3.4.2. New Neighbourhood configuration notation .......................................... 39
4. Decontamination with Visibility Hop and Contamination Distance ..................... 42 4.1. General Concept ................................................................................................. 42 4.2. Basic Visibility Hop Vh=1 ................................................................................. 46
4.2.2.2. Circular grid topology ......................................................................... 49 4.3. The impact of a greater Visibility, case study of Vh=2 ...................................... 51
5. Diagonal Flow............................................................................................................. 59 5.1. Motivation ........................................................................................................... 59 5.2. Basic Case of Visibility Vh=1 ........................................................................... 60
5.2.1. Contamination Distance Cd=1 ................................................................ 61 5.2.2. Generalization of an arbitrary distance Cd=k ......................................... 63
5.3. The impact of a greater Visibility ( 2Vh ) on Diagonal Moves ...................... 67 5.3.1. Contamination Distance Cd=1 ................................................................ 67 5.3.2. Contamination Distance Cd=2 ................................................................ 68
5.4. Generalization for an arbitrary Cd and Vh ......................................................... 72 5.5. Summary ............................................................................................................. 74
6.2.1. Base Idea ................................................................................................. 78 6.2.2. Sample Execution ................................................................................... 79
6.2.3. The pattern retrieval ................................................................................ 79 6.2.3.1. The pattern retrieval with conserved decontamination flow ............... 82 6.2.3.2. The pattern retrieval with inverse decontamination flow ................... 84 6.2.4. Similar strategies on sub networks ......................................................... 90
6.3.3. Division and Re-Application ................................................................ 104 6.3.3.1. Case with 2 corner initiators. ............................................................ 104 6.3.3.2. Case with 4 corner initiators. ............................................................ 108
6.4. The subdividing strategy of the Diagonal Move Approach ............................. 109 6.4.1. Case with 2 corner initiators ................................................................ 110
6.4.2. Case with 4 corner initiators ................................................................ 112 6.4.3. Case with 3 corner initiators ................................................................ 117 6.4.4. Rules minimization ............................................................................... 118 6.4.4.1. Approach by “flow analysis”. ........................................................... 119 6.4.4.2. Approach by “transition rules merge”. ............................................. 121
7. CAEDISI, a CA editor and simulator for Network Decontamination ............... 124 7.1. Motivation ......................................................................................................... 124
7.1.1. Needs and existing software limitations ............................................... 124
7.1.2. Overall characteristics .......................................................................... 125 7.2. Caedisi versus current CA Software ................................................................. 127
7.2.1. CA Structure ......................................................................................... 127 7.2.2. Simulation properties ............................................................................ 131 7.2.3. Inverter and Reversability ..................................................................... 134
7.4. The main views ................................................................................................. 137
7.4.1. The Simulator wireframes and its functionalities ................................. 138
7.4.2. The CA Parameters wireframes and its functionalities ........................ 139 7.4.3. The Inverter wireframes and its functionalities .................................... 141 7.4.4. The Inverter-Parameter wireframes and its functionalities .................. 143
7.5. The Library Module .......................................................................................... 144 7.5.1. Pertinence and goals ............................................................................. 144
7.5.2. The Transition State Definition user interface ...................................... 144 7.5.3. The Neighbourhood Definition user interface .................................... 145
7.6. The Model ......................................................................................................... 146 7.7. The Simulator module ...................................................................................... 148
7.7.1. Pertinence and goals ............................................................................. 148
Appendix A: Implementation of the Simulation algorithm
Appendix B: Implementation of the Inverter (without immunity) algorithm
Appendix C: Implementation of the Inverter (with immunity) algorithm
Appendix D: Implementation of the rules collision/inclusion validation algorithm
Appendix E: Implementation of the contamination rules generation algorithm
Appendix F: Implementation of the recursive generation of neighbourhood data
ix
List of Figures
Figure 1.1: The native representation of a CA grid ................................................................. 4 Figure 1.2: Sample of topologies that can be modeled by a 1-dimensional CA: Chain(a),
Ring(b), Chordal Ring (c) and Complete Graph (d). .............................................. 5 Figure 1.3: Sample of topologies that can be modeled by a 2-dimensional CA: Rectangle
Grid (a), Circular Grid (b), Torus (2D view (c) and its 3D representation (d)) .... 6 Figure 1.4: An example of a 2D grid network modeled by a Cellular Automaton .................. 7 Figure 1.5: Two examples of attempted decontamination of a 2-dimensional CA .................. 9
Figure 2.1: The omni standard neighbourhood: the von Neumann neighbourhood and the
Moore neighbourhood. ......................................................................................... 17 Figure 2.2: The process of decontaminating basic CAs under the von Neumann
Figure 2.3: The process of decontaminating circular CAs under the von Neumann
neighbourhood and its local rules (source [Daa12]) ............................................. 20
Figure 2.4: The circular propagation of an internal decontamination .................................... 21 Figure 2.5: Propagation of k decontaminating cells with Temporal Immunity in CAs with
von Neumann neighbourhood (source [DFZ10]) ................................................. 22
Figure 2.6: Propagation of decontaminating cells with Temporal Immunity in basic CAs
under the Moore neighbourhood (source [DFZ10]) ............................................. 23
Figure 2.7: Propagation of decontaminating cells with Temporal Immunity in circular CAs
under Moore neighbourhood (source [DFZ10]) .................................................. 24 Figure 2.8: A partial execution of Conway’s Game of life ................................................... 27
Figure 3.1: A representation of the von Neumann and Moore neighbourhood when the
radius distance is equal to 2. ................................................................................. 32
Figure 3.2: New edges inserted resulting to a new graph topology when Vh=2 under the von
Figure 3.3: A sample of the new notation of a transition rule using a grayscale or color visual
representation of the neighbourhood. ................................................................... 40
Figure 4.1: The decontamination block .................................................................................. 43 Figure 4.2: A sample execution of the left-to-right basic decontamination under the von
Neumann neighbourhood in a finite CA when Vh=1 and Cd=2 ........................... 47
Figure 4.3: A sample execution of the left-to-right basic decontamination under the von
Neumann neighbourhood in a circular CA when Vh=1 and Cd=2 ...................... 49
Figure 4.4: The propagation flow of the basic decontamination under the von Neumann
neighbourhood in a circular CA .......................................................................... 50 Figure 4.5: A sample execution of the left-to-right decontamination under the von Neumann
neighbourhood in a circular CA when Vh=2 and Cd=1 ...................................... 52
Figure 4.6: Propagation of a 2 by 2 column decontamination under the von Neumann
neighbourhood when Vh=2 and Cd=2 .................................................................. 55 Figure 5.1: A basic propagation of a decontamination approach initiated by an inner cell
showing a bound-less number of decontaminating cells ...................................... 60 Figure 5.2: Propagation of the basic diagonal move under the von Neumann neighbourhood
when Vh=1 and Cd=1 ........................................................................................... 61 Figure 5.3: Propagation of the basic diagonal move under the von Neumann neighbourhood
when Vh=1 and Cd=k ........................................................................................... 63
x
Figure 5.4: Maximum Number of Decontaminating cells in a diagonal move within the von
Neumann Neighbourhood when Vh=1 and Cd=k ................................................. 65
Figure 5.5: Propagation of the diagonal move under the von Neumann neighbourhood when
2Vh and Cd=2 .................................................................................................. 68 Figure 5.6: Propagation of the diagonal move under the von Neumann neighbourhood when
Figure 6.1: The road traffic approach ..................................................................................... 78 Figure 6.2: Propagation of the road traffic approach under the von Neumann neighbourhood
.............................................................................................................................. 79 Figure 6.3: The two different possibilities of finding the initial case in the Road Traffic
Figure 6.5: The cut strategy of the road traffic approach ....................................................... 90 Figure 6.6: The diagonal snake approach within the Moore neighbourhood ......................... 95 Figure 6.7: Execution difference around the diagonal depending on the value of n .............. 97 Figure 6.8: Propagation of the diagonal snake approach within the Moore neighbourhood . 98
Figure 6.9: The different type of cells within the CA during the diagonal snake strategy ... 100 Figure 6.10: An attempt to define f1 within the diagonal snake strategy .............................. 101 Figure 6.11: The subdividing strategy using 2 initiators. ..................................................... 105
Figure 6.12: The subdividing strategy using the snake approach with 4 initiators .............. 109 Figure 6.13: The divide and conquer diagonal strategy with 2 initiators ............................. 111
Figure 6.14: The subdividing strategy using diagonal move with 4 initiators ..................... 114 Figure 6.15: A sample of execution of the subdividing strategy using diagonal move
algorithm using a dynamic number of initiators. ................................................ 118
Figure 7.1: The CAEDISI software architecture .................................................................. 136
Figure 7.2: The simulator home screen ................................................................................ 138 Figure 7.3: The CA parameters screen of the simulator module .......................................... 139 Figure 7.4: The inverter home screen ................................................................................... 141
Figure 7.5: The CA parameter screen of the inverter module .............................................. 143 Figure 7.6: The Transition State Definition screen of the library module showing the current
list of cell state types. .......................................................................................... 144 Figure 7.7: The Neighbourhood Definition edit screen of the library module showing how to
create a new type of neighbouhood .................................................................... 145 Figure 7.8: the data entity model of CAEDISI ..................................................................... 146
Figure 7.9: A sample view of the metadata screen of the simulation module ...................... 149 Figure 7.10: An example of two rules having collision errors ............................................. 151 Figure 7.11: A view of the Rules Validation Results screen showing collision errors ........ 152
Figure 7.12: An example of two rules having inclusion errors ............................................ 153 Figure 7.13: A view of the Rules Validation Results screen showing inclusion errors ....... 154 Figure 7.14: An example of the Inverter execution showing the creation of rules .............. 157 Figure 7.15: The impact of an even/odd sized CA on the Inverter....................................... 158
xi
List of Tables
Table 2.1: The computational results of the basic Network Decontamination of CAs under a
von Neumann or Moore neighbourhood................................................................ 19 Table 2.2: The computational results of the Network Decontamination under the von
Neumann neighbourhood and with Time Immunity ............................................. 22 Table 2.3: The computational results of the Network Decontamination under the Moore
neighbourhood and with Time Immunity .............................................................. 24
Table 3.1: Various notations of the transition state of a CA in current literature and in this
thesis. ..................................................................................................................... 38 Table 4.1: Rule for Basic decontamination in Finite CA under the von Neumann
neighbourhood when Vh=1 and Cd=2 ................................................................... 48 Table 4.2: Alternative Rule for Basic decontamination in Finite CA under the von Neumann
neighbourhood when Vh=1 and Cd=2 ................................................................... 49
Table 4.3: Rule for Basic decontamination in circular CA under the von Neumann
neighbourhood when Vh=1 and Cd=2 ................................................................... 51
Table 4.4: Rule for Basic decontamination in Finite CA under the von Neumann
neighbourhood when Vh=2 and Cd=1 ................................................................... 52 Table 4.5: Rule for Basic decontamination in a circular and Finite CA under the von
Neumann neighbourhood when Vh=2 and Cd=1 .................................................. 53 Table 4.6: Rule for Basic Decontamination in Finite CA under the von Neumann
neighbourhood when Vh=2 and Cd=2 ................................................................... 56 Table 4.7: Rule for Basic Decontamination in Finite CA under the von Neumann
neighbourhood when Vh=2 and Cd=2 ................................................................... 57
Table 4.8: Summary of the basic decontamination results for a n*m )( mn CA under the
topology, Visibility Hop and Contamination Distance parameters. ...................... 58 Table 5.1: Rules for decontamination in Finite CA using basic diagonal move under the von
Neumann neighbourhood when Vh=1 and Cd=1 .................................................. 62 Table 5.2: Rules for Basic Decontamination in Finite CA using diagonal move under the von
Neumann neighbourhood when Vh=1 and for an arbitrary Cd=k ......................... 67
Table 5.3: Rules for Basic Decontamination in Finite CA using diagonal move under the von
Neumann neighbourhood when Vh=2 and Cd=2 .................................................. 70 Table 5.4: Another possible set of rules for Basic Decontamination in Finite CA using
diagonal move under the von Neumann neighbourhood when Vh=2 and Cd=2 ... 71
Table 5.5: Summary of decontamination results of an n*m (nm) CA using Diagonal move
strategies. ............................................................................................................... 76 Table 6.1: Rules for Basic Decontamination in Finite CA using the Road Traffic approach
(with flow conservation) under the von Neumann neighbourhood with Vh=3 ..... 84 Table 6.2: Rules for Basic Decontamination in Finite CA using the Road Traffic approach
with inverse flow under the von Neumann neighbourhood with Vh=3 ................. 87 Table 6.3: Rules for Basic Decontamination in Finite CA using the road Traffic approach
(with inverse flow) under the Moore neighbourhood with Vh=2 ......................... 90 Table 6.4: Rules for Decontamination in Finite CA using the road traffic approach (with
inverse flow) using 2*k decontaminating cells under Moore neighbourhood with
Vh=2 ....................................................................................................................... 93 Table 6.5: Direction flow of the decontaminating transition state ......................................... 99
xii
Table 6.6: Rules for Decontamination in Finite CA using the diagonal snake approach move
under the Moore neighbourhood when Vh=2 and for an immunity time It=2n-1
............................................................................................................................. 104 Table 6.7: Rules for Decontamination in Finite CA using the diagonal snake approach move
with 2 corner initiators under the Moore neighbourhood of Vh=2. ..................... 107 Table 6.8: Rules for Basic Decontamination in Finite CA using basic diagonal move and two
corner initiators under the von Neumann neighbourhood when Vh=1 and Cd=1
............................................................................................................................. 112 Table 6.9: Rules for Basic Decontamination in Finite CA using basic diagonal move and
four corner initiators with the von Neumann neighbourhood when Vh=1 and
Cd=1 .................................................................................................................... 117 Table 6.10: Alternative rules for Basic Decontamination in Finite CA under the von
Neumann neighbourhood using basic diagonal move and initiated by the top left
initiator when Vh=1 and Cd=1 ............................................................................. 119 Table 6.11: Alternative rules for Basic Decontamination in Finite CA with the von Neumann
neighbourhood using basic diagonal move and initiated by any corner initiators
when Vh=1 and Cd=1 .......................................................................................... 121 Table 6.12: Summary of decontamination results of a n*n CA using the Road Traffic,
Diagonal Snake and Diagonal Move strategy. .................................................... 123 Table 7.1: CAEDISI vs current CA Software (Overall structure) ........................................ 128 Table 7.2: CAEDISI vs current CA Software (Simulation properties) ................................ 132
Table 7.3: CAEDISI vs current CA Software (Inverter and Reversability) ......................... 134 Table 7.4: CAEDISI vs other CA Software (Database and Libraries) ................................. 135
1
Chapter 1
1. Introduction
1.1. Problem Statement
Consider a network where sites (nodes) are processing some computations. In addition,
sites can communicate with each other through links. A very realistic situation is that some
sites might be contaminated, for example, by a virus. These infections could have been
inserted locally in the network or by external network attacks. When infected these nodes
usually behave incorrectly. Typically, antivirus programs are run at each infected network
site for disinfection. However, there is no genuine guarantee that the clean site will not be re-
infected again. To accentuate the issue, a network site cannot detect the presence of viruses
within itself and therefore cannot curb the spread of viruses. This situation is exploited by
some types of viruses which are capable of encouraging infected nodes to propagate the fault
to neighbouring nodes. The evident solution to execute the antivirus against all existing hosts
of the network is not an acceptable one because when active, it is assumed that the antiviral
program will reduce or even stop local computation and therefore disrupt the entire network.
In order to sanitize the network, a system must be capable of firstly, cleaning the infected
hosts and secondly, counteracting the propagation of faults. Network Decontamination is the
research of strategies for network sanitation by considering these previous two key points.
1.2. Network Decontamination
The Network Decontamination problem was first introduced in Speleology, where a
maze of caves was infected by gas and needed to be decontaminated [Bre67]. In computer
science, Network Decontamination is a field of study that addresses the problem of
sanitizing a network which is contaminated by a virus. A virus is assumed to be a program
that, when executed against a clean host, will make the host faulty. The faulty host then
spreads the virus over the network using communication links. A network is considered
contaminated by a virus when either one or more machine hosts are infected by a virus.
Infected hosts expose faulty behaviors and can contaminate neighbouring hosts which
2
recursively affects the entire network. In the decontamination problem, it is generally
assumed that the network is partially or fully contaminated. Our interest is to find an
efficient strategy to correct every faulty node by executing an antivirus against contaminated
hosts.
1.2.1. Decontamination by Mobile Agents
The most popular approach to sanitizing a distributed network is the use of Mobile
Agents. Mobile Agents are extensively used in distributed systems to solve typical problems
such as Rendez-vous, Graph Exploration and Black Holes. A listing of the use of Mobile
Agents in Distributed systems is found in [KK07]. Mobile Agents can be defined as software
entities with the capacity for motion inside a network and which can act on behalf of their
user with some degree of autonomy in order to accomplish different computing tasks.
Mobile Agents have been found to be useful in a number of network security applications
including Network Decontamination. The nature of the network topology plays an
important role in the efficiency of operations executed within the network by the sites and
the Mobile Agents (see [FHL06], [FHL08] and [FHL07]).
1.2.2. Network Topology and Graph approach
The standard visual way to represent a network is by the means of a graph: hosts are
represented by nodes, and the presence of edges between two nodes stipulates that there is a
connection link between these two hosts. Researchers have shown tremendous interest in the
debate over the best graph topology on which to model a network. Among the known
topologies are Ring, Tree, Rectangular Grids (or Mesh), Hypercube and Complete graphs.
Clearly, the choice of the topology has a direct impact on the efficiency of operations that
will be executed under the network. For instance, an optimal decontamination strategy
against a Ring network might not necessarily be efficient, nor even meaningful, for a
Complete graph.
Most solutions for graph theory problems such as graph coloring, covering problems
(e.g., Vertex cover), and route problems (e.g., Hamiltonian path, spanning tree) are
frequently used as the backbone of solutions in distributed systems problems such as Voting,
Leader Election, Broadcasting, or Routing. The Network Decontamination problem is
related, under certain conditions, to that of the graph search ([Mes08]). Thus, several of the
3
techniques and models considered by researchers for the general graph search problems are
quite useful in the study of the Network Decontamination problems when the network is
modeled by a graph.
1.2.3. The Cellular Automaton approach
In our thesis, we take a tangent direction from the graph approach. Instead of having
the external intervention of Mobile Agents cleaning the network, we put our focus on
finding "local" strategies so that hosts can trigger and execute the decontamination
themselves. The idea of using local approaches is known in distributed systems. Distributed
and networked systems often employ local majority based rules to enhance reliability and
fault-tolerance. Local voting schemes are used as decision tools in a variety of different
applications, for example, agreement and consensus in distributed systems. Also, systems
employing majority-based local voting schemes are known to have a higher level of
resistance. (For instance, one can use a similar idea with respect to network contamination in
which a clean cell is always immune to contamination as long as a majority of its neighbours
are uncontaminated). More precisely, we want to build local rules that will be applied to
each network site in a uniform way. To this end, we use a Cellular Automaton to model both
the network and the operations that need to be performed. Invented by Ulam and Neumann
in the 1950s, Cellular Automaton was originally used to study their joint work on liquid
motion for self-organizing and reproducing behaviors [Neu51]. Our motivation is based on
the fact that it is a discrete model known for its simplicity in integrating a locally based
voting scheme, yet powerful enough to model any complex application. The study of its
properties and its behavior has interested various disciplines as diverse as physics, biology,
and theoretical computer science (e.g. [ADF07], [Kar05], [CD98], [LM10]).
1.3. Cellular Automata
1.3.1. Definition and structure
A Cellular Automaton (CA) consists of a regular grid of cells, each having a finite
number of states (A formal definition of a CA can be consulted in Chapter 3). The grid can
be in any finite number of dimensions but the most used in practical applications are the 1-
dimensional and 2-dimensional ones (see Figure 1.1). For each cell, a set of cells, called
4
its neighbourhood, is defined relative to the specified cell. Neighbours are usually composed
by a set of cells surrounding the centered cell itself within a specific integer distance called
radius. An initial state is selected by assigning a state for each cell. A new generation is
created at the next step according to a fixed transition rule that determines the new state of
each cell in terms of the current state of the cell and the states of the cells in its
neighbourhood. Typically, the rule for updating the states of cells is the same for each cell,
does not change over time, and is applied to the whole grid simultaneously, which makes the
execution of the state update in a synchronous fashion.
1-dimensional CA
i i+1i-1
2-dimensional CA
i-1,j-1 i-1,j i-1,j+1
i,j-1 i,j i,j+1
i+1,j-1 i+ 1, j i+1,j+1
Figure 1.1: The native representation of a CA grid
The most elementary model of a CA is the 1-dimensional version (1D) (see Figure
1.1). Each site or cell in the lattice is in either the ON (a filled circle in the cell) or OFF (an
empty cell) state. In the example illustrated here, the site i-1 is OFF and the sites i and i+1
are ON. Each cell can have two states; therefore, there are 23= 8 possible configurations of
this neighborhood. For the CA to work, it is necessary to define what the state should be in
the next generation. Consequently, there are 28 = 256 possible local rules with a wide range
of behaviours and properties. The diversity of these simple rules alone has raised great
interest and contributes to its popularity since its introduction.
5
1.3.2. Cellular Automata and network topology
(a)
(b)
(c) (d)
Figure 1.2: Sample of topologies that can be modeled by a 1-dimensional CA:
Chain(a), Ring(b), Chordal Ring (c) and Complete Graph (d).
Network topology addresses how the various elements of a computer network are
arranged and graphs are useful because they serve as mathematical models of network
structures. The topological structure of a network can be depicted physically (how various
component such as the location of the device or cables are placed); or logically (how the data
flows within the network regardless of its physical design). In a CA, the physical topology of
the network can be a ring, a mesh or a torus and the dataflow between the components
which determines the logical topology of the network is addressed by the CA
neighbourhood. Indeed, CA has ability to model some specific classes of network
topologies. For instance, it is easy to see that a chain is naturally modeled by a 1-
dimensional CA. To this end, the chain is only extrapolated by a single array (see Figure
1.2a). Chorded rings are also special type of 1-dimensional circular CA (see Figure 1.2c). A
chordal ring },,...,2,1{ kpC of size n is a ring on n nodes 110 ,...,, nxxx where each node ix
is connected to nodes npini xx mod)(mod)1( ... and nkix mod)( . In a general aspect, a chordal ring
can be considered as a k-neighbours 1-dimensional circular CA. Note that when 1 kp ,
the chordal ring is a simple Ring (see Figure 1.2b) and becomes a Complete graph when
2
nkp (see Figure 1.2d).
6
(a) (b)
(c) (d)
Figure 1.3: Sample of topologies that can be modeled by a 2-dimensional CA:
Rectangle Grid (a), Circular Grid (b), Torus (2D view (c) and its 3D representation (d))
Additionally, rectangle grid (mesh) and possible variations can naturally be modeled
by a 2-dimensional (2D) CA (Figure 1.3a). When making a circular connection between the
various extremities of the 2D grid, the bi-dimensional CA with circular connections become
a Torus (Figure 1.3c). In fact, a 2D CA can model any instance of a grid as long as the
connections between elements follow a regular pattern that can be represented by the CA
neighbourhood concept. A 2D CA can represent a grid network with larger connections
between hosts in a larger neighbourhood defined in the CA. Figure 1.4 is an example of the
modelling of a simple sub-network by a 2D CA. In this example, a cell has a maximum of
six neighbours.
1.3.3. Decontamination using Cellular Automata
The use of a CA to perform the decontamination is possible under two conditions. The
first hypothesis is that the network must be modeled by a CA. In the previous section, we
7
have shown some candidate topologies that satisfy this condition. The second condition
concerns the state of the network sites that has to be mapped with the CA transition states.
To this end, each CA’s cell state is just set to one of these three states: Contaminated (the
network site is infected by a virus), Decontaminating (The network site is executing the
antiviral program) and Decontaminated (the virus has been removed from the network site
and the site is currently clean). The decontamination goal is to study the building of
transition rules that take as input a contaminated CA, and transfer each cell state from a
faulty contaminated state into a decontaminating state so that each cell eventually becomes
and remains decontaminated. An illustration of an execution is shown in Figure 1.4.
Contaminated network sites (white cell) are represented by the number "1" in the CA while
decontaminated cells are represented by "0" to represented the clean site (gray cell). When
cells are in a decontaminating state, it is represented by a dot "•" within both the CA and the
network graph representation.
Network using a graph representation
CA Representation
1 1 • 0 0 0
1 1 • 0 0 0
1 1 • 0 0 0
1 1 • • • •
1 1 1 1 1 1
Figure 1.4: An example of a 2D grid network modeled by a Cellular Automaton
1.4. Motivation and Pertinence
In a world dominated by networking and its ramifications (Internet, social networks,
distributed systems, distributed data, and cloud computing), networking reliability is crucial.
Similar to software which cannot be bug free, any networking system cannot insure
complete reliability. Indeed, network systems are now facing an increased number of attacks
than they have faced in the past. The problem is that faulty network sites become vulnerable
and can expose security holes. There are various types of breakdown including process
deaths, machine crashes, and network failures. A great concern for fault tolerance and
8
security is how to devise strategies to correct the faulty behaviour at network sites and to
control the propagation of faults. Thus, Network Decontamination has attracted many
researchers in the past decade. They have approached the Network Decontamination
problem from many angles including its empirical version of a fully contaminated network
that needs a full decontamination.
1.5. Research Questions and Requirements
1.5.1. State of the art and challenges
The general result within the field of Network Decontamination using external
approach is that the problem of determining the optimal number of mobile agents necessary
to perform the decontamination in arbitrary topologies is NP-hard. To date, much research
has been done on the study of the decontamination problem, especially in the theoretical
field of fault tolerance within distributed systems theory. There are a considerable number of
papers that have been published on the topic. Many researchers have studied the
decontamination problem under different types of parameters; however, most have
concentrated their efforts in the study of decontamination in topologies of graphs, such as
Trees, Rings, Tories, and Hypercubes. There are a few papers in which the network is
modelled by a CA.
With respect to pure CA theory, there are a number of papers devoted primarily to its
structure and its properties. There are also a considerable number of applications that
directly use CA as a backbone. That said, the amount of research that has been done
regarding the use of CA in the field of Network Decontamination is still limited.
9
t=0 t=1 t=2
(a)
(b)
Figure 1.5: Two examples of attempted decontamination of a 2-dimensional CA
One trivial decontamination strategy using a CA is to initially run the antiviral
program to one or multiple cells (initiators) of our CA and to propagate the decontamination
strategy to all existing neighbours (Figure 1.5a). This strategy is simple because it just
possesses two rules. The first rule suggests that any decontaminating cell gets
decontaminated at the next stage. The second rule proposes that any contaminated state in
contact with a decontaminating cell will also run the antiviral program in the next stage.
With this solution, we can see that the CA eventually gets fully decontaminated. However,
the fundamental issue with this solution is that the number of decontaminating cells
considerably increases at each step and therefore is boundless. If one attempt to reduce the
number of decontaminating cells at each step, a possible strategy would only propagate the
decontamination from the initiator cells to a limited number of neighbours, for instance to
the neighbours located on its right (as in Figure 1.5b). However, with this strategy, any
decontaminated cell will get re-contaminated by its left neighbours. These examples show
the nature of some problems that must be taken into account when building decontamination
strategies.
10
1.5.2. Our research and contributions
Our research focuses on the Network Decontamination problem using the concept of
CA. We propose optimal strategies to decontaminate a network using local rules by using a
2-dimensional CA as a model. Various basic algorithms using this type of model have been
investigated in [Daa12]. In this thesis, we continue this line of research by studying new
strategies under new assumptions. More precisely, we study the decontamination problem
under two new dimensions arising from the concept of radius within CA. To this date, only
direct neighbourhood (radius=1) have been considered. Therefore,
a new model of accessing knowledge information, which we define as Visibility Hop, is
proposed. This property allows a cell to oversee a larger neighbourhood.
a new model of (re)infections, which we define as Contamination Distance, is also
proposed. This property allows us to define which distant infected neighbours can
contaminate cleaned cells.
We demonstrate that the addition of these parameters brings new dynamics to the
decontamination process. The Visibility Hop allows us to discover new decontamination
strategies. Moreover, the Contamination Distance allows us to differentiate the strategies to
take under weaker or stronger conditions. Also fundamentally, a greater value assigned to
these properties also implies that the graph topology covered by the CA is denser than a
simple rectangle grid. These dynamics are seen in more details in Chapter 3.
Principally in this thesis, we developed several decontamination techniques under
these parameters. Additionally, a research tool that help us manage our research have been
developed.
1.6. Thesis Organization
This thesis is organized as follows.
In Chapter 2, we review the existing literature on the Network Decontamination
problem. We also briefly present some related results on CA which are significant to our
study.
Chapter 3 presents the model we will use in this thesis. We will also present the
terminology and other formal characterization of the various entities used in our document.
11
In Chapter 4, we investigate the impact of the Visibility Hop and Contamination
Distance against some basic known decontamination algorithms under a CA. We present the
result of our initial studies against this new concept under the von Neumann and Moore
neighbourhoods.
In Chapter 5, we present a new approach called Diagonal Flow and we show that the
concept of Visibility can bring noticeable improvement against these schemes.
In Chapter 6, we present others schemes of decontaminating a CA by using a
subdividing strategy similar to divide and conquer methods. We also show that the diagonal
move presented in the previous chapter can serve as a base block in this strategy.
In Chapter 7, we present a research tool that we have implemented that aims to assist
us in the study of Network Decontamination using CA.
In Chapter 8, we give a summary of the work accomplished so far and we present a
non exhaustive list of possible future work.
12
Chapter 2
2. Literature Review
In this chapter, we give a survey of the known problems and results related to our work in
this thesis. We briefly discuss the two different classifications of network decontamination
with respect to the approach being internal or external. We review known results for each
approach, especially when decontamination is performed by Mobile Agents. Then, we
outline in detail the current known algorithms and results of internal decontamination using
a CA as this is directly related to our study. We continue by enunciating some relevant
properties of the theory of CA. We conclude the chapter by listing some various applications
using CA.
2.1. Network Decontamination and approach classification
Network Decontamination is a widely studied problem in Computer Science. Network
hosts or sites are assumed to be contaminated by malicious software and a process needs to
be executed to clean the network. The process of decontamination is generally classified by
two distinct aspects. Depending on whether the decontamination is carried out by the
majority-voting mechanism already in place or by the use of a team of mobile agents, the
decontamination process is called internal or external, respectively. The process is called
internal due to the fact that the decontamination is processed by the sites themselves by
using local rules and without any outside intervention. An example of an internal process is
when the network is modeled by a CA and the local rules are composed of a set of transition
rules in which each cell obeys in exactly the same fashion. The process is called external
when the decontamination is processed by external entities to the system. An example of an
external decontamination is the cleaning by means of Mobile Agents. [Flo09] presents a
survey of the different methods of Network Decontamination with respect to these two
different approaches. In this chapter, we give a survey of the most common problems and
results related to our work in this thesis.
13
2.2. External Decontamination
2.2.1. Graph Search and the Search Number
The Network Decontamination problem is closely related to the graph search problem.
The metaphorical rendition of the two concepts has been introduced by Breisch in [Bre67].
The problem was presented as follows. A person is lost in a totally dark cave and the goal is
to find an efficient way to search and rescue the lost person. The author aims to find the
minimum number of searchers required to explore the cave so that it is impossible to miss
the victim. The analogy to the graph search problem is that the cave can be represented by a
finite connected graph G so that rooms are represented by vertices and the passages by
edges. The problem has been reformulated by other authors replacing the notion of the lost
person with an intruder, motivated by the fact that in the new problem, there are assumptions
that the intruder can have knowledge of the searchers' every move. Additionally, the intruder
is arbitrarily fast, invisible to rescuers, and even tries to avoid meeting the searchers
([Par78], [Par76]). Theoretically, we are given a graph ),( EVG with contaminated edges
and via a sequence of steps, one that uses searchers. The goal is to arrive at a situation where
all edges of the graph are simultaneously clean. More precisely, the problem is to find the
minimum number of searchers needed to clean the graph and to reach a final stage where all
edges are simultaneously clean. A clean edge Ee is immune to recontamination on two
conditions: either another searcher remains in a vertex adjacent to the edge, or all other
edges incident to this vertex are clean. That is, e is re-contaminated if there exists a path P
between e and a contaminated edge and there is no searcher residing in any node v for
Pv . An edge Eyxe ),( gets decontaminated if a searcher traverses it from x or y (or
from y to x). Any decontamination strategy can be broken down into a sequence of 3 basic
operations: the action of putting a searcher on a node v, the action of removing a searcher
from a node v, and the action of making the searcher traverse an edge e. Graph searching is
about finding a sequence composed of these three basic operations that results in all edges
being simultaneously clean. In general, researchers are most interested in finding optimal
search strategies and the minimization of the number of searchers used by a strategy.
Assuming a search strategy exists, )(Gs is the smallest number of searchers for a graph G.
Two results are important with respect to the search number. First, Meggido et al shows in
14
[MHG+88] that determining the search number of a graph is NP-hard. Second, LaPaugh
[Lap93] has proven that for every G, there is always a monotone search strategy that uses
)(Gs searchers. By definition, a search strategy is monotone if no recontamination ever
occurs. Several techniques and models considered by researchers with respect to the graph
search problem are useful in the study of the Network Decontamination problems.
2.2.2. Network Decontamination by Mobile Agents
The decontamination framework that has received great interest in recent years is
Network Decontamination using mobile agents. In computer science, a mobile agent is a
software entity that has the ability to move from node to node in a distributed system.
Mobile agents have been used in solving many distributed systems problems because of their
ease of use, their efficiency, and their fault-tolerance as explained in [KK07]. There are
several papers on the use of mobile agents in distributed systems problems including graph
exploration, black hole search and rendez-vous.
Decontamination by a mobile agent is considered an external decontamination because
the cleaning process is performed by an entity which is external to the system. The
decontamination process usually works in the same way. At any time, nodes can be
contaminated, clean, or guarded (if they contain at least an agent). All nodes are initially
contaminated except for one (the homebase) where a team of mobile agents is located.
Agents can move in the network from a node to a neighbouring node, and a contaminated
node is transformed into clean when an agent passes by the node. The goal is to reach a state
in which all nodes are clean (or guarded). Mobile agents are self-contained programs that
can move from a node to a neighbouring node to execute tasks independently of each other,
or to cooperate to solve problems. The network is still seen as an environment where nodes
represent hosts, edges represent connections between hosts, and we assume that the network
is initially contaminated. The goal is to deploy a team of agents to decontaminate the
network. An agent is a program that can migrate on the network. When an agent resides on a
node, it can detect all intruders at the node and clean the node if it is contaminated.
However, when a clean node has a contaminated neighbour, it becomes contaminated as
well. It is assumed that the agents start from the same node (the homebase) and can move to
neighbouring nodes. An important fact is that the problem of determining the optimal
15
number of agents necessary to perform the decontamination in arbitrary topologies is NP-
hard. Several papers exist about the optimal strategy to clean a network using mobile agents
under specific network topologies [FHL06], [LPS06], [LPS07], [FHL08], [FHL07].
In [FHL07], Flocchini et al consider the problem of decontaminating a network using
a team of mobile agents. The agents can clean a node after the agent transits the node. When
an agent transits a node, it can clean it, but when the node is left unguarded, it will be re-
contaminated as soon as at least one of its neighbours is contaminated. The authors' focus is
on asynchronous chordal ring networks with n nodes and chord lengths d1 = 1, d2, ..., dk, and
on tori. They also consider two variations of the model: one where an agent has only local
knowledge, and the other in which it has "visibility”. In other words, the agent can "see" the
state of its neighbouring nodes. The main result is that, when the largest chord dk is not too
large, the number of agents necessary to perform the task in chordal rings does not depend
on the size of the network but only on the length of the longest chord. The authors propose
different algorithms for realizing the decontamination strategy. They also show a lower
bound on the number of agents for the torus topology. For the complexity measures, they
consider the number of moves and the time complexity of the decontamination algorithms
showing that the visibility assumption allows for substantial decrease of both complexity
measures. Another advantage of the visibility model is that agents move independently and
autonomously without requiring any coordination, in other words, in an asynchronous way.
In [FHL08], the same authors studied the same decontamination idea but under the
Hypercube topology. They introduced a new variation of the model used in [FHL07]. The
variation was based on the capabilities of mobile agents in terms of locality (where agents
can only access "local" information), visibility (where agents can “see” the state of their
neighbours), cloning (where agents can create copies of themselves), and
synchronicity (where agents can synchronize their actions). For each model, Flocchini et al
designed a decontamination algorithm. For agents with locality, the decontaminating
strategy is based on the use of a coordinator that serves as a leader for the other agents. The
found strategy results in an optimal number of agents
n
n
log and requires O(n log n)
moves and O(n log n) time steps. For agents with visibility, with the assumption that the
agents can move autonomously, the decontamination strategy is also achieved in an optimal
16
time complexity (log n time steps), but the number of agents increases to 2
n. Finally, when
the agents have the capability to clone combined with either visibility or synchronicity, the
strategy reduces the move complexity, which becomes optimal, but at the expense of an
increase in the number of agents.
One parameter that brings setbacks to any decontamination algorithm is the strong
assumption that the host can be re-contaminated as soon as one of its neighbours is
contaminated. In all the existing literature, it is usually assumed that the immunity level of a
disinfected site is nil. Throughout the years researchers have attempted to weaken the
hypothesis by introducing some forms of immunity after the node has been decontaminated.
In [LPS06], the authors studied the Network Decontamination problem under a different
model of recontamination. They consider the case when a disinfected vertex, after the
cleaning agent has gone, will become re-contaminated, only if a weak majority of its
neighbours are infected. Their work focuses on tori and trees. For these two types of graphs,
they establish lower bounds on the number of moves performed by an optimal size time of
agents. In addition, they design and present strategies for disinfecting tori and trees and
prove that these strategies are optimal in terms of both team size (number of agents) and
number of moves by the agents. The same idea of immunity is also used in [LPS07] with the
authors focusing on toroidal meshes, graphs of vertex degree at most three (e.g., cubic
graphs, binary trees), and of tree networks.
2.3. Internal Decontamination
When internal decontamination mechanisms are in place, a contaminated host can be
decontaminated by itself with a pre-installed program, which is similar for each host in the
network. These programs are typically based on local analysis by the host itself of the status
of its neighbour. In other words, in a system with internal decontamination, all nodes are
subject to a rule that is similarly applied to each node. Theoretically, this is similar to
executing an existing Local-Majority mechanism. Peleg presents in [Pel02] a survey of some
Local Majority Voting in graphs. The same concept has motivated researchers to use CA as
the model to conduct some required decisions during the execution of the decontamination.
17
2.3.1. Decontamination using Cellular Automata
A Cellular Automaton consists of a grid of "cells" which are identical to each other
and whose states are updated synchronously following a set of predefined rules. The rules
applied to the cell itself are similar for each cell and are applied based on the state of a list of
predefined neighbours. Due to that simplicity, CA have always been used to model discrete
based systems, including Network Decontamination. In Network Decontamination using
CAs, each cell has the possibility of having three states: Contaminated, Decontaminated and
Decontaminating, respectively abbreviated and formally represented in the literature by the
number 1, 0 and the dot "•".
2.3.2. 2D Cellular Automaton Neighbourhood
Two types of neighbourhood are omnipresent in the study of two-dimensional CAs:
the von Neumann neighbourhood and the Moore neighbourhood (see Figure 2.1). Both
neighbourhood have been named according to their authors, who were pioneers of the theory
of CAs.
von Neumann neighbourhood
},,,,{ dcbaxN
b
a x c
d
Moore neighbourhood
},,,,,,,,{ hgfedcbaxN
b c d
a x e
h g f
Figure 2.1: The omni standard neighbourhood: the von Neumann neighbourhood and the
Moore neighbourhood.
2.3.2.1. The von Neumann neighbourhood
Assume the cell x is at coordinate ),( ji where the row index is i and j is the column
index (see Figure 2.1). The von Neumann neighbourhood N consists of the output cell x
and its four neighbouring cells dcba ,,, respectively at coordinate
),1(),1,(),,1(),1,( jijijiji .
The usual notation seen in the literature is },,,,{ dcbaxN
18
John von Neumann first used this neighbourhood to create a self-replicating machine
named the Universal Constructor. The fundamental details of the machine were published
in [Neu96]. von Neumann's design for a self-reproducing computer program is considered
the world’s first computer virus. The use of his neighbourhood and an extension of his
Universal Constructor work have been extended in various applications. The most known
CA application Game of Life uses the von Neumann neighbourhood [Gar70] and is the
source of inspiration for many applications from different domain. For instance, the Game of
Life CA is used in computer games for the generation of environments or in music for MIDI
sequencing.
2.3.2.2. The Moore neighbourhood
Assume the cell x is at coordinate ),( ji where the row index is i and j is the column
index (see Figure 2.1). The Moore neighbourhood N consists of the output cell x and its
eight neighbouring cells, which consist of the neighbour cells in the von Neumann model
plus the additional diagonal neighbours hfdb ,,, respectively at coordinate
)1,1(),1,1(),1,1(),1,1( jijijiji
The usual notation seen in the literature is },,,,,,,,{ hgfedcbaxN .
Edward F. Moore is the inventor of the Moore finite state machine (Moore FSM) and
is considered an early pioneer of artificial life. He invented the Moore Neighbourhood in CA
and his early work has contributed to some well-known theorems in CAs. One example is
the Garden of Eden theorem in which the author proves that there exists a configuration that
cannot appear on the lattice after one time step, regardless of the initial configuration (that
is, it is a pattern that has no parents and thus can only occur at time t=0). The Moore
neighbourhood has been used in the Firing squad problem in which the goal is to design a
CA that starts with a single active cell and eventually reaches a state in which all cells are
simultaneously active [MG68]. The Moore neighbourhood is currently used in various image
editing software such as Adobe Photoshop as well as Macromedia’s graphics software
behind their image engine to manage the allocation of the boundary and edge of a digital
image.
19
2.3.3. Basic Network Decontamination under CA
In this section, we review some results related to decontamination by 2-dimensional
CA for which the global decontamination process is described by a set of CA local rules.
The following results have been thoroughly developed in [Daa12]. Here we will only present
and briefly discuss the local rules’ results under the CA with a distinction made between the
von Neumann and Moore neighbourhoods. We also make a distinction between the
computational results based on a standard grid or circular topology since these types of
neighbourhoods and topologies are the main cases we consider in this thesis.
Model
Maximum Number
of Decontaminating
Cells k
Time Completion
(Number of steps)
Basic CA with von Neumann or
Moore neighbourhood n )(n
Circular CA with von Neumann
or Moore neighbourhood 2n )(n
Table 2.1: The computational results of the basic Network Decontamination of CAs
under a von Neumann or Moore neighbourhood
Basic contamination algorithms presented in [Daa12] have used a common approach.
They all obey a horizontal spread of the decontamination procedure, as opposed to the
circular propagation from the center of the cellular automaton as depicted in Figure 2.4.
2.3.3.1. Horizontal flow under the von Neumann neighbourhood
In finite two-dimensional CA under the von Neumann neighbourhood, optimal basic
decontamination can be achieved using n simultaneously decontaminating cells. The process
starts with n decontaminating cells aligned on one side (left) of the automata, and
horizontally moving to the other side (right side). Through this process, all left cells that
have been cleaned remain as such due to the protection of the current decontaminating cells
on their right, preventing the left cells from being re-contaminated by the outer right cells
still in a contaminated state. The process is represented in the Figure 2.2 below, displaying
the set of local rules needed to perform these operations as well.
20
Figure 2.2: The process of decontaminating basic CAs under the von Neumann
neighbourhood (source [Daa12])
In a circular CA, optimal basic decontamination can be achieved under the von
Neumann neighbourhood using 2n simultaneously decontaminating cells. The process starts
with 2 columns of n decontaminating cells aligned beside each other. The column of cells on
the left side will be responsible for decontaminating the left half of the automata, and the
right side of the column engages in the same operation against the right half of the CA. Each
horizontal move produces a set of clean cells in the center of the CA, and the process will
end when both columns encounter themselves after 2
n steps. Through this process, all cells
that have been cleaned remain as such due to the protection of the current decontaminating
cells that navigate either left to right or right to left. The process is depicted by the figure
below and the set of local rules needed to perform these operations are also displayed.
Figure 2.3: The process of decontaminating circular CAs under the von Neumann
neighbourhood and its local rules (source [Daa12])
21
2.3.3.2. Horizontal flow under the Moore neighbourhood
Even if we increase the neighbourhood to include diagonal neighbours, (the Moore
neighbourhood) we cannot obtain a better result than the von Neumann results. In fact, the
lower bound on the number of simultaneously decontaminating cells is similar to the von
Neumann neighbourhood both for finite and for circular CA.
Figure 2.4: The circular propagation of an internal decontamination
2.3.4. Network Decontamination under CA with Time Immunity
The definition of Time Immunity is simple in Network Decontamination. With
temporal decontamination, once a cell becomes decontaminated, it stays decontaminated for
a certain amount of time (t > 1), called immunity time. Same as in the previous section, we
review some results related to decontamination by 2D CA with Time Immunity
systematically developed in [DFZ10]. In the following sub-sections, we present the global
results with a distinction between the von Neumann and Moore neighbourhoods. The goal is
to design a set of local rules in such a way that during the evolution of the CA, a
decontaminated cell never comes into contact with a contaminated cell after its immunity
time has expired.
2.3.4.1. Strategies under the von Neumann neighbourhood
Under the von Neumann neighbourhood, Figure 2.5 shows the strategy to perform the
decontamination used by the algorithm. The author in [Daa12] distinguished three different
scenarios for the value of the number of decontaminating cells k. For each value of k (k=1,
22
k=2 and k=4), the author propose a different strategy inspired by the same idea, to
propagate a spiral flow going from the outer side of the CA into the central cell.
[Wol88] S. Wolfram. High Speed Computing, Scientific Application and Algorithm
Design, ed. Robert B. Wilhelmson. University of Illinois Press, 1988.
[Wol94] S. Wolfram. Theory and Applications of CA, World Scientific (1986), CA and
Complexity, Addison-Wesley, Massachusetts, 1994.
[Wol02] Stephen Wolfram, A new kind of science, Wolfram Media, 2002.
169
Appendix A: Implementation of the Simulation algorithm
/// <summary>/// Processes the transition rules algorithm. The goal is to produce new state for each cell of the cellular automata /// based on which transition rules is eligible applied to that cell. The data structure that holds the state for each/// step is the SystemStateDictionary. /// </summary>/// <param name="cellularAutomata">The cellular automata.</param>/// <param name="newStep">The new step.</param>private void ProcessTransitionRulesAlgorithm(Web.DataModel.CellularAutomata cellularAutomata, int newStep){ int numberOfRows = cellularAutomata.Height; int numberOfColumns = cellularAutomata.Width;
for (int i = 0; i < numberOfRows; i++) { for (int j = 0; j < numberOfColumns; j++) { int k = 0; // only 2D for now Cell myCell = cellularAutomata.CellularAutomataAsArray[i, j, k]; SimulationIterationItem previousIterationItem = GetSimulationIterationItem(myCell.CellId, newStep-1, false); SimulationIterationItem newIterationItem = GetSimulationIterationItem(myCell.CellId, newStep, true); newIterationItem.Reset();
//grab which rules applies to myCell foreach (TransitionRule rule in cellularAutomata.TransitionRules) { bool doesCellCurrentStateSatisfyRule = DoesCellConfigurationSatisfyTransitionRule(myCell, rule, cellularAutomata); if (doesCellCurrentStateSatisfyRule) newIterationItem.TransitionRulesCause.Add(rule); } //by default, the result state is the old value int resultCellStateTypeId = myCell.CellStateTypeId; if (newIterationItem.TransitionRulesCause.Count > 0) { if (newIterationItem.IsDeterministic) { int tentativeResultCellStateTypeId = newIterationItem.TransitionRulesCause.First().ResultCellStateTypeId; if (tentativeResultCellStateTypeId == ((int)EnumCellStateType.Decontaminated)) { resultCellStateTypeId = ((int)EnumCellStateType.Decontaminated); //each time the cell gets decontaminated (i.e the virus has been cleant), //the immunity timer is reset newIterationItem.ImmunityTimerValue = cellularAutomata.ImmunityTime; } else if (tentativeResultCellStateTypeId == ((int)EnumCellStateType.Contaminated)) { //it will goes to contaminated if the cell is no more immune if (previousIterationItem == null || previousIterationItem.ImmunityTimerValue == 0) { resultCellStateTypeId = ((int)EnumCellStateType.Contaminated); } else resultCellStateTypeId = myCell.CellStateTypeId; //decrease the timer newIterationItem.ImmunityTimerValue = (previousIterationItem.ImmunityTimerValue > 0 ? previousIterationItem.ImmunityTimerValue - 1 : 0); } else resultCellStateTypeId = tentativeResultCellStateTypeId; }
170
else { // Undeterministic (We found multiple transition rules that can be applied to the // cells but their result state are different) The Code decision is to keep the previous // transition result but we flag that the cell has an issue resultCellStateTypeId = myCell.CellStateTypeId; //even for underterministic case, we still decrease the immunity timer when the previous //state has a timer value set if (previousIterationItem.CellStateTypeId == ((int)EnumCellStateType.Decontaminated)) newIterationItem.ImmunityTimerValue = (previousIterationItem.ImmunityTimerValue > 0 ? previousIterationItem.ImmunityTimerValue - 1 : 0); } } else { if (resultCellStateTypeId == ((int)EnumCellStateType.Decontaminated)) { newIterationItem.ImmunityTimerValue = (previousIterationItem.ImmunityTimerValue>0 ? previousIterationItem.ImmunityTimerValue-1 : 0); } } //setting the final result state newIterationItem.CellStateTypeId = resultCellStateTypeId;
newTransitionRule.CurrentCellStateTypeId = previousCellStateTypeId; newTransitionRule.ResultCellStateTypeId = currentCellStateTypeId; //even though it is system generated, it is still simulating a user created. newTransitionRule.IsSystemGenerated = false; //now set the neighbourhood foreach (NeighbourhoodStateConfiguration ruleStateConfiguration
//foreach (Cell cell in this.CurrentCellularAutomata.Cells) for (int i = 0; i < numberOfRows; i++) { for (int j = 0; j < numberOfColumns; j++) { Cell myCell = currentInverterExecution.CellularAutomata.CellularAutomataAsArray[i, j, 0]; int currentCellStateTypeId = myCell.CellStateTypeId;
if (currentCellStateTypeId == ((int)EnumCellStateType.Contaminated)) { ; //no need to perform as we explicity ignore immunity. } else { //get the previousCellStateTypeId int previousCellStateTypeId =
newTransitionRule.CurrentCellStateTypeId = previousCellStateTypeId; newTransitionRule.ResultCellStateTypeId = currentCellStateTypeId; //even though it is system generated, it is still simulating a user created. newTransitionRule.IsSystemGenerated = false; //now set the neighbourhood foreach (NeighbourhoodStateConfiguration ruleStateConfiguration
Appendix D: Implementation of the rules collision/inclusion validation
algorithm public static Collection<RuleValidationError> ValidateTransitionRulesCollision(CellularAutomata cellularAutomata){ Collection<RuleValidationError> result = new Collection<RuleValidationError>(); int size = cellularAutomata.TransitionRules.Count;
for (int i = 0; i < size; i++) { TransitionRule t1 = cellularAutomata.TransitionRules.ElementAt(i); for (int j = i + 1; j < size; j++) { TransitionRule t2 = cellularAutomata.TransitionRules.ElementAt(j); // A collision occurs between 2 rules when their current state is the same, their resulting state are different // however the input neighbourhood configuration are similar if (t1.CurrentCellStateTypeId == t2.CurrentCellStateTypeId && t1.ResultCellStateTypeId != t2.ResultCellStateTypeId) { //validate if the input are the same. bool isInputIsomorphic = IsInputIsomorphic(t1, t2); if (isInputIsomorphic) result.Add(new RuleValidationError(t1, t2)); } } } return result;}
public static Collection<RuleValidationError> ValidateTransitionRulesInclusion(CellularAutomata cellularAutomata){ Collection<RuleValidationError> result = new Collection<RuleValidationError>(); int size = cellularAutomata.TransitionRules.Count;
for (int i = 0; i < size; i++) { TransitionRule t1 = cellularAutomata.TransitionRules.ElementAt(i); for (int j = i + 1; j < size; j++) { TransitionRule t2 = cellularAutomata.TransitionRules.ElementAt(j); // An inclusion occurs between 2 rules if their current state are the same , their resulting state is the same, // and the neighbourhood configuration neighbourhood configuration are similar or one is contained in another if (//!t1.IsSystemGenerated && !t2.IsSystemGenerated && t1 != t2 && t1.CurrentCellStateTypeId == t2.CurrentCellStateTypeId && t1.ResultCellStateTypeId == t2.ResultCellStateTypeId) { //validate if the input are the same. bool isInputIsomorphic = IsInputIsomorphic(t1, t2); if (isInputIsomorphic) result.Add(new RuleValidationError(t1, t2)); } } } return result;}
foreach (NeighbourhoodStateConfiguration t1Neighbour in t1.NeighbourhoodStateConfigurations) { if (t1Neighbour.CellStateTypeId != (int)EnumCellStateType.Generic) //no need to check if one is generic { NeighbourhoodStateConfiguration t2EquivalentNeighbour = t2.NeighbourhoodStateConfigurations.Where( neighbour => neighbour.x_offset == t1Neighbour.x_offset && neighbour.y_offset == t1Neighbour.y_offset && neighbour.z_offset == t1Neighbour.z_offset).SingleOrDefault(); if (t2EquivalentNeighbour != null && t2EquivalentNeighbour.CellStateTypeId != (int)EnumCellStateType.Generic && t1Neighbour.CellStateTypeId != t2EquivalentNeighbour.CellStateTypeId) { isInputIsomorphic = false; break; } } } return isInputIsomorphic;}
176
Appendix E: Implementation of the contamination rules generation algorithm
public static void GenerateContaminationRule(CellularAutomata cellularAutomata, NeighbourhoodType selectedNeighbourhoodType, ref int numberOfRulesCreated){ //using a temporary rule to loop through all existing neighbours TransitionRule tempRule = EntityHelper.GenerateGenericTransitionRule( string.Empty, string.Empty, selectedNeighbourhoodType, cellularAutomata.RadiusVisibility); //then create all contamination rule foreach (NeighbourhoodStateConfiguration configuration in tempRule.NeighbourhoodStateConfigurations) { //only generate when the contamination radius is smaller than the visibility radius if (configuration.DistanceFromCenter <= cellularAutomata.RadiusContamination) { numberOfRulesCreated++;
TransitionRule newContaminationRule = EntityHelper.GenerateGenericTransitionRule( "Rule #" + numberOfRulesCreated + " (Contamination)", "Contamination rule infecting a clean cell when a contaminated cell is located at a contamination radius=" + cellularAutomata.RadiusContamination + " and a visibility radius=" +cellularAutomata.RadiusVisibility, selectedNeighbourhoodType as NeighbourhoodType, cellularAutomata.RadiusVisibility);
&& stateConfiguration.y_offset == configuration.y_offset && stateConfiguration.z_offset == configuration.z_offset).First(); //set this neighourhood to contaminated and leave the remaining neighbours as generic thisConfiguration.CellStateTypeId = (int)EnumCellStateType.Contaminated; cellularAutomata.TransitionRules.Add(newContaminationRule); } } }
public static TransitionRule GenerateGenericTransitionRule(string name, string description, NeighbourhoodType neighbourhoodType, int radiusVisibility){ TransitionRule transitionRule = new TransitionRule() { Name = name, Description = description }; int minOffset = radiusVisibility * (-1); int maxOffset = radiusVisibility * (1); int xIndexCenterCell = maxOffset; int yIndexCenterCell = maxOffset; int zIndexCenterCell = 0; //for now we only deal with 2D //Generate recursively the neighbouring cells data according to the neighbourhoodtype int currentRadiusIndex = 0; EntityHelper.GenerateListNeighboursData(transitionRule, xIndexCenterCell, yIndexCenterCell, zIndexCenterCell, neighbourhoodType, currentRadiusIndex, radiusVisibility);
return transitionRule;}
177
Appendix F: Implementation of the recursive generation of neighbourhood
data algorithm (called by the contamination rules generation algorithm (Appendix E))
/// <summary>/// Generates the list neighbours data. /// The code recursively generate the list of neighbours starting from the center cell based on the /// neighbourhood type and the radius visibility. The approach uses a breadth-first-search (BFS)/// </summary>/// <param name="transitionRule">The transition rule.</param>/// <param name="xIndexCenterCell">The x index center cell.</param>/// <param name="yIndexCenterCell">The y index center cell.</param>/// <param name="zIndexCenterCell">The z index center cell.</param>/// <param name="neighbourhoodType">Type of the neighbourhood.</param>/// <param name="currentRadiusIndex">Index of the current radius.</param>/// <param name="radiusVisibility">The radius visibility.</param>/// <returns>A collection of NeighbourhoodStateConfiguration</returns>public static EntityCollection<NeighbourhoodStateConfiguration> GenerateListNeighboursData( TransitionRule transitionRule, int xIndexCenterCell, int yIndexCenterCell, int zIndexCenterCell, NeighbourhoodType neighbourhoodType, int currentRadiusIndex, int radiusVisibility){ currentRadiusIndex++; if (currentRadiusIndex > radiusVisibility) //the recursion ends when the distance thresold has ben met return null; //we use this storage to store the list of existing neighbourhood coordinate Collection<Tuple<int, int, int>> listOfExistingNeighboursCoordinate = new Collection<Tuple<int, int, int>>();
if (neighbourhoodType.IsTopLeftON) { int xIndex = xIndexCenterCell - 1; int yIndex = yIndexCenterCell - 1; int zIndex = 0; GenerateDirectNeighbourData(transitionRule, xIndex, yIndex, zIndex, currentRadiusIndex, radiusVisibility); listOfExistingNeighboursCoordinate.Add(new Tuple<int, int, int>(xIndex, yIndex, zIndex)); } if (neighbourhoodType.IsTopON) { int xIndex = xIndexCenterCell - 1; int yIndex = yIndexCenterCell; int zIndex = 0; GenerateDirectNeighbourData(transitionRule, xIndex, yIndex, zIndex, currentRadiusIndex, radiusVisibility); listOfExistingNeighboursCoordinate.Add(new Tuple<int, int, int>(xIndex, yIndex, zIndex)); } if (neighbourhoodType.IsTopRightON) { int xIndex = xIndexCenterCell - 1; int yIndex = yIndexCenterCell + 1; int zIndex = 0; GenerateDirectNeighbourData(transitionRule, xIndex, yIndex, zIndex, currentRadiusIndex, radiusVisibility); listOfExistingNeighboursCoordinate.Add(new Tuple<int, int, int>(xIndex, yIndex, zIndex)); } if (neighbourhoodType.IsRightON) { int xIndex = xIndexCenterCell; int yIndex = yIndexCenterCell + 1; int zIndex = 0; GenerateDirectNeighbourData(transitionRule, xIndex, yIndex, zIndex, currentRadiusIndex, radiusVisibility); listOfExistingNeighboursCoordinate.Add(new Tuple<int, int, int>(xIndex, yIndex, zIndex)); } if (neighbourhoodType.IsBottomRightON) { int xIndex = xIndexCenterCell + 1; int yIndex = yIndexCenterCell + 1; int zIndex = 0; GenerateDirectNeighbourData(transitionRule, xIndex, yIndex, zIndex, currentRadiusIndex, radiusVisibility); listOfExistingNeighboursCoordinate.Add(new Tuple<int, int, int>(xIndex, yIndex, zIndex)); }
178
/// <summary>/// Generates the direct neighbour data./// </summary>/// <param name="transitionRule">The transition rule.</param>/// <param name="xIndex">Index of the x.</param>/// <param name="yIndex">Index of the y.</param>/// <param name="zIndex">Index of the z.</param>public static void GenerateDirectNeighbourData(TransitionRule transitionRule, int xIndex, int yIndex, int zIndex, int currentRadiusIndex, int radiusVisibility){ int x_offset = xIndex - radiusVisibility; int y_offset = yIndex - radiusVisibility; int z_offset = 0;
if (x_offset == 0 && y_offset == 0 && z_offset == 0) // no need to create the center data return;