[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[freehaven-cvs] Add code for new padding trials.



Update of /home/freehaven/cvsroot/doc/e2e-traffic/src
In directory moria.mit.edu:/tmp/cvs-serv22587

Modified Files:
	sim.cpp sim.h simmain.cpp trials.cpp trials.h 
Added Files:
	PLAN.5 
Log Message:
Add code for new padding trials.

--- NEW FILE: PLAN.5 ---
New cases for preproceedings:

   5c: N=65536, nAlice=32, bgVol=125,
   pMsgAlice = 0.6

   padding = 2,4                 [2]
   smoothing = yes,no            [2]
   pDelay = .1, .6               [2]
   pathlen = 1, 4                [2]

   pOnline = .1, .3, .5, .7, .9  [5]

    5c.1: padding=2,smoothing=no, pD=.1,L=1,4
    5c.2: padding=2,smoothing=no, pD=.6,L=1,4
    5c.3: padding=2,smoothing=yes,pD=.1,L=1,4
    5c.4: padding=2,smoothing=yes,pD=.6,L=1,4
    5c.5: padding=4,smoothing=no, pD=.1,L=1,4
    5c.6: padding=4,smoothing=no, pD=.6,L=1,4
    5c.7: padding=4,smoothing=yes,pD=.1,L=1,4
    5c.8: padding=4,smoothing=yes,pD=.6,L=1,4




Index: sim.cpp
===================================================================
RCS file: /home/freehaven/cvsroot/doc/e2e-traffic/src/sim.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- sim.cpp	24 Jan 2004 05:49:24 -0000	1.11
+++ sim.cpp	8 Apr 2004 21:24:35 -0000	1.12
@@ -16,17 +16,39 @@
   if (pSend < 1.0 && rng() > pSend)
     return;
   n_out = nM = nMessageDist->get();
+  if (padding && nPending && nM < padding) {
+    if (nPending < (padding-nM)) {
+      n_out += nPending;
+      nM = n_out;
+      nPending = 0;
+    } else {
+      nPending -= (padding-nM);
+      n_out = nM = padding;
+    }
+  }
   for (int i = 0; i < n_out; ++i) {
     ++ v_out[recipientDist->get()];
   }
   if (padding) {
-    if (padding>nM)
+    if (nM>padding) {
+      if (smoothPadding) {
+	nPending += (nM-padding);
+	n_out = padding;
+      }
+    } else {
       n_out = padding;
+    }
   } else if (nDummyDist) {
     n_out += nDummyDist->get();
   }
 }
 
+void
+DistAlice::reset()
+{
+  nPending = 0;
+}
+
 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)

Index: sim.h
===================================================================
RCS file: /home/freehaven/cvsroot/doc/e2e-traffic/src/sim.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- sim.h	11 Dec 2003 11:07:51 -0000	1.7
+++ sim.h	8 Apr 2004 21:24:35 -0000	1.8
@@ -21,6 +21,7 @@
   // Add messages for a single round to the vector v_add.  Set nAdd
   // to the number of messages sent in this round.
   virtual void addTraffic(vec<int> &v_add, int &nAdd) = 0;
+  virtual void reset() {};
   virtual ~Alice();
 };
 
@@ -88,16 +89,22 @@
   Dist<int> *nMessageDist;
   Dist<int> *nDummyDist;
   Dist<int> *recipientDist;
-  // if padding is >0, and we send any dummies, we instead send >=padding
+  int nPending;
+  // if padding is >0, and we send any messages, we instead send >=padding
   int padding;
+  // if smoothpadding, we never send > padding.
   double pSend;
+  bool smoothPadding;
   DistAlice() : nMessageDist(0), nDummyDist(0), recipientDist(0), padding(0) {}
  public:
   DistAlice(Dist<int> *recips, Dist<int> *msgs, Dist<int> *dummies,
-            int p=0, double pSendAny=1.0)
+            int p=0, double pSendAny=1.0, bool sm=false)
     : nMessageDist(msgs->copy()), nDummyDist(dummies->copy()),
-      recipientDist(recips->copy()), padding(p), pSend(pSendAny) {}
+      recipientDist(recips->copy()), padding(p), pSend(pSendAny),
+      smoothPadding(sm)
+  {}
   void addTraffic(vec<int> &v_out, int &nOut);
+  void reset();
   ~DistAlice() { delete nMessageDist; delete nDummyDist; delete recipientDist;}
 };
 

