From: victor Date: Wed, 7 Oct 2009 11:29:59 +0000 (+0000) Subject: integration in progress X-Git-Url: http://p2p-next.cs.pub.ro/gitweb/?a=commitdiff_plain;h=03a9743d67e800a5eaaa46c8fecf5b4a63cca8ba;p=swift-upb.git integration in progress git-svn-id: https://ttuki.vtt.fi/svn/p2p-next/TUD/p2tp/trunk@394 e16421f0-f15b-0410-abcd-98678b794739 --- diff --git a/doc/binmaps-alenex.pdf b/doc/binmaps-alenex.pdf new file mode 100644 index 0000000..d67b8c2 Binary files /dev/null and b/doc/binmaps-alenex.pdf differ diff --git a/doc/lancaster.txt b/doc/lancaster.txt deleted file mode 100644 index d4d79cb..0000000 --- a/doc/lancaster.txt +++ /dev/null @@ -1,27 +0,0 @@ -* MISSION : <1 min - * multiparty transport protocol - * diverse usecases (files, VoD, live) - * for embedded 24x7 use -* OBJECTIVES : 1 min - * light footprint (embedded) - * NAT penetration - * non-intrusive congestion control - * genericity -* METHOD : 1 min - * UDP - * LEDBAT (Mugurel) - * common messages - * Merkle hashes - * binmaps -* STATUS : 5 min - * state machine: implemented - * congestion control: implemented - * binmaps: implemented - * streaming: in progress - * todo: test, integrate, test -* HELP NEEDED : 4 min - * testing - * security - * robustness - * usecases - diff --git a/doc/p2tp-lancaster.pdf b/doc/p2tp-lancaster.pdf new file mode 100755 index 0000000..4bed32b Binary files /dev/null and b/doc/p2tp-lancaster.pdf differ diff --git a/doc/p2tp-uml-er.pdf b/doc/p2tp-uml-er.pdf new file mode 100644 index 0000000..4d858ec Binary files /dev/null and b/doc/p2tp-uml-er.pdf differ diff --git a/file.h b/file.h deleted file mode 100644 index 29e8f6b..0000000 --- a/file.h +++ /dev/null @@ -1,62 +0,0 @@ -#include - -namespace p2tp { - - class File { - - typedef enum {EMPTY,IN_PROGRESS,DONE} status_t; - - static std::vector files; - - /** File descriptor. */ - int fd; - /** Whether the file is completely downloaded. */ - status_t status_; - - // A map for all packets obtained and succesfully checked. - bins ack_out; - // Hinted packets. - bins hint_out; - - HashTree hashes; - // History of bin retrieval. - bin::vec history; - - // TBD - uint64_t options; - - /** Submit a fresh file. */ - File (int fd); - /** Retrieve a file. */ - File (Sha1Hash hash, int fd); - /** Placeholder. */ - File () : fd(-1), hashes(Sha1Hash::ZERO) {} - /** Close everything. */ - ~File(); - - bool OfferHash (bin pos, const Sha1Hash& hash); - const Sha1Hash& root_hash () const { return hashes.root; } - size_t size () const { return hashes.data_size()<<10; } - size_t packet_size () const { return hashes.data_size(); } - status_t status () const { return status_; } - - static File* find (const Sha1Hash& hash); - static File* file (int fd) { return fd +#include +#include +#include "bins.h" + + +TEST(BinsTest,Routines) { + + uint32_t cell = (3<<10) | (3<<14) | (3<<0); + uint16_t correct = (1<<5) | (1<<7) | (1<<0); + uint16_t joined = bins::join32to16(cell); + EXPECT_EQ(correct,joined); + + uint32_t split = bins::split16to32(correct); + EXPECT_EQ(cell,split); + + EXPECT_EQ(bins::NOJOIN,bins::join32to16(cell|4)); + +} + +TEST(BinsTest,SetGet) { + + bins bs; + bin64_t b3(1,0), b2(0,1), b4(0,2), b6(1,1), b7(2,0); + bs.set(b3); + //bs.dump("set done"); + EXPECT_EQ(bins::FILLED,bs.get(b3)); + //bs.dump("set checkd"); + EXPECT_EQ(bins::FILLED,bs.get(b2)); + //bs.dump("get b2 done"); + EXPECT_EQ(bins::FILLED,bs.get(b3)); + //bs.dump("get b3 done"); + EXPECT_EQ(bins::EMPTY,bs.get(b4)); + EXPECT_EQ(bins::EMPTY,bs.get(b6)); + EXPECT_NE(bins::FILLED,bs.get(b7)); + EXPECT_NE(bins::EMPTY,bs.get(b7)); + EXPECT_EQ(bins::FILLED,bs.get(b3)); + bs.set(bin64_t(1,1)); + EXPECT_EQ(bins::FILLED,bs.get(bin64_t(2,0))); + +} + +TEST(BinsTest,Iterator) { + bins b; + b.set(bin64_t(3,1)); + iterator i(&b,0,false); + while (!i.solid()) + i.left(); + EXPECT_EQ(bin64_t(3,0),i.bin()); + EXPECT_EQ(false,i.deep()); + EXPECT_EQ(true,i.solid()); + EXPECT_EQ(bins::EMPTY,*i); + i.next(); + EXPECT_EQ(bin64_t(3,1),i.bin()); + EXPECT_EQ(false,i.deep()); + EXPECT_EQ(true,i.solid()); + EXPECT_EQ(bins::FILLED,*i); + i.next(); + EXPECT_TRUE(i.end()); +} + +TEST(BinsTest,Chess) { + bins chess16; + for(int i=0; i<15; i++) + chess16.set(bin64_t(0,i), (i&1)?bins::FILLED:bins::EMPTY); + chess16.set(bin64_t(0,15), bins::FILLED); + for(int i=0; i<16; i++) + EXPECT_EQ((i&1)?bins::FILLED:bins::EMPTY, chess16.get(bin64_t(0,i))); + EXPECT_NE(bins::FILLED,chess16.get(bin64_t(4,0))); + EXPECT_NE(bins::EMPTY,chess16.get(bin64_t(4,0))); + for(int i=0; i<16; i+=2) + chess16.set(bin64_t(0,i), bins::FILLED); + EXPECT_EQ(bins::FILLED,chess16.get(bin64_t(4,0))); + EXPECT_EQ(bins::FILLED,chess16.get(bin64_t(2,3))); + + chess16.set(bin64_t(4,1),bins::FILLED); + EXPECT_EQ(bins::FILLED,chess16.get(bin64_t(5,0))); +} + +TEST(BinsTest,Staircase) { + + const int TOPLAYR = 44; + bins staircase; + for(int i=0;i s; + clock_t start, end; + double b_time, s_time; + int b_size, s_size; + + start = clock(); + for(int i=1; i<(1<<20); i++) + b |= bin(i); + //b_size = b.bits.size(); + end = clock(); + b_time = ((double) (end - start)) / CLOCKS_PER_SEC; + //ASSERT_EQ(1,b.bits.size()); + + start = clock(); + for(int i=1; i<(1<<20); i++) + s.insert(i); + s_size = s.size(); + end = clock(); + s_time = ((double) (end - start)) / CLOCKS_PER_SEC; + + printf("bins: %f (%i), set: %f (%i)\n",b_time,b_size,s_time,s_size); +}*/ + +int main (int argc, char** argv) { + testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +}