[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[freehaven-cvs] Whitespace fixes; revised approach to mix breaking t...
Update of /home/freehaven/cvsroot/doc/e2e-traffic/src
In directory moria.mit.edu:/tmp/cvs-serv12957
Modified Files:
Makefile PLAN netparams.cpp sim.cpp sim.h simmain.cpp
trials.cpp trials.h
Log Message:
Whitespace fixes; revised approach to mix breaking that needs more work.
Index: Makefile
===================================================================
RCS file: /home/freehaven/cvsroot/doc/e2e-traffic/src/Makefile,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- Makefile 23 Nov 2003 06:26:23 -0000 1.6
+++ Makefile 2 Dec 2003 20:15:46 -0000 1.7
@@ -5,7 +5,8 @@
./test
CXX=g++
-CFLAGS=-Wall -O2 -g -DFAST_RANDOM -DQUIET
+CFLAGS=-Wall -O2 -g -DFAST_RANDOM
+#-DQUIET
clean:
rm -f *.o *~ sim test
Index: PLAN
===================================================================
RCS file: /home/freehaven/cvsroot/doc/e2e-traffic/src/PLAN,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- PLAN 23 Aug 2003 19:04:29 -0000 1.1
+++ PLAN 2 Dec 2003 20:15:46 -0000 1.2
@@ -1,39 +1,56 @@
+TODO for source:
+ . Make output easily parsed by Python
+ o Make sure that Alice can send dummies either by an indep or
+ dependant distribution.
+ - Output data for additional displays.
+ - Use correct rule for unknown-background nonbatch cases.
+ - Configure the obscurity of Alice's recipients in smallworld mode.
+ - Make partial-observation on entry != partial-observation on exit.
+ - Select simulations from command line by name/number.
+ - Simulation for full/partial linkability.
+
Simulations:
- 1 Original attack.
+ 1 Original statisticatl disclosure attack.
Mix=Batch, Alice=SD, Background=SD.
(class: SDTrial)
- 2 Attack with unknown background.
- Mix=Batch, Alice=SD+pNoSend, Background=SmallWorld.
- (class: UnkBGBatchTrial)
+ Variables: b, m, N.
- 3 Attack with realistic sender/recipient model.
+ 2 Attack with realistic network model and unknown background.
Mix=Batch, Alice=SmallWorld, Background=SmallWorld.
(class: UnkBGBatchTrial)
- 4 Attack with a timed dynamic-pool mix.
- Mix=1mix, Alice=SmallWorld, Background=Smallworld
- (class: DelayMixTrial)
+ Additional variables: frequency of alice sending,
+ connectedness of Alice's recipients. (plus vars from (1))
- 5 Attack with a mix-net.
- Mix=mixnet, Alice=SmallWorld, Background=Smallworld
+ 3 Attack with a timed dynamic-pool mix or a mixnet.
+ Mix=1mix/mixnet, Alice=SmallWorld, Background=Smallworld
(class: DelayMixTrial)
- 6 Attack with a mix-net and dummies
+ Additional variables: mix algorithm, mix algorithm
+ parameters, freq. of Alice sending. (plus vars from (2))
+
+ Additional display: histogram of latency.
+
+ 4 The impact of dummy traffic.
Mix=mixnet, Alice=SmallWorld+dummies, Background=Smallworld+dummies
- (class: DelayMixTrial)
-======================================================================
+ Additonal variables: Dummy approach and volume, probability that
+ Alice forgets to send. (plus vars from (3))
- 7 Partial observation: fraction of mixes
+ 5 The impact of partial observation
Mix=po_mixnet, Alice=SmallWorld+dummies,
Background=Smallworld+dummies
(class: PO_DelayMixTrial)
+ Additional variables: probability of observing incoming msgs,
+ probability of observing outgoing messatges (plus vars from (3),
+ (4)).
+
======================================================================
- 8 Nymservice
- 9 Fragmented community
- 10 Suspicious user
+ 6 Nymservice
+ 7 Fragmented community
+ 8 Suspicious user
Index: netparams.cpp
===================================================================
RCS file: /home/freehaven/cvsroot/doc/e2e-traffic/src/netparams.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- netparams.cpp 24 Nov 2003 00:33:27 -0000 1.3
+++ netparams.cpp 2 Dec 2003 20:15:46 -0000 1.4
@@ -19,7 +19,7 @@
std::vector<double> p(maxPathLen+maxDelay, 0.0);
for (int pathLen = 1; pathLen < maxPathLen; ++pathLen) {
double pathProb = pathLenDist.getP(pathLen);
- if (!pathProb)
+ if (!pathProb)
continue;
for (int d = 0; d < maxDelay; ++d) {
p[pathLen+d] += pathProb * bins(d, pathLen) *
Index: sim.cpp
===================================================================
RCS file: /home/freehaven/cvsroot/doc/e2e-traffic/src/sim.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- sim.cpp 22 Nov 2003 23:32:22 -0000 1.5
+++ sim.cpp 2 Dec 2003 20:15:46 -0000 1.6
@@ -13,23 +13,23 @@
DistAlice::addTraffic(vec<int> &v_out, int &n_out)
{
int nM;
+ if (pSend < 1.0 && rng() > pSend)
+ return;
n_out = nM = nMessageDist->get();
for (int i = 0; i < n_out; ++i) {
++ v_out[recipientDist->get()];
}
- if (nDummyDist) {
- int nD = nDummyDist->get();
- if ((nD||nM) && padding) {
- if (padding>nM)
- n_out = padding;
- } else
- n_out += nD;
+ if (padding) {
+ if (padding>nM)
+ n_out = padding;
+ } else if (nDummyDist) {
+ n_out += nDummyDist->get();
}
}
-UniformAlice::UniformAlice(const std::vector<int> &r,
- Dist<int> *mD, Dist<int> *dD, int p)
- : DistAlice(new UniformChoiceDist<int>(r), mD, dD, p)
+UniformAlice::UniformAlice(const std::vector<int> &r,
+ Dist<int> *mD, Dist<int> *dD, int p, double pOn)
+ : DistAlice(new UniformChoiceDist<int>(r), mD, dD, p, pOn)
{
}
@@ -117,7 +117,7 @@
// Unknown background
void
-DistBackground::addNTraffic(vec<int> &v_out, int nMessages)
+DistBackground::addNTraffic(vec<int> &v_out, int nMessages)
{
while (nMessages-- > 0) {
// XXX rng bottleneck
@@ -125,7 +125,7 @@
}
}
-void
+void
DistBackground::addTraffic(vec<int> &v_out, int &nOut)
{
nOut = nMessages->get();
@@ -174,7 +174,7 @@
// ======================================================================
-DelayMix::DelayMix(int nR, int mD,
+DelayMix::DelayMix(int nR, int mD,
Dist<int> *d)
: maxDelay(mD), poolIdx(0), pools(mD), delayDist(d->copy())
{
@@ -202,7 +202,7 @@
void
DelayMix::addRound(const vec<int> &inp, int nA, int nO,
- FwdAttacker *a)
+ FwdAttacker *a)
{
int sz = inp.size();
for (int i = 0; i < sz; ++i) {
@@ -220,13 +220,13 @@
}
DelayMixAttacker::DelayMixAttacker(int nR, int mD, InvDist<int> *dDist)
- : nRecips(nR), maxDelay(mD), nAliceIdx(0), nAliceHist(mD, 0),
+ : nRecips(nR), maxDelay(mD), nAliceIdx(0), nAliceHist(mD, 0),
nOtherHist(mD, 0),
background(nR, 0.0),
- observed(nR, 0.0),
+ observed(nR, 0.0),
nObservedOther(0.0), nObservedAlice(0.0),
delayDist(dynamic_cast<InvDist<int>*>(dDist->copy())),
- nRoundsObserved(0), nRoundsMaybeAlice(0)
+ nRoundsObserved(0), nRoundsMaybeAlice(0)
{
}
@@ -255,29 +255,32 @@
{
nAliceIdx = 0;
nAliceHist = std::vector<int>(nRecips, 0);
- nOtherHist = std::vector<int>(nRecips, 0);
+ nOtherHist = std::vector<int>(nRecips, 0);
background.reset(0.0);
observed.reset(0.0);
nObservedOther = nObservedAlice = 0.0;
nRoundsObserved = nRoundsMaybeAlice = 0;
+ exOtherInBackground = exAliceInBackground = 0.0;
}
//XXXX make this configurable. Low values really seem to hurt.
-#define BG_THRESHOLD 1
-void
-DelayMixAttacker::addRound(int nAlice, int nOther,
+#define BG_THRESHOLD 0.5
+void
+DelayMixAttacker::addRound(int nAlice, int nOther,
const vec<int> &r)
{
nAliceHist[nAliceIdx] = nAlice;
nOtherHist[nAliceIdx] = nOther;
-
+
double exAlice = expectedAliceMsgs();
double exOther = expectedOtherMsgs();
++nRoundsObserved;
//std::cout << exAlice << std::endl;
if (exAlice < BG_THRESHOLD) {
for (int i = 0; i < nRecips; ++i)
- background[i] += r[i]*exOther;
+ background[i] += r[i];//*(exOther+exAlice);
+ exOtherInBackground += exOther;
+ exAliceInBackground += exAlice;
} else {
++nRoundsMaybeAlice;
for (int i = 0; i < nRecips; ++i)
@@ -298,9 +301,16 @@
if (!uTotal || !nObservedAlice)
return false;
vec<double> u(background);
- u *= (nObservedOther / uTotal);
+ // XXX why does this work better?
+ u *= 1.8*(nObservedOther / exOtherInBackground);
res = observed - u;
- res -= u;
+#ifndef QUIET
+ std::cout << exOtherInBackground << "++++" << exAliceInBackground << std::endl;
+ std::cout << nObservedOther << "++++" << nObservedAlice << std::endl;
+ //std::cout << observed << std::endl;
+ //std::cout << u << std::endl;
+ //std::cout << res << std::endl;
+#endif
res /= nObservedAlice;
return true;
}
Index: sim.h
===================================================================
RCS file: /home/freehaven/cvsroot/doc/e2e-traffic/src/sim.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- sim.h 22 Nov 2003 23:32:22 -0000 1.5
+++ sim.h 2 Dec 2003 20:15:46 -0000 1.6
@@ -24,11 +24,11 @@
public:
FwdAttacker() {}
- virtual void reset() = 0;
- virtual void addRound(int nSentAlice, int nSentOther,
+ virtual void reset() = 0;
+ virtual void addRound(int nSentAlice, int nSentOther,
const vec<int> &nReceived) = 0;
virtual bool guessAlice(vec<double> &recipients) = 0;
- void getRoundCounts(int &nObs, int &nAlice) {
+ void getRoundCounts(int &nObs, int &nAlice) {
nObs = nAlice = 0;
}
@@ -54,15 +54,15 @@
Dist<int> *nMessageDist;
Dist<int> *nDummyDist;
Dist<int> *recipientDist;
- // if padding is >0, and we send any dummies, we instead send >=padding
- // messages total including dummies.
- int padding;
+ // if padding is >0, and we send any dummies, we instead send >=padding
+ int padding;
+ double pSend;
DistAlice() : nMessageDist(0), nDummyDist(0), recipientDist(0), padding(0) {}
public:
DistAlice(Dist<int> *recips, Dist<int> *msgs, Dist<int> *dummies,
- int p=0)
- : nMessageDist(msgs->copy()), nDummyDist(dummies->copy()),
- recipientDist(recips->copy()), padding(p) {}
+ int p=0, double pSendAny=1.0)
+ : nMessageDist(msgs->copy()), nDummyDist(dummies->copy()),
+ recipientDist(recips->copy()), padding(p), pSend(pSendAny) {}
void addTraffic(vec<int> &v_out, int &nOut);
~DistAlice() { delete nMessageDist; delete nDummyDist; delete recipientDist;}
};
@@ -71,7 +71,8 @@
class UniformAlice : public DistAlice {
public:
UniformAlice(const std::vector<int> &r,
- Dist<int> *msgDist, Dist<int> *dummyDist, int padding=0);
+ Dist<int> *msgDist, Dist<int> *dummyDist, int padding=0,
+ double pOnline=1.0);
~UniformAlice() { }
};
@@ -92,7 +93,7 @@
public:
BatchMix(int b);
void reset();
- void addRound(const vec<int> &input,
+ void addRound(const vec<int> &input,
int nAlice, int nBackground,
FwdAttacker *f);
~BatchMix() {}
@@ -159,7 +160,8 @@
Dist<int> *delayDist;
protected:
- int getDelay() { return delayDist->get(); }
+ int getDelay() { int d = delayDist->get();
+ return d >= maxDelay ? maxDelay-1 : d; }
public:
DelayMix(int nRecips, int maxDelay, Dist<int> *delayDist);
@@ -185,17 +187,20 @@
double nObservedOther;
double nObservedAlice;
+ double exOtherInBackground;
+ double exAliceInBackground;
+
InvDist<int> *delayDist;
// for TrialResult
int nRoundsObserved;
int nRoundsMaybeAlice;
- int aHist(int rds) { return rds>maxDelay ? 0 :
+ int aHist(int rds) { return rds>=maxDelay ? 0 :
nAliceHist[(maxDelay+nAliceIdx-rds)%maxDelay]; }
- int oHist(int rds) { return rds>maxDelay ? 0 :
+ int oHist(int rds) { return rds>=maxDelay ? 0 :
nOtherHist[(maxDelay+nAliceIdx-rds)%maxDelay]; }
-
+
double expectedAliceMsgs();
double expectedOtherMsgs();
@@ -204,7 +209,7 @@
void reset();
void addRound(int nSentAlice, int nSentOther, const vec<int> &nReceived);
bool guessAlice(vec<double> &nRecipients);
- void getRoundCounts(int &nObs, int &nAlice) {
+ void getRoundCounts(int &nObs, int &nAlice) {
nObs = nRoundsObserved; nAlice = nRoundsMaybeAlice; }
~DelayMixAttacker() { delete delayDist; }
};
Index: simmain.cpp
===================================================================
RCS file: /home/freehaven/cvsroot/doc/e2e-traffic/src/simmain.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- simmain.cpp 24 Nov 2003 00:33:27 -0000 1.6
+++ simmain.cpp 2 Dec 2003 20:15:46 -0000 1.7
@@ -13,7 +13,7 @@
class XTrial : public Trial {
public:
- TrialResult attempt()
+ TrialResult attempt()
{
UnkBGBatchTrialSpec s;
s.setNRecipients(100).setNAliceRecipients(5).setBatchSize(30)
@@ -24,7 +24,7 @@
return trial.attempt();
}
};
-
+
struct percentiles {
int min, p25, p50, p75, p90, p95, max;
};
@@ -34,7 +34,7 @@
getPercentile(Trial &test, int nTrials, percentiles &p)
{
std::vector<TrialResult> results(nTrials);
- std::vector<int> rounds(nTrials);
+ std::vector<int> rounds(nTrials);
for (int i = 0; i < nTrials; ++i) {
results[i] = test.attempt();
@@ -53,7 +53,7 @@
}
-int
+int
main(int c, char **v)
{
// SDTrial trial(10000, 10, 3000);
@@ -63,13 +63,13 @@
MixTrialSpec s;
s.setNRecipients(100).setNAliceRecipients(5).setPathLen(3).setPDelay(0.5)
.setExpAlice(0.5).setPMessage(0.6).setPDummy(0.2).setBGVolMean(30)
- .setBGVolDev(3).setPadding(0).setGranularity(20)
- .setPartial(true).setPObserve(.5).setCutoff(1000000);
+ .setBGVolDev(3).setPadding(0).setGranularity(100)
+ .setPartial(false).setPObserve(1.0).setCutoff(1000000);
MixTrial trial(s);
//MixTrial trial(100, 5, 3, 0.5, true, 0.6, 0.2, 30, 3, 0, 20, true, 0.4);
percentiles p;
getPercentile(trial, 2, p);
- cout << "======"
+ cout << "======"
<< p.min << " " << p.p50 << " "
<< p.p90 << " " << p.max << "=====" << endl;
Index: trials.cpp
===================================================================
RCS file: /home/freehaven/cvsroot/doc/e2e-traffic/src/trials.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- trials.cpp 23 Nov 2003 06:26:23 -0000 1.4
+++ trials.cpp 2 Dec 2003 20:15:46 -0000 1.5
@@ -51,7 +51,7 @@
mixnet->reset();
attacker->reset();
-
+
vec<int> trafficIn(nRecips, 0);
vec<double> recips(nRecips, 0.0);
@@ -107,13 +107,27 @@
}
void
+SDTrialSpec::write(std::ostream &o) const
+{
+ o << "SDTrial(b=" << batchSize << ",m="<< nAliceRecipients
+ << ",N=" << nRecipients << ")" << std::endl;
+}
+
+Trial *
+SDTrialSpec::create() const
+{
+ assertFilled();
+ return new SDTrial(*this);
+}
+
+void
SDTrial::init(int nR, int nAR, int b, int g, int c)
{
ConstDist<int> aMsgs(1);
ConstDist<int> aDummies(0);
truth = std::vector<int>(nAR, 0);
for (int i=0; i<nAR; ++i) { truth[i] = i; }
-
+
alice = new UniformAlice(truth, &aMsgs, &aDummies);
background = new UniformBackground(nR);
vec<double> uniform(nR, 1.0/b);
@@ -128,12 +142,38 @@
{
}
+
void
-UnkBGBatchTrial::init(int nR, int nAR, int b,
- bool smallworldAlice,
+UnkBGBatchTrialSpec::write(std::ostream &o) const
+{
+ o << "UnkBGBatchTrial(b="<<batchSize<<",m="<<nAliceRecipients
+ << ",N="<<nRecipients<<",aliceStrategy=";
+ if (aliceIsSmallworld)
+ o << "\"smallworld";
+ else
+ o << "\"uniform";
+ if (expMsgDist)
+ o << "-geometric\"";
+ else
+ o << "-uniform\"";
+ o << ",pMessage=" << pMsgAlice << ",pDummy=" << pDummyAlice
+ << ")" << std::endl;
+ // XXX paddingLevel is wrong, so include it when it's right.
+}
+
+Trial *
+UnkBGBatchTrialSpec::create() const
+{
+ assertFilled();
+ return new UnkBGBatchTrial(*this);
+}
+
+void
+UnkBGBatchTrial::init(int nR, int nAR, int b,
+ bool smallworldAlice,
bool expMsgDist,
double pMsgA, double pDA,
- int padding,
+ int padding, double pOnline,
int g, int c)
{
GeometricDist aMsgsE(1.0-pMsgA);
@@ -145,26 +185,26 @@
Dist<int> *backgroundTrafficDist = 0;
std::vector<int> *aliceRecipients = 0;
getCommunicationLinks(aliceRecipDist, backgroundTrafficDist,
- aliceRecipients,
+ aliceRecipients,
nAR, nR);
if (smallworldAlice) {
truth = *aliceRecipients;
if (expMsgDist)
- alice = new DistAlice(aliceRecipDist, &aMsgsE, &aDummiesE, padding);
+ alice = new DistAlice(aliceRecipDist, &aMsgsE, &aDummiesE, padding, pOnline);
else
- alice = new DistAlice(aliceRecipDist, &aMsgsB, &aDummiesB, padding);
+ alice = new DistAlice(aliceRecipDist, &aMsgsB, &aDummiesB, padding, pOnline);
} else {
truth = std::vector<int>(nAR, 0);
for (int i=0; i<nAR; ++i) { truth[i] = i; }
if (expMsgDist)
- alice = new UniformAlice(truth, &aMsgsE, &aDummiesE, padding);
+ alice = new UniformAlice(truth, &aMsgsE, &aDummiesE, padding, pOnline);
else
- alice = new UniformAlice(truth, &aMsgsB, &aDummiesB, padding);
+ alice = new UniformAlice(truth, &aMsgsB, &aDummiesB, padding, pOnline);
}
ConstDist<int> oneDist(1); // ignored.
background = new DistBackground(*backgroundTrafficDist, oneDist);
-
+
delete aliceRecipDist;
delete backgroundTrafficDist;
delete aliceRecipients;
@@ -183,7 +223,7 @@
// ======================================================================
-TrialResult
+TrialResult
NonbatchTrial::attempt()
{
TrialResult res;
@@ -197,7 +237,7 @@
vec<int> trafficIn(nRecips, 0);
vec<int> bTraffic(nRecips, 0);
vec<double> recips(nRecips, 0.0);
-
+
int n = 0;
while (1) {
trafficIn.reset(0);
@@ -243,38 +283,58 @@
}
}
-NonbatchTrial::~NonbatchTrial()
+NonbatchTrial::~NonbatchTrial()
{
- delete alice;
- delete background;
+ delete alice;
+ delete background;
delete mixnet;
delete attacker;
}
+
+void
+MixTrialSpec::write(std::ostream &o) const
+{
+ o << "MixTrial(N=" << nRecipients << ",m=" << nAliceRecipients
+ << ",l=" << pathLen << ",pDelay=" << pDelay;
+ // padding XXX all other vars.
+}
+
+Trial *
+MixTrialSpec::create() const
+{
+ assertFilled();
+ return new MixTrial(*this);
+}
+
void
MixTrial::init(int nR, int nAR, int pathLen, double pDelay,
bool expAlice, double pMessage, double pDummy,
- double bgVolMean, double bgVolDev, int padding,
- int g, bool partial, double pObserve, int c)
+ double bgVolMean, double bgVolDev,
+ double pOnline, int padding,
+ int g, bool partial, double pObserve, int c)
{
assert(pathLen > 0);
////
// Set up mixnet and attacker.
InvDist<int> *delayDist;
- int maxDelay = static_cast<int>(std::log(0.01)/std::log(pDelay))+1;
+ int maxDelay = static_cast<int>(std::log(0.001)/std::log(pDelay))*2+1;
+ std::cout << "MAXDELAY="<<maxDelay<<std::endl;
if (pathLen == 1) {
delayDist = getSingleMixDelays(pDelay);
} else {
delayDist = getMixNetDelays(ConstDist<int>(pathLen), pathLen+1,
pDelay, maxDelay);
}
-
+ std::cout << "Prob of delay (max-1) is = " << delayDist->getP(maxDelay-1)
+ << std::endl;
+
mixnet = new DelayMix(nR, maxDelay, delayDist);
attacker = new DelayMixAttacker(nR, maxDelay, delayDist);
if (partial)
attacker = new POAttacker(attacker, pObserve);
-
+
delete delayDist;
//// Set up small world.
@@ -282,7 +342,7 @@
Dist<int> *backgroundTrafficDist = 0;
std::vector<int> *aliceRecipients = 0;
getCommunicationLinks(aliceRecipDist, backgroundTrafficDist,
- aliceRecipients,
+ aliceRecipients,
nAR, nR);
//// set up alice.
@@ -293,16 +353,16 @@
truth = *aliceRecipients;
if (expAlice)
- alice = new DistAlice(aliceRecipDist, &aMsgsE, &aDummiesE, padding);
+ alice = new DistAlice(aliceRecipDist, &aMsgsE, &aDummiesE, padding, pOnline);
else
- alice = new DistAlice(aliceRecipDist, &aMsgsB, &aDummiesB, padding);
-
+ alice = new DistAlice(aliceRecipDist, &aMsgsB, &aDummiesB, padding, pOnline);
+
//// set up background.
background = new DistBackground(*backgroundTrafficDist,
IntNormalDist(bgVolMean, bgVolDev, true));
cutoff = c;
-
+
delete aliceRecipDist;
delete backgroundTrafficDist;
delete aliceRecipients;
Index: trials.h
===================================================================
RCS file: /home/freehaven/cvsroot/doc/e2e-traffic/src/trials.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- trials.h 23 Nov 2003 06:26:23 -0000 1.4
+++ trials.h 2 Dec 2003 20:15:46 -0000 1.5
@@ -7,10 +7,21 @@
#include "sim.h"
#include "rng.h"
+class Trial;
+
+class TrialSpec
+{
+ public:
+ TrialSpec() {}
+ virtual void write(std::ostream &o) const = 0;
+ virtual Trial *create() const = 0;
+ virtual ~TrialSpec() {}
+};
+
class TrialResult
{
public:
- TrialResult() {
+ TrialResult() {
nRounds = nRoundsAlice = nRoundsObserved = nRoundsMaybeAlice = 0;
nMsgs = nMsgsAlice = nMsgsAliceReal = 0L;
failed = false;
@@ -18,7 +29,7 @@
int nRounds;
int nRoundsAlice;
long nMsgs;
- long nMsgsAlice;
+ long nMsgsAlice;
long nMsgsAliceReal;
std::vector<int> roundsToGuessN;
@@ -33,7 +44,7 @@
};
-std::ostream &operator<<(std::ostream &out,
+std::ostream &operator<<(std::ostream &out,
const TrialResult &r);
class Trial {
@@ -62,7 +73,7 @@
virtual ~BatchTrial();
};
-class SDTrialSpec
+class SDTrialSpec : public TrialSpec
{
friend class SDTrial;
protected:
@@ -72,7 +83,7 @@
int granularity;
int cutoff;
public:
- SDTrialSpec() {
+ SDTrialSpec() {
granularity = 5; nRecipients = nAliceRecipients = batchSize = 0;
cutoff = 1000000000;
}
@@ -86,6 +97,8 @@
assert(nAliceRecipients > 0);
assert(batchSize > 0);
}
+ void write(std::ostream &o) const;
+ Trial *create() const;
};
// ========================================
@@ -95,7 +108,7 @@
// Alice has fixed list of recipients, chooses with equal probability.
class SDTrial : public BatchTrial {
protected:
- void init(int nRecipients, int nAliceRecipients, int batchSize,
+ void init(int nRecipients, int nAliceRecipients, int batchSize,
int granularity, int cutoff);
public:
SDTrial(const SDTrialSpec &s) {
@@ -113,18 +126,18 @@
// - follows smallworld distribution.
// Background distribution is unknown smallworld instance.
-class UnkBGBatchTrialSpec
+class UnkBGBatchTrialSpec : public TrialSpec
{
friend class UnkBGBatchTrial;
- protected:
+ protected:
int nRecipients, nAliceRecipients, batchSize;
bool aliceIsSmallworld, expMsgDist, ais_set, emd_set;
- double pMsgAlice, pDummyAlice;
+ double pMsgAlice, pDummyAlice, pOnline;
int paddingLevel, granularity;
int cutoff;
public:
- UnkBGBatchTrialSpec() {
- paddingLevel = 0; granularity = 5; cutoff = 1000000000;
+ UnkBGBatchTrialSpec() {
+ paddingLevel = 0; granularity = 5; cutoff = 1000000000; pOnline=1.0;
nRecipients = nAliceRecipients = batchSize = 0;
pMsgAlice = pDummyAlice = -1;
ais_set = emd_set = false;
@@ -136,9 +149,9 @@
UnkBGBatchTrialSpec &setGranularity(int n) { granularity = n; return *this; }
UnkBGBatchTrialSpec &setCutoff(int n) { cutoff = n; return *this; }
- UnkBGBatchTrialSpec &setAliceIsSmallworld(bool b) {
+ UnkBGBatchTrialSpec &setAliceIsSmallworld(bool b) {
aliceIsSmallworld = b; ais_set = true; return *this; }
- UnkBGBatchTrialSpec &setExpMsgDist(bool b) {
+ UnkBGBatchTrialSpec &setExpMsgDist(bool b) {
expMsgDist = b; emd_set = true; return *this; }
UnkBGBatchTrialSpec &setPMsgAlice(double p) { pMsgAlice = p; return *this; }
@@ -149,24 +162,27 @@
assert(pMsgAlice >= 0.0 && pDummyAlice >= 0.0);
assert(ais_set && emd_set);
}
+ void write(std::ostream &o) const;
+ Trial *create() const;
};
class UnkBGBatchTrial : public BatchTrial {
protected:
- void init(int nRecipients, int nAliceRecipients,
+ void init(int nRecipients, int nAliceRecipients,
int batchSize, bool aliceIsSmallworld,
bool expMsgDist, // if true, alice sends N msgs on exp. dist
double pMsgAlice, double pDummyAlice,
int paddingLevel=0, // if true, and if alice sends dummies in a round, she sends fillDummies messages total.
+ double pOnline=1.0,
int granularity=5, int cutoff=1000000000);
public:
UnkBGBatchTrial(const UnkBGBatchTrialSpec &s) {
s.assertFilled();
- init(s.nRecipients, s.nAliceRecipients, s.batchSize,
+ init(s.nRecipients, s.nAliceRecipients, s.batchSize,
s.aliceIsSmallworld, s.expMsgDist, s.pMsgAlice, s.pDummyAlice,
- s.paddingLevel, s.granularity, s.cutoff);
+ s.paddingLevel, s.pOnline, s.granularity, s.cutoff);
}
-
+
~UnkBGBatchTrial();
};
@@ -184,7 +200,7 @@
int nRecips;
int granularity;
int cutoff;
-
+
NonbatchTrial(int nR, int g) : alice(0), background(0), mixnet(0),
attacker(0), truth(nR), nRecips(nR), granularity(g) {}
public:
@@ -192,17 +208,17 @@
~NonbatchTrial();
};
-class MixTrialSpec {
+class MixTrialSpec : public TrialSpec {
friend class MixTrial;
protected:
int nRecipients, nAliceRecipients, pathLen, padding, granularity, cutoff;
bool expAlice, partial, ea_set, p_set;
- double pDelay, pMessage, pDummy, bgVolMean, bgVolDev, pObserve;
+ double pOnline, pDelay, pMessage, pDummy, bgVolMean, bgVolDev, pObserve;
public:
- MixTrialSpec() {
- padding = 0; granularity = 5; partial=false; pObserve=1.0;
+ MixTrialSpec() {
+ padding = 0; granularity = 5; partial=false; pObserve=1.0; pOnline=1.0;
cutoff = 1000000000;
-
+
nRecipients = nAliceRecipients = pathLen = 0;
ea_set = p_set = false;
pDelay = pMessage = pDummy = bgVolMean = bgVolDev = -1;
@@ -211,7 +227,7 @@
MixTrialSpec &setNAliceRecipients(int n) { nAliceRecipients = n; return *this; }
MixTrialSpec &setPathLen(int n) { pathLen = n; return *this; }
MixTrialSpec &setPadding(int n) { padding = n; return *this; }
- MixTrialSpec &setGranularity(int n) { granularity = n; return *this; }
+ MixTrialSpec &setGranularity(int n) { granularity = n; return *this; }
MixTrialSpec &setCutoff(int n) { cutoff = n; return *this; }
MixTrialSpec &setExpAlice(bool b) { expAlice = b; ea_set = true; return *this; }
@@ -223,7 +239,8 @@
MixTrialSpec &setBGVolMean(double d) { bgVolMean = d; return *this; }
MixTrialSpec &setBGVolDev(double d) { bgVolDev = d; return *this; }
MixTrialSpec &setPObserve(double d) { pObserve = d; return *this; }
-
+ MixTrialSpec &setPOnline(double d) { pOnline = d; return *this; }
+
void assertFilled() const {
assert(nRecipients && nAliceRecipients && pathLen);
assert(ea_set && p_set);
@@ -231,12 +248,15 @@
bgVolMean >= 0.0 && bgVolDev >= 0.0);
}
+ void write(std::ostream &o) const;
+ Trial *create() const;
+
};
// Trial with a single mix or a whole mixnet.
class MixTrial : public NonbatchTrial {
private:
- void init(int nRecipients, int nAliceRecipients,
+ void init(int nRecipients, int nAliceRecipients,
int pathLen, // 1 if using a single mix.
double pDelay, // probability of being delayed in a randomly chosen round.
bool expAlice, // alice uses exponential distribution.
@@ -244,18 +264,19 @@
double pDummy, // probability of Alice sending a dummy message
double bgVolMean, // \ Taken together, these two decide how many
double bgVolDev, // / messages the background sends in a round.
- int padding=0,
- int granularity=5,
- bool partial=false,
- double pObserve=1.0,
- int cutoff=1000000000
+ double pOnline,
+ int padding,
+ int granularity,
+ bool partial,
+ double pObserve,
+ int cutoff
);
public:
MixTrial(const MixTrialSpec &s) : NonbatchTrial(s.nRecipients, s.granularity)
{ s.assertFilled();
init(s.nRecipients, s.nAliceRecipients, s.pathLen, s.pDelay,
s.expAlice, s.pMessage, s.pDummy, s.bgVolMean, s.bgVolDev,
- s.padding, s.granularity, s.partial, s.pObserve, s.cutoff); }
+ s.pOnline, s.padding, s.granularity, s.partial, s.pObserve, s.cutoff); }
TrialResult attempt();
~MixTrial() {}
};
***********************************************************************
To unsubscribe, send an e-mail to majordomo@seul.org with
unsubscribe freehaven-cvs in the body. http://freehaven.net/