Index: simmain.cpp
===================================================================
RCS file: /home/freehaven/cvsroot/doc/e2e-traffic/src/simmain.cpp,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- simmain.cpp	8 Apr 2004 19:53:10 -0000	1.34
+++ simmain.cpp	8 Apr 2004 21:24:35 -0000	1.35
@@ -276,7 +276,7 @@
       std::cout << "\"" << i << "/" << 100 << "\"" << std::endl;
       UnkBGBatchTrial trial(s);
       TrialResult res = trial.attempt();
-      std::cout << res << std::endl << std::endl; 
+      std::cout << res << std::endl << std::endl;
       if (res.failed)
 	++nBad;
       else
@@ -335,7 +335,7 @@
 void trial2u_base(int batchSize, int nRecips, int nAMin, int nAMax,
 		  int nAStep,
 		  double pMsg, bool sgw=false)
-		  
+
 {
   for (int nAR = nAMin; (nAR <= nAMax && nAR < nRecips); nAR *= nAStep) {
     for (int strategy=0; strategy < 2; ++strategy) {
@@ -348,7 +348,7 @@
 	.setExpMsgDist(pMsg)
 	.setPMsgAlice(0.9)
 	.setPDummyAlice(0.0);
-    
+
       if (sgw) {
 	s.setAliceIsSmallworld(1).setWeightAlice(1);
       } else {
@@ -356,8 +356,8 @@
 	  s.setAliceIsSmallworld(0).setWeightAlice(0);
 	else
 	  s.setAliceIsSmallworld(1).setWeightAlice(0);
-      } 
-      
+      }
+
       s.setGranularity(10);
       s.setCutoff(1000000);
       int nBad = 0;
@@ -367,7 +367,7 @@
 	std::cout << "\"" << i << "/" << 100 << "\"" << std::endl;
 	UnkBGBatchTrial trial(s);
 	TrialResult res = trial.attempt();
-	std::cout << res << std::endl << std::endl; 
+	std::cout << res << std::endl << std::endl;
 	if (res.failed)
 	  ++nBad;
 	else
@@ -424,7 +424,7 @@
 void trial2r_base(int batchSize, int nRecips, int nAMin, int nAMax,
 		  int nAStep,
 		  double pMsg, bool sgw=false)
-		  
+
 {
   for (int nAR = nAMin; (nAR <= nAMax && nAR < nRecips); nAR *= nAStep) {
     UnkBGBatchTrialSpec s;
@@ -433,13 +433,13 @@
       .setExpMsgDist(pMsg)
       .setPMsgAlice(0.9)
       .setPDummyAlice(0.0);
-    
+
     if (sgw) {
       s.setAliceIsSmallworld(1).setWeightAlice(1);
     } else {
       s.setAliceIsSmallworld(1).setWeightAlice(0);
-    } 
-      
+    }
+
     s.setGranularity(2);
     s.setCutoff(1000000);
     int nBad = 0;
@@ -449,7 +449,7 @@
       std::cout << "\"" << i << "/" << 100 << "\"" << std::endl;
       UnkBGBatchTrial trial(s);
       TrialResult res = trial.attempt();
-      std::cout << res << std::endl << std::endl; 
+      std::cout << res << std::endl << std::endl;
       if (res.failed)
 	++nBad;
       else
@@ -512,7 +512,7 @@
 	  std::cout << "\"" << i << "/" << 100 << "\"" << std::endl;
 	  MixTrial trial(s);
 	  TrialResult res = trial.attempt();
-	  std::cout << res << std::endl << std::endl; 
+	  std::cout << res << std::endl << std::endl;
 	  if (res.failed)
 	    ++nBad;
 	  else
@@ -533,7 +533,7 @@
     .setPathLen(1).setPadding(0)
     .setExpAlice(1)
     .setPartial(false)
-    
+
     .setPDelay(pDel)
     .setPMessage(pMsgA)
     .setBGVolMean(bg).setBGVolDev(bg/10.0)
@@ -541,7 +541,7 @@
     .setPDummy(0.0);
 
   s.setGranularity(50);
-  
+
   s.setCutoff(1500000);
   int nBad = 0;
   int nGood = 0;
@@ -550,7 +550,7 @@
     std::cout << "\"" << i << "/" << 100 << "\"" << std::endl;
     MixTrial trial(s);
     TrialResult res = trial.attempt();
-    std::cout << res << std::endl << std::endl; 
+    std::cout << res << std::endl << std::endl;
     if (res.failed)
       ++nBad;
     else
@@ -719,7 +719,7 @@
     .setExpAlice(1)
     .setPMessage(1.0)
     .setPartial(false)
-    
+
     .setPDelay(pDel)
     .setPMessage(pMsgA)
     .setBGVolMean(bgVol).setBGVolDev(bgVol/10.0)
@@ -727,7 +727,7 @@
     .setPDummy(0.0);
 
   s.setGranularity(25);
-  
+
   s.setCutoff(1000000);
   int nBad = 0;
   int nGood = 0;
@@ -736,7 +736,7 @@
     std::cout << "\"" << i << "/" << 100 << "\"" << std::endl;
     MixTrial trial(s);
     TrialResult res = trial.attempt();
-    std::cout << res << std::endl << std::endl; 
+    std::cout << res << std::endl << std::endl;
     if (res.failed)
       ++nBad;
     else
@@ -879,7 +879,7 @@
     .setExpAlice(1)
     .setPartial(false)
     .setPOnline(1.0)
-   
+
     .setPDelay(pDelay)
     .setPMessage(pMsgA)
     .setBGVolMean(125).setBGVolDev(125/10.0)
@@ -895,7 +895,7 @@
     std::cout << "\"" << i << "/" << 100 << "\"" << std::endl;
     MixTrial trial(s);
     TrialResult res = trial.attempt();
-    std::cout << res << std::endl << std::endl; 
+    std::cout << res << std::endl << std::endl;
     if (res.failed)
       ++nBad;
     else
@@ -998,7 +998,7 @@
     .setExpAlice(1)
     .setPartial(false)
     .setPOnline(pOnline)
-   
+
     .setPDelay(pDelay)
     .setPMessage(pMsgA)
     .setBGVolMean(125).setBGVolDev(125/10.0)
@@ -1006,7 +1006,7 @@
     .setPDummy(0.0);
 
   s.setGranularity(10);
-  
+
   s.setCutoff(1000000);
   int nBad = 0;
   int nGood = 0;
@@ -1015,7 +1015,7 @@
     std::cout << "\"" << i << "/" << 100 << "\"" << std::endl;
     MixTrial trial(s);
     TrialResult res = trial.attempt();
-    std::cout << res << std::endl << std::endl; 
+    std::cout << res << std::endl << std::endl;
     if (res.failed)
       ++nBad;
     else
@@ -1125,6 +1125,111 @@
   trial5b_base(.9,.1,2,.1,1);
 }
 
+void trial5c_base(double pOnline, int nPad, int smooth, double pDelay,
+		  int pathLen, double pMsg=0.6)
+{
+  MixTrialSpec s;
+
+  s.setNRecipients(65536).setNAliceRecipients(32)
+    .setPathLen(pathLen).setPadding(nPad).setSmoothPadding(smooth)
+    .setExpAlice(1)
+    .setPartial(false)
+    .setPOnline(pOnline)
+    .setPDelay(pDelay)
+    .setPMessage(pMsg)
+    .setBGVolMean(125).setBGVolDev(125/10.0)
+    .setPObserve(1.0)
+    .setPDummy(0.0);
+
+  s.setGranularity(10);
+
+  s.setCutoff(1000000);
+  int nBad = 0;
+  int nGood = 0;
+  for (int i = 1; i <= 100; ++i) {
+    s.write(std::cout);
+    std::cout << "\"" << i << "/" << 100 << "\"" << std::endl;
+    MixTrial trial(s);
+    TrialResult res = trial.attempt();
+    std::cout << res << std::endl << std::endl;
+    if (res.failed)
+      ++nBad;
+    else
+      ++nGood;
+    if (nBad >= 5 && nGood < nBad/2) {
+      break;
+    }
+  }
+}
+
+void trial5c_1()
+{
+  for(int pTrial=1; pTrial <= 9; pTrial +=2) {
+    for (int L=1; L <= 4; L +=3) {
+      trial5c_base(pTrial*0.1, 2, false, .1, L);
+    }
+  }
+}
+
+void trial5c_2()
+{
+  for(int pTrial=1; pTrial <= 9; pTrial +=2) {
+    for (int L=1; L <= 4; L +=3) {
+      trial5c_base(pTrial*0.1, 2, false, .6, L);
+    }
+  }
+}
+void trial5c_3()
+{
+  for(int pTrial=1; pTrial <= 9; pTrial +=2) {
+    for (int L=1; L <= 4; L +=3) {
+      trial5c_base(pTrial*0.1, 2, true, .1, L);
+    }
+  }
+}
+void trial5c_4()
+{
+  for(int pTrial=1; pTrial <= 9; pTrial +=2) {
+    for (int L=1; L <= 4; L +=3) {
+      trial5c_base(pTrial*0.1, 2, true, .6, L);
+    }
+  }
+}
+void trial5c_5()
+{
+  for(int pTrial=1; pTrial <= 9; pTrial +=2) {
+    for (int L=1; L <= 4; L +=3) {
+      trial5c_base(pTrial*0.1, 4, false, .1, L);
+    }
+  }
+}
+void trial5c_6()
+{
+  for(int pTrial=1; pTrial <= 9; pTrial +=2) {
+    for (int L=1; L <= 4; L +=3) {
+      trial5c_base(pTrial*0.1, 4, false, .6, L);
+    }
+  }
+}
+void trial5c_7()
+{
+  for(int pTrial=1; pTrial <= 9; pTrial +=2) {
+    for (int L=1; L <= 4; L +=3) {
+      trial5c_base(pTrial*0.1, 4, true, .1, L);
+    }
+  }
+}
+void trial5c_8()
+{
+  for(int pTrial=1; pTrial <= 9; pTrial +=2) {
+    for (int L=1; L <= 4; L +=3) {
+      trial5c_base(pTrial*0.1, 4, true, .6, L);
+    }
+  }
+}
+
+
+
 void trial6_base(double pDelay, double pObserve)
 {
   MixTrialSpec s;
@@ -1133,7 +1238,7 @@
     .setExpAlice(1)
     .setPMessage(1.0)
     .setPartial(true)
-    
+
     .setPDelay(pDelay)
     .setPMessage(0.6)
     .setBGVolMean(125).setBGVolDev(125/10.0)
@@ -1141,7 +1246,7 @@
     .setPDummy(0.0);
 
   s.setGranularity(50);
-  
+
   s.setCutoff(1000000);
   int nBad = 0;
   int nGood = 0;
@@ -1150,7 +1255,7 @@
     std::cout << "\"" << i << "/" << 100 << "\"" << std::endl;
     MixTrial trial(s);
     TrialResult res = trial.attempt();
-    std::cout << res << std::endl << std::endl; 
+    std::cout << res << std::endl << std::endl;
     if (res.failed)
       ++nBad;
     else
@@ -1313,6 +1418,15 @@
   { "5b.11", trial5b_11 },
   { "5b.12", trial5b_12 },
 
+  { "5c.1", trial5c_1 },
+  { "5c.2", trial5c_2 },
+  { "5c.3", trial5c_3 },
+  { "5c.4", trial5c_4 },
+  { "5c.5", trial5c_5 },
+  { "5c.6", trial5c_6 },
+  { "5c.7", trial5c_7 },
+  { "5c.8", trial5c_8 },
+
   { "6.1",    trial6_1 },
   { "6.2",    trial6_2 },
   { "6.3",    trial6_3 },

Index: trials.cpp
===================================================================
RCS file: /home/freehaven/cvsroot/doc/e2e-traffic/src/trials.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- trials.cpp	24 Jan 2004 05:49:24 -0000	1.15
+++ trials.cpp	8 Apr 2004 21:24:35 -0000	1.16
@@ -40,6 +40,7 @@
 
   mixnet->reset();
   attacker->reset();
+  alice->reset();
 
   vec<int> trafficIn(nRecips, 0);
   vec<double> recips(nRecips, 0.0);
@@ -222,12 +223,14 @@
 NonbatchTrial::attempt()
 {
   TrialResult res;
+  int gran = granularity;
   res.roundsToGuessN.reserve(truth.size());
   res.roundsToGuessN.push_back(0);
   unsigned int nGuessed = 0;
 
   attacker->reset();
   mixnet->reset();
+  alice->reset();
 
   vec<int> trafficIn(nRecips, 0);
   vec<int> bTraffic(nRecips, 0);
@@ -248,7 +251,9 @@
     res.nMsgs += nAlice + nBackground;
     mixnet->addRound(trafficIn, nAlice, nBackground, attacker);
     ++n;
-    if (!(n % granularity)) {
+    if (!(n % gran)) {
+      if (n>=(gran*20) && gran <= granularity*128)
+	gran *= 2;
       if (n > cutoff) {
 	attacker->guessAlice(recips);
 	res.nRounds = n;
@@ -291,10 +296,11 @@
 MixTrialSpec::write(std::ostream &o) const
 {
   o << "MixTrial(N=" << nRecipients << ",m=" << nAliceRecipients
-    << ",l=" << pathLen << ",pDelay=" << pDelay 
+    << ",l=" << pathLen << ",pDelay=" << pDelay
     << ",bgVolume=" << bgVolMean << ",bgVolumeStdDev=" << bgVolDev
-    << ",pObserve=" << pObserve << ",pading="<<padding
-    << ",pOnline=" << pOnline << ",pMessage="<<pMessage 
+    << ",pObserve=" << pObserve << ",padding="<<padding
+    << ",smoothPadding" << smoothPadding
+    << ",pOnline=" << pOnline << ",pMessage="<<pMessage
     << ",pDummy=" << pDummy
     << ",granularity=" << granularity
     << ")" << std::endl;
@@ -312,9 +318,9 @@
 
 void
 MixTrial::init(int nR, int nAR, int pathLen, double pDelay,
-                   bool expAlice, double pMessage, double pDummy,
-                   double bgVolMean, double bgVolDev,
-	       double pOnline, int padding,
+	       bool expAlice, double pMessage, double pDummy,
+	       double bgVolMean, double bgVolDev,
+	       double pOnline, int padding, bool smoothPadding,
 	       int g, bool partial, double pObserve, int c)
 {
   assert(pathLen > 0);
@@ -375,9 +381,11 @@
 
   truth = *aliceRecipients;
   if (expAlice)
-    alice = new DistAlice(aliceRecipDist, &aMsgsE, &aDummiesE, padding, pOnline);
+    alice = new DistAlice(aliceRecipDist,&aMsgsE, &aDummiesE, padding, pOnline,
+			  smoothPadding);
   else
-    alice = new DistAlice(aliceRecipDist, &aMsgsB, &aDummiesB, padding, pOnline);
+    alice = new DistAlice(aliceRecipDist,&aMsgsB, &aDummiesB, padding, pOnline,
+			  smoothPadding);
   cout << "bgAlice={";
   for (int i = 0; i < nAR; ++i)
     cout << truth[i] << ":" << backgroundTrafficDist->getP(i) << ",";

Index: trials.h
===================================================================
RCS file: /home/freehaven/cvsroot/doc/e2e-traffic/src/trials.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- trials.h	8 Jan 2004 03:57:30 -0000	1.9
+++ trials.h	8 Apr 2004 21:24:35 -0000	1.10
@@ -216,7 +216,7 @@
   friend class MixTrial;
  protected:
   int nRecipients, nAliceRecipients, pathLen, padding, granularity, cutoff;
-  bool expAlice, partial, ea_set, p_set;
+  bool expAlice, partial, ea_set, p_set, smoothPadding;
   double pOnline, pDelay, pMessage, pDummy, bgVolMean, bgVolDev, pObserve;
  public:
   MixTrialSpec() {
@@ -224,7 +224,7 @@
     cutoff = 1000000000;
 
     nRecipients = nAliceRecipients = pathLen = 0;
-    ea_set = p_set = false;
+    ea_set = p_set = smoothPadding = false;
     pDelay = pMessage = pDummy = bgVolMean = bgVolDev = -1;
   }
   MixTrialSpec &setNRecipients(int n) { nRecipients = n; return *this; }
@@ -233,6 +233,7 @@
   MixTrialSpec &setPadding(int n) { padding = n; return *this; }
   MixTrialSpec &setGranularity(int n) { granularity = n; return *this; }
   MixTrialSpec &setCutoff(int n) { cutoff = n; return *this; }
+  MixTrialSpec &setSmoothPadding(bool b) { smoothPadding = b; return *this; }
 
   // rename to geometric.
   MixTrialSpec &setExpAlice(bool b) { expAlice = b; ea_set = true; return *this; }
@@ -274,6 +275,7 @@
 	    double bgVolDev,  // / messages the background sends in a round.
 	    double pOnline,
 	    int padding,
+	    bool smoothPadding,
 	    int granularity,
 	    bool partial,
 	    double pObserve,
@@ -284,7 +286,8 @@
     { s.assertFilled();
       init(s.nRecipients, s.nAliceRecipients, s.pathLen, s.pDelay,
 	   s.expAlice, s.pMessage, s.pDummy, s.bgVolMean, s.bgVolDev,
-	   s.pOnline, s.padding, s.granularity, s.partial, s.pObserve, s.cutoff); }
+	   s.pOnline, s.padding, s.smoothPadding,
+	   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/