From: Victor Grishchenko Date: Tue, 26 Jan 2010 16:27:36 +0000 (+0100) Subject: Renamed p2tp to swift everywhere. X-Git-Url: http://p2p-next.cs.pub.ro/gitweb/?a=commitdiff_plain;h=5192959cd179b2a9e0e21bf4a6786e2c16c70583;p=swift-upb.git Renamed p2tp to swift everywhere. For the purpose of consistency. --- diff --git a/bin64.cpp b/bin64.cpp index 6b2ccb5..bb26154 100644 --- a/bin64.cpp +++ b/bin64.cpp @@ -1,6 +1,6 @@ /* * bin64.cpp - * p2tp + * swift * * Created by Victor Grishchenko on 10/10/09. * Copyright 2009 Delft University of Technology. All rights reserved. diff --git a/compat.cpp b/compat.cpp index 0945744..c81bdbf 100644 --- a/compat.cpp +++ b/compat.cpp @@ -1,6 +1,6 @@ /* * compat.cpp - * p2tp + * swift * * Created by Arno Bakker, Victor Grishchenko * Copyright 2009 Delft University of Technology. All rights reserved. @@ -21,7 +21,7 @@ #include #endif -namespace p2tp { +namespace swift { #ifdef _WIN32 static HANDLE map_handles[1024]; diff --git a/compat.h b/compat.h index 1bfeedf..ffd1378 100644 --- a/compat.h +++ b/compat.h @@ -33,7 +33,7 @@ #define S_IROTH _S_IREAD #endif -namespace p2tp { +namespace swift { /** tint is the time integer type; microsecond-precise. */ typedef int64_t tint; diff --git a/compat/hirestimeofday.cpp b/compat/hirestimeofday.cpp index f5aad7c..29595be 100644 --- a/compat/hirestimeofday.cpp +++ b/compat/hirestimeofday.cpp @@ -11,7 +11,7 @@ #include #endif -namespace p2tp { +namespace swift { HiResTimeOfDay* HiResTimeOfDay::_instance = 0; @@ -112,7 +112,7 @@ tint HiResTimeOfDay::getTimeUSec(void) -// ARNOTODO: move to p2tp.cpp +// ARNOTODO: move to swift.cpp #ifdef _WIN32 static WSADATA _WSAData; @@ -138,7 +138,7 @@ void LibraryInit(void) #ifdef TEST #include -using namespace p2tp; +using namespace swift; int main() { diff --git a/compat/hirestimeofday.h b/compat/hirestimeofday.h index 731da1e..362dd96 100644 --- a/compat/hirestimeofday.h +++ b/compat/hirestimeofday.h @@ -17,7 +17,7 @@ #include #endif -namespace p2tp { +namespace swift { typedef int64_t tint; #define TINT_SEC ((tint)1000000) diff --git a/compat/util.cpp b/compat/util.cpp index 281dfac..579ef84 100644 --- a/compat/util.cpp +++ b/compat/util.cpp @@ -11,7 +11,7 @@ #include #endif -namespace p2tp +namespace swift { std::string gettmpdir(void) diff --git a/compat/util.h b/compat/util.h index aa99df6..dd9256b 100644 --- a/compat/util.h +++ b/compat/util.h @@ -10,7 +10,7 @@ #include -namespace p2tp +namespace swift { /** * Return path of temporary directory. diff --git a/datagram.cpp b/datagram.cpp index 76ec217..93124e0 100644 --- a/datagram.cpp +++ b/datagram.cpp @@ -19,7 +19,7 @@ #include "datagram.h" #include "compat.h" -namespace p2tp { +namespace swift { tint Datagram::now = Datagram::Time(); tint Datagram::start = now; diff --git a/datagram.h b/datagram.h index 6866be1..30a9ec3 100644 --- a/datagram.h +++ b/datagram.h @@ -37,7 +37,7 @@ #include "compat.h" -namespace p2tp { +namespace swift { #define MAXDGRAMSZ 2800 #ifndef _WIN32 diff --git a/exec/hasher.cpp b/exec/hasher.cpp index 1e7127e..c95f119 100644 --- a/exec/hasher.cpp +++ b/exec/hasher.cpp @@ -1,6 +1,6 @@ /* * hasher.cpp - * p2tp + * swift * * Created by Victor Grishchenko on 11/8/09. * Copyright 2009 Delft University of Technology. All rights reserved. @@ -17,7 +17,7 @@ int main (int argn, char** args) { return 1; } - p2tp::HashTree* ht = new p2tp::HashTree(args[1]); + swift::HashTree* ht = new swift::HashTree(args[1]); printf("SHA1 Merkle tree root hash: %s\n",ht->root_hash().hex().c_str()); diff --git a/exec/leecher.cpp b/exec/leecher.cpp index ff08ad8..38cdaa7 100644 --- a/exec/leecher.cpp +++ b/exec/leecher.cpp @@ -1,16 +1,16 @@ /* * leecher.cpp - * p2tp + * swift * * Created by Victor Grishchenko on 11/3/09. * Copyright 2009 Delft University of Technology. All rights reserved. * */ -#include "p2tp.h" +#include "swift.h" #include -using namespace p2tp; +using namespace swift; /** P2TP downloader. Params: root hash, filename, tracker ip/port, own ip/port */ @@ -28,7 +28,7 @@ int main (int argn, char** args) { return -2; } - p2tp::LibraryInit(); + swift::LibraryInit(); char* filename = args[2]; @@ -43,28 +43,28 @@ int main (int argn, char** args) { else bindaddr = Address((uint32_t)INADDR_ANY,rand()%10000+7000); - assert(0=4) { Address tracker(args[3]); - p2tp::SetTracker(tracker); + swift::SetTracker(tracker); } Address bindaddr(args[2]); @@ -35,22 +35,22 @@ int main (int argn, char** args) { return -2; } - assert(0 #include #include "compat/util.h" @@ -15,7 +15,7 @@ #endif -using namespace p2tp; +using namespace swift; /** P2TP downloader. Params: root hash, filename, tracker ip/port, own ip/port */ @@ -23,7 +23,7 @@ int main (int argn, char** args) { THIS IS NOT TRIAL BRANCH srand(time(NULL)); Sha1Hash root_hash(true,"32e5d9d2d8c0f6073e2820cf47b15b58c2e42a23"); - p2tp::LibraryInit(); + swift::LibraryInit(); // Arno: use tempdir std::string tmpdir = gettmpdir(); @@ -37,27 +37,27 @@ int main (int argn, char** args) { bindaddr((uint32_t)INADDR_ANY,10000), fallback("victor2.p2p-next.org:12345"); - if (0>p2tp::Listen(bindaddr)) { + if (0>swift::Listen(bindaddr)) { print_error("cannot bind"); return 1; } - p2tp::SetTracker(tracker); - int file = p2tp::Open(filename,root_hash); + swift::SetTracker(tracker); + int file = swift::Open(filename,root_hash); printf("Downloading %s\n",root_hash.hex().c_str()); int count = 400; - while (!p2tp::IsComplete(file) && count-->0) { - p2tp::Loop(TINT_SEC/10); + while (!swift::IsComplete(file) && count-->0) { + swift::Loop(TINT_SEC/10); if (count==100) FileTransfer::file(file)->OnPexIn(fallback); printf("done %lli of %lli (seq %lli) %lli dgram %lli bytes up, %lli dgram %lli bytes down\n", - p2tp::Complete(file), p2tp::Size(file), p2tp::SeqComplete(file), + swift::Complete(file), swift::Size(file), swift::SeqComplete(file), Datagram::dgrams_up, Datagram::bytes_up, Datagram::dgrams_down, Datagram::bytes_down ); } - int ret = !p2tp::IsComplete(file); + int ret = !swift::IsComplete(file); - p2tp::Close(file); - p2tp::Shutdown(); + swift::Close(file); + swift::Shutdown(); return ret; diff --git a/ext/ledbat_controller.cpp b/ext/ledbat_controller.cpp index 5bc19bd..090911a 100644 --- a/ext/ledbat_controller.cpp +++ b/ext/ledbat_controller.cpp @@ -1,15 +1,15 @@ /* * ledbat_controller.cpp - * p2tp + * swift * * Created by Victor Grishchenko on 10/6/09. * Copyright 2009 Delft University of Technology. All rights reserved. * */ -#include "p2tp.h" +#include "swift.h" -using namespace p2tp; +using namespace swift; class LedbatController : public CongestionController { public: diff --git a/ext/mmap_storer.cpp b/ext/mmap_storer.cpp index aeff70c..dfa5b1b 100644 --- a/ext/mmap_storer.cpp +++ b/ext/mmap_storer.cpp @@ -1,12 +1,12 @@ /* * mmap_storer.cpp - * p2tp + * swift * * Created by Victor Grishchenko on 10/7/09. * Copyright 2009 Delft University of Technology. All rights reserved. * */ -#include "p2tp.h" +#include "swift.h" class MMappedStorer : public DataStorer { public: diff --git a/ext/seq_picker.cpp b/ext/seq_picker.cpp index 3132236..dfaa20b 100644 --- a/ext/seq_picker.cpp +++ b/ext/seq_picker.cpp @@ -1,16 +1,19 @@ /* * seq_picker.cpp - * p2tp + * swift * * Created by Victor Grishchenko on 10/6/09. * Copyright 2009 Delft University of Technology. All rights reserved. * */ -#include "p2tp.h" +#include "swift.h" -using namespace p2tp; +using namespace swift; + +/** Picks pieces nearly sequentialy; some local randomization (twisting) + is introduced to prevent synchronization among multiple channels. */ class SeqPiecePicker : public PiecePicker { binmap_t ack_hint_out_; @@ -41,7 +44,7 @@ public: if (!file().size()) { return bin64_t(0,0); // whoever sends it first } - retry: + retry: // bite me twist_ &= (file().peak(0)) & ((1<<6)-1); if (twist_) { offer.twist(twist_); diff --git a/ext/simple_selector.cpp b/ext/simple_selector.cpp index 2396b11..3b51e98 100644 --- a/ext/simple_selector.cpp +++ b/ext/simple_selector.cpp @@ -1,6 +1,6 @@ /* * simple_selector.cpp - * p2tp + * swift * * Created by Victor Grishchenko on 10/6/09. * Copyright 2009 Delft University of Technology. All rights reserved. @@ -8,9 +8,9 @@ */ #include -#include "p2tp.h" +#include "swift.h" -using namespace p2tp; +using namespace swift; class SimpleSelector : public PeerSelector { typedef std::pair memo_t; diff --git a/hashtree.cpp b/hashtree.cpp index 47213e7..538d05d 100644 --- a/hashtree.cpp +++ b/hashtree.cpp @@ -22,7 +22,7 @@ #endif -using namespace p2tp; +using namespace swift; #define HASHSZ 20 const size_t Sha1Hash::SIZE = HASHSZ; diff --git a/hashtree.h b/hashtree.h index 7878bf1..e31d8a4 100644 --- a/hashtree.h +++ b/hashtree.h @@ -13,7 +13,7 @@ #include #include -namespace p2tp { +namespace swift { /** SHA-1 hash, 20 bytes of data */ diff --git a/mfold/doseq.sh b/mfold/doseq.sh index 30e0461..b61d969 100755 --- a/mfold/doseq.sh +++ b/mfold/doseq.sh @@ -5,7 +5,13 @@ # docmd.sh); all failed executions are # put to the FAILURES file rm -f FAILURES -for srv in `cat servers.txt`; do + +if [ -z "$SERVERS" ]; then + SERVERS="das2.txt" +fi +HOSTS=`cat $SERVERS | awk '{print $2}'` + +for srv in $HOSTS; do ( for cmd in $@; do if ! ./docmd.sh $srv $cmd; then echo $srv >> FAILURES diff --git a/send_control.cpp b/send_control.cpp index 4e504dd..11b9110 100644 --- a/send_control.cpp +++ b/send_control.cpp @@ -7,9 +7,9 @@ * */ -#include "p2tp.h" +#include "swift.h" -using namespace p2tp; +using namespace swift; using namespace std; tint Channel::MIN_DEV = 50*TINT_MSEC; diff --git a/sendrecv.cpp b/sendrecv.cpp index 72d00fc..1533ce5 100644 --- a/sendrecv.cpp +++ b/sendrecv.cpp @@ -6,11 +6,11 @@ * Copyright 2009 Delft University of Technology. All rights reserved. * */ -#include "p2tp.h" +#include "swift.h" #include "compat/util.h" -using namespace p2tp; +using namespace swift; using namespace std; /* diff --git a/p2tp.cpp b/swift.cpp similarity index 86% rename from p2tp.cpp rename to swift.cpp index 65390d9..350a1fd 100644 --- a/p2tp.cpp +++ b/swift.cpp @@ -1,5 +1,5 @@ /* - * p2tp.cpp + * swift.cpp * serp++ * * Created by Victor Grishchenko on 3/6/09. @@ -20,16 +20,16 @@ #include //#include -#include "p2tp.h" +#include "swift.h" #include "datagram.h" using namespace std; -using namespace p2tp; +using namespace swift; -p2tp::tint Channel::last_tick = 0; +swift::tint Channel::last_tick = 0; int Channel::MAX_REORDERING = 4; bool Channel::SELF_CONN_OK = false; -p2tp::tint Channel::TIMEOUT = TINT_SEC*60; +swift::tint Channel::TIMEOUT = TINT_SEC*60; std::vector Channel::channels(1); SOCKET Channel::sockets[8] = {0,0,0,0,0,0,0,0}; int Channel::socket_count = 0; @@ -70,7 +70,7 @@ Channel::~Channel () { } -void p2tp::SetTracker(const Address& tracker) { +void swift::SetTracker(const Address& tracker) { Channel::tracker = tracker; } @@ -83,7 +83,7 @@ int Channel::EncodeID(int unscrambled) { } -int p2tp::Listen (Address addr) { +int swift::Listen (Address addr) { int sock = Datagram::Bind(addr); if (sock!=INVALID_SOCKET) Channel::sockets[Channel::socket_count++] = sock; @@ -91,7 +91,7 @@ int p2tp::Listen (Address addr) { } -void p2tp::Shutdown (int sock_des) { +void swift::Shutdown (int sock_des) { for(int i=0; ifile().file_descriptor(); if (fdes>0) { @@ -126,19 +126,19 @@ int p2tp::Open (const char* filename, const Sha1Hash& hash) { } -void p2tp::Close (int fd) { +void swift::Close (int fd) { // FIXME delete all channels if (fd>FileTransfer::files.size() && FileTransfer::files[fd]) delete FileTransfer::files[fd]; } -void p2tp::AddPeer (Address address, const Sha1Hash& root) { +void swift::AddPeer (Address address, const Sha1Hash& root) { Channel::peer_selector->AddPeer(address,root); } -uint64_t p2tp::Size (int fdes) { +uint64_t swift::Size (int fdes) { if (FileTransfer::files.size()>fdes && FileTransfer::files[fdes]) return FileTransfer::files[fdes]->file().size(); else @@ -146,7 +146,7 @@ uint64_t p2tp::Size (int fdes) { } -bool p2tp::IsComplete (int fdes) { +bool swift::IsComplete (int fdes) { if (FileTransfer::files.size()>fdes && FileTransfer::files[fdes]) return FileTransfer::files[fdes]->file().is_complete(); else @@ -154,7 +154,7 @@ bool p2tp::IsComplete (int fdes) { } -uint64_t p2tp::Complete (int fdes) { +uint64_t swift::Complete (int fdes) { if (FileTransfer::files.size()>fdes && FileTransfer::files[fdes]) return FileTransfer::files[fdes]->file().complete(); else @@ -162,7 +162,7 @@ uint64_t p2tp::Complete (int fdes) { } -uint64_t p2tp::SeqComplete (int fdes) { +uint64_t swift::SeqComplete (int fdes) { if (FileTransfer::files.size()>fdes && FileTransfer::files[fdes]) return FileTransfer::files[fdes]->file().seq_complete(); else @@ -170,7 +170,7 @@ uint64_t p2tp::SeqComplete (int fdes) { } -const Sha1Hash& p2tp::RootMerkleHash (int file) { +const Sha1Hash& swift::RootMerkleHash (int file) { FileTransfer* trans = FileTransfer::file(file); if (!trans) return Sha1Hash::ZERO; diff --git a/p2tp.h b/swift.h similarity index 99% rename from p2tp.h rename to swift.h index f372998..8c65dd3 100644 --- a/p2tp.h +++ b/swift.h @@ -1,5 +1,5 @@ /* - * p2tp.h + * swift.h * the main header file for libswift, normally you should only read this one * * Created by Victor Grishchenko on 3/6/09. @@ -63,7 +63,7 @@ Messages #include "datagram.h" #include "hashtree.h" -namespace p2tp { +namespace swift { #define NOW Datagram::now diff --git a/tests/connecttest.cpp b/tests/connecttest.cpp index 580a373..40a7ae5 100644 --- a/tests/connecttest.cpp +++ b/tests/connecttest.cpp @@ -9,11 +9,11 @@ #include //#include -#include "p2tp.h" +#include "swift.h" #include -using namespace p2tp; +using namespace swift; TEST(P2TP,CwndTest) { @@ -26,35 +26,35 @@ TEST(P2TP,CwndTest) { int size = st.st_size;//, sizek = (st.st_size>>10) + (st.st_size%1024?1:0) ; Channel::SELF_CONN_OK = true; - int sock1 = p2tp::Listen(7001); + int sock1 = swift::Listen(7001); ASSERT_TRUE(sock1>=0); - int file = p2tp::Open("doc/sofi.jpg"); + int file = swift::Open("doc/sofi.jpg"); FileTransfer* fileobj = FileTransfer::file(file); //FileTransfer::instance++; - p2tp::SetTracker(Address("127.0.0.1",7001)); + swift::SetTracker(Address("127.0.0.1",7001)); - int copy = p2tp::Open("doc/sofi-copy.jpg",fileobj->root_hash()); + int copy = swift::Open("doc/sofi-copy.jpg",fileobj->root_hash()); - p2tp::Loop(TINT_SEC); + swift::Loop(TINT_SEC); int count = 0; - while (p2tp::SeqComplete(copy)!=size && count++<600) - p2tp::Loop(TINT_SEC); - ASSERT_EQ(size,p2tp::SeqComplete(copy)); + while (swift::SeqComplete(copy)!=size && count++<600) + swift::Loop(TINT_SEC); + ASSERT_EQ(size,swift::SeqComplete(copy)); - p2tp::Close(file); - p2tp::Close(copy); + swift::Close(file); + swift::Close(copy); - p2tp::Shutdown(sock1); + swift::Shutdown(sock1); } int main (int argc, char** argv) { - p2tp::LibraryInit(); + swift::LibraryInit(); testing::InitGoogleTest(&argc, argv); int ret = RUN_ALL_TESTS(); return ret; diff --git a/tests/dgramtest.cpp b/tests/dgramtest.cpp index 8ad68bf..eb7443c 100644 --- a/tests/dgramtest.cpp +++ b/tests/dgramtest.cpp @@ -9,9 +9,9 @@ #include //#include #include "datagram.h" -#include "p2tp.h" // Arno: for LibraryInit +#include "swift.h" // Arno: for LibraryInit -using namespace p2tp; +using namespace swift; TEST(Datagram, AddressTest) { Address addr("127.0.0.1:1000"); @@ -103,7 +103,7 @@ TEST(Datagram,TwoPortTest) { int main (int argc, char** argv) { - p2tp::LibraryInit(); + swift::LibraryInit(); testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); diff --git a/tests/hashtest.cpp b/tests/hashtest.cpp index d988fb1..db4ac83 100644 --- a/tests/hashtest.cpp +++ b/tests/hashtest.cpp @@ -11,7 +11,7 @@ #include #include "hashtree.h" -using namespace p2tp; +using namespace swift; char hash123[] = "a8fdc205a9f19cc1c7507a60c4f01b13d11d7fd0"; char rooth123[] = "d0bdb8ba28076d84d2b3a0e62521b998e42349a1"; diff --git a/tests/ledbattest.cpp b/tests/ledbattest.cpp index 55af714..29d00ce 100644 --- a/tests/ledbattest.cpp +++ b/tests/ledbattest.cpp @@ -3,10 +3,10 @@ #include #include #include "datagram.h" -#include "p2tp.h" +#include "swift.h" #include -using namespace p2tp; +using namespace swift; using namespace std; /** @@ -169,7 +169,7 @@ TEST(Datagram,LedbatTest) { int main (int argc, char** argv) { printf("Warning: use the script to set up dummynet!\n"); - p2tp::LibraryInit(); + swift::LibraryInit(); testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); diff --git a/tests/transfertest.cpp b/tests/transfertest.cpp index fbd0e47..36a92a2 100644 --- a/tests/transfertest.cpp +++ b/tests/transfertest.cpp @@ -1,6 +1,6 @@ /* * transfertest.cpp - * p2tp + * swift * * Created by Victor Grishchenko on 10/7/09. * Copyright 2009 Delft University of Technology. All rights reserved. @@ -8,11 +8,11 @@ */ //#include //#include -#include "p2tp.h" +#include "swift.h" #include "compat.h" #include -using namespace p2tp; +using namespace swift; const char* BTF = "test_file"; diff --git a/transfer.cpp b/transfer.cpp index 08205ee..70c7a0e 100644 --- a/transfer.cpp +++ b/transfer.cpp @@ -14,12 +14,12 @@ #include #include #include -#include "p2tp.h" +#include "swift.h" #include "compat/util.h" #include "ext/seq_picker.cpp" // FIXME FIXME FIXME FIXME -using namespace p2tp; +using namespace swift; std::vector FileTransfer::files(20);