- Revised cost heuristic. Trace length is no longer the real
optimization.
This commit is contained in:
parent
e1890ddc9f
commit
d2058d937b
@ -57,8 +57,6 @@ Role I_RRSD; //!< Decrypt role of the intruder
|
|||||||
|
|
||||||
int proofDepth; //!< Current depth of the proof
|
int proofDepth; //!< Current depth of the proof
|
||||||
int max_encryption_level; //!< Maximum encryption level of any term
|
int max_encryption_level; //!< Maximum encryption level of any term
|
||||||
int num_regular_runs; //!< Current number of regular runs
|
|
||||||
int num_intruder_runs; //!< Current number of intruder runs
|
|
||||||
|
|
||||||
static int indentDepth;
|
static int indentDepth;
|
||||||
static int prevIndentDepth;
|
static int prevIndentDepth;
|
||||||
@ -132,8 +130,8 @@ arachneInit (const System mysys)
|
|||||||
add_event (SEND, NULL);
|
add_event (SEND, NULL);
|
||||||
I_RRSD = add_role ("I_D: Decrypt");
|
I_RRSD = add_role ("I_D: Decrypt");
|
||||||
|
|
||||||
num_regular_runs = 0;
|
sys->num_regular_runs = 0;
|
||||||
num_intruder_runs = 0;
|
sys->num_intruder_runs = 0;
|
||||||
max_encryption_level = 0;
|
max_encryption_level = 0;
|
||||||
|
|
||||||
indentDepth = 0;
|
indentDepth = 0;
|
||||||
@ -309,9 +307,9 @@ semiRunCreate (const Protocol p, const Role r)
|
|||||||
int run;
|
int run;
|
||||||
|
|
||||||
if (p == INTRUDER)
|
if (p == INTRUDER)
|
||||||
num_intruder_runs++;
|
sys->num_intruder_runs++;
|
||||||
else
|
else
|
||||||
num_regular_runs++;
|
sys->num_regular_runs++;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (DEBUGL (5))
|
if (DEBUGL (5))
|
||||||
{
|
{
|
||||||
@ -341,9 +339,9 @@ semiRunDestroy ()
|
|||||||
p = sys->runs[sys->maxruns - 1].protocol;
|
p = sys->runs[sys->maxruns - 1].protocol;
|
||||||
roleInstanceDestroy (sys);
|
roleInstanceDestroy (sys);
|
||||||
if (p == INTRUDER)
|
if (p == INTRUDER)
|
||||||
num_intruder_runs--;
|
sys->num_intruder_runs--;
|
||||||
else
|
else
|
||||||
num_regular_runs--;
|
sys->num_regular_runs--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2277,8 +2275,8 @@ arachne ()
|
|||||||
error ("Something is wrong, number of runs >0.");
|
error ("Something is wrong, number of runs >0.");
|
||||||
}
|
}
|
||||||
|
|
||||||
num_regular_runs = 0;
|
sys->num_regular_runs = 0;
|
||||||
num_intruder_runs = 0;
|
sys->num_intruder_runs = 0;
|
||||||
|
|
||||||
max_encryption_level = 0;
|
max_encryption_level = 0;
|
||||||
iterate_role_events (determine_encrypt_max);
|
iterate_role_events (determine_encrypt_max);
|
||||||
|
@ -588,3 +588,23 @@ bindings_c_minimal ()
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Count the number of bindings that are done.
|
||||||
|
int
|
||||||
|
countBindingsDone ()
|
||||||
|
{
|
||||||
|
int count;
|
||||||
|
|
||||||
|
int countDone (Binding b)
|
||||||
|
{
|
||||||
|
if (b->done)
|
||||||
|
{
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
count = 0;
|
||||||
|
iterate_bindings (countDone);
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
@ -48,5 +48,6 @@ int iterate_preceding_bindings (const int run, const int ev,
|
|||||||
int (*func) (Binding b));
|
int (*func) (Binding b));
|
||||||
|
|
||||||
int bindings_c_minimal ();
|
int bindings_c_minimal ();
|
||||||
|
int countBindingsDone ();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
12
src/cost.c
12
src/cost.c
@ -32,10 +32,14 @@ attackCost (const System sys)
|
|||||||
|
|
||||||
cost = 0;
|
cost = 0;
|
||||||
|
|
||||||
cost += get_semitrace_length ();
|
//cost += get_semitrace_length ();
|
||||||
cost += 8 * selfInitiators (sys);
|
|
||||||
cost += 4 * selfResponders (sys);
|
cost += 10 * selfInitiators (sys);
|
||||||
cost += 2 * countInitiators (sys);
|
cost += 7 * selfResponders (sys);
|
||||||
|
cost += 4 * sys->num_regular_runs;
|
||||||
|
cost += 3 * countInitiators (sys);
|
||||||
|
cost += 2 * countBindingsDone ();
|
||||||
|
cost += 1 * sys->num_intruder_runs;
|
||||||
|
|
||||||
return cost;
|
return cost;
|
||||||
}
|
}
|
||||||
|
@ -17,8 +17,6 @@ extern int attack_leastcost;
|
|||||||
extern Protocol INTRUDER;
|
extern Protocol INTRUDER;
|
||||||
extern int proofDepth;
|
extern int proofDepth;
|
||||||
extern int max_encryption_level;
|
extern int max_encryption_level;
|
||||||
extern int num_regular_runs;
|
|
||||||
extern int num_intruder_runs;
|
|
||||||
|
|
||||||
//! Prune determination for bounds
|
//! Prune determination for bounds
|
||||||
/**
|
/**
|
||||||
@ -92,13 +90,14 @@ prune_bounds (const System sys)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (num_regular_runs > switches.runs)
|
if (sys->num_regular_runs > switches.runs)
|
||||||
{
|
{
|
||||||
// Hardcoded limit on runs
|
// Hardcoded limit on runs
|
||||||
if (switches.output == PROOF)
|
if (switches.output == PROOF)
|
||||||
{
|
{
|
||||||
indentPrint ();
|
indentPrint ();
|
||||||
eprintf ("Pruned: too many regular runs (%i).\n", num_regular_runs);
|
eprintf ("Pruned: too many regular runs (%i).\n",
|
||||||
|
sys->num_regular_runs);
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -111,7 +110,7 @@ prune_bounds (const System sys)
|
|||||||
if (switches.experimental & 1)
|
if (switches.experimental & 1)
|
||||||
{
|
{
|
||||||
if ((switches.match < 2)
|
if ((switches.match < 2)
|
||||||
&& (num_intruder_runs >
|
&& (sys->num_intruder_runs >
|
||||||
((double) switches.runs * max_encryption_level * 8)))
|
((double) switches.runs * max_encryption_level * 8)))
|
||||||
{
|
{
|
||||||
// Hardcoded limit on iterations
|
// Hardcoded limit on iterations
|
||||||
@ -120,7 +119,7 @@ prune_bounds (const System sys)
|
|||||||
indentPrint ();
|
indentPrint ();
|
||||||
eprintf
|
eprintf
|
||||||
("Pruned: %i intruder runs is too much. (max encr. level %i)\n",
|
("Pruned: %i intruder runs is too much. (max encr. level %i)\n",
|
||||||
num_intruder_runs, max_encryption_level);
|
sys->num_intruder_runs, max_encryption_level);
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -107,6 +107,8 @@ systemReset (const System sys)
|
|||||||
|
|
||||||
termlistDestroy (sys->secrets); // remove old secrets list
|
termlistDestroy (sys->secrets); // remove old secrets list
|
||||||
sys->secrets = NULL; // list of claimed secrets
|
sys->secrets = NULL; // list of claimed secrets
|
||||||
|
sys->num_intruder_runs = 0; // number of intruder runs
|
||||||
|
sys->num_regular_runs = 0; // number of regular runs
|
||||||
|
|
||||||
/* transfer switches */
|
/* transfer switches */
|
||||||
sys->maxtracelength = switches.maxtracelength;
|
sys->maxtracelength = switches.maxtracelength;
|
||||||
|
@ -121,6 +121,8 @@ struct system
|
|||||||
states_t failed; //!< Number of claims failed.
|
states_t failed; //!< Number of claims failed.
|
||||||
int attackid; //!< Global counter of attacks (used for assigning identifiers) within this Scyther call.
|
int attackid; //!< Global counter of attacks (used for assigning identifiers) within this Scyther call.
|
||||||
int countScenario; //!< Number of scenarios skipped.
|
int countScenario; //!< Number of scenarios skipped.
|
||||||
|
int num_regular_runs; //!< Number of regular runs
|
||||||
|
int num_intruder_runs; //!< Number of intruder runs
|
||||||
|
|
||||||
/* protocol definition */
|
/* protocol definition */
|
||||||
Protocol protocols; //!< List of protocols in the system
|
Protocol protocols; //!< List of protocols in the system
|
||||||
|
Loading…
Reference in New Issue
Block a user