Skip to content

Commit 126bfef

Browse files
authored
Merge pull request #4 from jingwei87/TwoRoundDownload
Two round download Fixed
2 parents 7ca8d81 + 3f0f020 commit 126bfef

File tree

18 files changed

+367
-375
lines changed

18 files changed

+367
-375
lines changed

TEDStore/ShellScripts/systemBuild.sh

100644100755
Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
#!/bin/bash
22
./ShellScripts/systemCleanup.sh
33

4-
cd lib/leveldb/
5-
if [ ! -d "build" ]; then
6-
mkdir -p build && cd build
7-
cmake -DCMAKE_BUILD_TYPE=Release .. && cmake --build .
8-
cd ../../../
9-
else
10-
cd ../../
11-
fi
4+
# cd lib/leveldb/
5+
# if [ ! -d "build" ]; then
6+
# mkdir -p build && cd build
7+
# cmake -DCMAKE_BUILD_TYPE=Release .. && cmake --build .
8+
# cd ../../../
9+
# else
10+
# cd ../../
11+
# fi
1212

13-
cd lib/openssl/
14-
if [ ! -f "Makefile" ]; then
15-
./config && make
16-
cd ../../
17-
else
18-
cd ../../
19-
fi
13+
# cd lib/openssl/
14+
# if [ ! -f "Makefile" ]; then
15+
# ./config && make
16+
# cd ../../
17+
# else
18+
# cd ../../
19+
# fi
2020

2121
if [ ! -d "bin" ]; then
2222
mkdir bin

TEDStore/ShellScripts/systemCleanup.sh

100644100755
File mode changed.

TEDStore/include/dataStructure.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ typedef struct {
1818
u_char chunkHash[CHUNK_HASH_SIZE];
1919
u_char encryptKey[CHUNK_ENCRYPT_KEY_SIZE];
2020
} Chunk_t;
21+
22+
typedef struct {
23+
u_char chunkHash[CHUNK_HASH_SIZE];
24+
} ChunkHash_t;
25+
26+
typedef struct {
27+
vector<ChunkHash_t> hash_;
28+
} HashList_t;
29+
2130
// HIGH - 16460 LOW - 16428
2231

2332
typedef struct {

TEDStore/include/dedupCore.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class DedupCore {
1818
public:
1919
DedupCore();
2020
~DedupCore();
21-
bool dedupByHash(powSignedHash_t in, RequiredChunk_t& out);
21+
bool dedupByHash(HashList_t in, RequiredChunk_t& out);
2222
};
2323

2424
#endif //TEDSTORE_DEDUPCORE_HPP

TEDStore/include/protocol.hpp

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,11 @@
33

44
#include <bits/stdc++.h>
55
//client-server network protocol
6-
#define SGX_RA_MSG01 0
7-
#define SGX_RA_MSG2 1
8-
#define SGX_RA_MSG3 2
9-
#define SGX_RA_MSG4 3
10-
#define POW_CLOSE_SESSION 4
11-
#define SGX_SIGNED_HASH 5
12-
#define POW_REQUEST 6
136
#define CLIENT_UPLOAD_CHUNK 7
147
#define CLIENT_DOWNLOAD_CHUNK_WITH_RECIPE 8
158
#define SERVER_REQUIRED_CHUNK 9
16-
#define CLIENT_UPLOAD_RECIPE 10
17-
#define CLIENT_DOWNLOAD_FILEHEAD 11
9+
#define CLIENT_UPLOAD_ENCRYPTED_RECIPE 10
10+
#define CLIENT_DOWNLOAD_ENCRYPTED_RECIPE 11
1811
#define ERROR_RESEND 12
1912
#define ERROR_CLOSE 13
2013
#define SUCCESS 14
@@ -23,22 +16,9 @@
2316
#define ERROR_CHUNK_NOT_EXIST 17
2417
#define ERROR_CLIENT_CLOSE_CONNECT 18
2518
#define CLIENT_EXIT 19
26-
#define CLIENT_GET_KEY_SERVER_SK 20
27-
#define RA_REQUEST 21
19+
#define CLIENT_UPLOAD_DECRYPTED_RECIPE 20
20+
#define CLIENT_DOWNLOAD_RECIPE_SIZE 21
2821

29-
//dupCore-storageCore protocol
30-
#define SAVE_CHUNK
31-
#define SAVE_RECIPE
3222
using namespace std;
3323

34-
typedef struct _ra_msg4_struct {
35-
bool status;
36-
//sgx_platform_info_t platformInfoBlob;
37-
} ra_msg4_t;
38-
39-
typedef struct {
40-
uint8_t signature_[16];
41-
vector<string> hash_;
42-
} powSignedHash_t;
43-
4424
#endif //TEDSTORE_PROTOCOL_HPP

TEDStore/include/recvDecode.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@ class RecvDecode {
2525

2626
public:
2727
Recipe_t fileRecipe_;
28+
RecipeList_t fileRecipeList_;
2829
RecvDecode(string fileName);
2930
~RecvDecode();
3031
void run();
31-
bool recvFileHead(Recipe_t& FileRecipe, u_char* fileNameHash);
32+
bool processRecipe(Recipe_t& recipeHead, RecipeList_t& recipeList, u_char* fileNameHash);
3233
bool recvChunks(ChunkList_t& recvChunk, int& chunkNumber, uint32_t& startID, uint32_t& endID);
3334
Recipe_t getFileRecipeHead();
3435
bool insertMQToRetriever(RetrieverData_t& newChunk);

TEDStore/include/storageCore.hpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,14 @@ class StorageCore {
4747
StorageCore();
4848
~StorageCore();
4949

50-
bool saveChunks(NetworkHeadStruct_t& networkHead, char* data);
51-
bool saveRecipe(std::string recipeName, Recipe_t recipeHead, RecipeList_t recipeList, bool status);
52-
bool restoreRecipeAndChunk(char* fileNameHash, uint32_t startID, uint32_t endID, ChunkList_t& restoredChunkList);
53-
bool saveChunk(std::string chunkHash, char* chunkData, int chunkSize);
54-
bool restoreChunk(std::string chunkHash, std::string& chunkData);
55-
bool checkRecipeStatus(Recipe_t recipeHead, RecipeList_t recipeList);
56-
bool restoreRecipeHead(char* fileNameHash, Recipe_t& restoreRecipe);
50+
bool restoreChunks(NetworkHeadStruct_t& networkHead, char* data);
51+
bool storeRecipes(char* fileNameHash, u_char* recipeContent, uint64_t recipeSize);
52+
bool restoreRecipeAndChunk(RecipeList_t recipeList, uint32_t startID, uint32_t endID, ChunkList_t& restoredChunkList);
53+
bool storeChunk(string chunkHash, char* chunkData, int chunkSize);
54+
bool storeChunks(NetworkHeadStruct_t& networkHead, char* data);
55+
bool restoreChunk(std::string chunkHash, std::string& chunkDataStr);
56+
bool restoreRecipes(char* fileNameHash, u_char* recipeContent, uint64_t& recipeSize);
57+
bool restoreRecipesSize(char* fileNameHash, uint64_t& recipeSize);
5758
};
5859

5960
#endif

TEDStore/src/client/chunker.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -335,10 +335,10 @@ void Chunker::fixSizeChunking()
335335
if (setJobDoneFlag() == false) {
336336
cerr << "Chunker : set chunking done flag error" << endl;
337337
}
338-
cout << "Chunker : Fixed chunking over:\nTotal file size = " << fileRecipe.recipe.fileRecipeHead.fileSize << "; Total chunk number = " << fileRecipe.recipe.fileRecipeHead.totalChunkNumber << endl;
338+
cerr << "Chunker : Fixed chunking over:\nTotal file size = " << fileRecipe.recipe.fileRecipeHead.fileSize << "; Total chunk number = " << fileRecipe.recipe.fileRecipeHead.totalChunkNumber << endl;
339339
#if BREAK_DOWN_DEFINE == 1
340-
cout << "Chunker : total chunking time = " << chunkTime << " s" << endl;
341-
cout << "Chunker : total hashing time = " << hashTime << " s" << endl;
340+
cerr << "Chunker : total chunking time = " << chunkTime << " s" << endl;
341+
cerr << "Chunker : total hashing time = " << hashTime << " s" << endl;
342342
#endif
343343
}
344344

@@ -424,10 +424,10 @@ void Chunker::traceDrivenChunkingFSL()
424424
if (setJobDoneFlag() == false) {
425425
cerr << "Chunker : set chunking done flag error" << endl;
426426
}
427-
cout << "Chunker : trace gen over:\nTotal file size = " << fileRecipe.recipe.fileRecipeHead.fileSize << "; Total chunk number = " << fileRecipe.recipe.fileRecipeHead.totalChunkNumber << endl;
427+
cerr << "Chunker : trace gen over:\nTotal file size = " << fileRecipe.recipe.fileRecipeHead.fileSize << "; Total chunk number = " << fileRecipe.recipe.fileRecipeHead.totalChunkNumber << endl;
428428
#if BREAK_DOWN_DEFINE == 1
429-
cout << "Chunker : total chunking time = " << chunkTime << " s" << endl;
430-
cout << "Chunker : total hashing time = " << hashTime << " s" << endl;
429+
cerr << "Chunker : total chunking time = " << chunkTime << " s" << endl;
430+
cerr << "Chunker : total hashing time = " << hashTime << " s" << endl;
431431
#endif
432432
}
433433

@@ -514,10 +514,10 @@ void Chunker::traceDrivenChunkingUBC()
514514
if (setJobDoneFlag() == false) {
515515
cerr << "Chunker : set chunking done flag error" << endl;
516516
}
517-
cout << "Chunker : trace gen over:\nTotal file size = " << fileRecipe.recipe.fileRecipeHead.fileSize << "; Total chunk number = " << fileRecipe.recipe.fileRecipeHead.totalChunkNumber << endl;
517+
cerr << "Chunker : trace gen over:\nTotal file size = " << fileRecipe.recipe.fileRecipeHead.fileSize << "; Total chunk number = " << fileRecipe.recipe.fileRecipeHead.totalChunkNumber << endl;
518518
#if BREAK_DOWN_DEFINE == 1
519-
cout << "Chunker : total chunking time is" << chunkTime << " s" << endl;
520-
cout << "Chunker : total hashing time is" << hashTime << " s" << endl;
519+
cerr << "Chunker : total chunking time is" << chunkTime << " s" << endl;
520+
cerr << "Chunker : total hashing time is" << hashTime << " s" << endl;
521521
#endif
522522
}
523523

@@ -690,13 +690,13 @@ void Chunker::varSizeChunking()
690690
cerr << "Chunker: set chunking done flag error" << endl;
691691
return;
692692
}
693-
cout << "Chunker : variable size chunking over:\nTotal file size = " << fileRecipe.recipe.fileRecipeHead.fileSize << "; Total chunk number = " << fileRecipe.recipe.fileRecipeHead.totalChunkNumber << endl;
693+
cerr << "Chunker : variable size chunking over:\nTotal file size = " << fileRecipe.recipe.fileRecipeHead.fileSize << "; Total chunk number = " << fileRecipe.recipe.fileRecipeHead.totalChunkNumber << endl;
694694
#if BREAK_DOWN_DEFINE == 1
695695
gettimeofday(&timeendChunker, NULL);
696696
diff = 1000000 * (timeendChunker.tv_sec - timestartChunker.tv_sec) + timeendChunker.tv_usec - timestartChunker.tv_usec;
697697
second = diff / 1000000.0;
698-
cout << "Chunker : total chunking time = " << setbase(10) << second - (insertTime + hashTime) << " s" << endl;
699-
cout << "Chunker : total hashing time = " << hashTime << " s" << endl;
698+
cerr << "Chunker : total chunking time = " << setbase(10) << second - (insertTime + hashTime) << " s" << endl;
699+
cerr << "Chunker : total hashing time = " << hashTime << " s" << endl;
700700
#endif
701701
return;
702702
}

TEDStore/src/client/clientMain.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ struct timeval timeend;
2222

2323
void usage()
2424
{
25-
cout << "[client -r filename] for receive file" << endl;
26-
cout << "[client -s filename] for send file" << endl;
25+
cerr << "[client -r filename] for receive file" << endl;
26+
cerr << "[client -s filename] for send file" << endl;
2727
}
2828

2929
int main(int argv, char* argc[])
@@ -74,8 +74,8 @@ int main(int argv, char* argc[])
7474
gettimeofday(&timeend, NULL);
7575
long diff = 1000000 * (timeend.tv_sec - timestart.tv_sec) + timeend.tv_usec - timestart.tv_usec;
7676
double second = diff / 1000000.0;
77-
cout << "System : total work time is " << diff << " us = " << second << " s" << endl;
78-
cout << "System : start work time is " << timestart.tv_sec << " s, " << timestart.tv_usec << " us" << endl;
79-
cout << "System : end work time is " << timeend.tv_sec << " s, " << timeend.tv_usec << " us" << endl;
77+
cerr << "System : total work time is " << diff << " us = " << second << " s" << endl;
78+
cerr << "System : start work time is " << timestart.tv_sec << " s, " << timestart.tv_usec << " us" << endl;
79+
cerr << "System : end work time is " << timeend.tv_sec << " s, " << timeend.tv_usec << " us" << endl;
8080
return 0;
8181
}

TEDStore/src/client/keyClient.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -145,19 +145,19 @@ void keyClient::run()
145145
if (!senderObj_->editJobDoneFlag()) {
146146
cerr << "KeyClient : error to set job done flag for sender" << endl;
147147
} else {
148-
cout << "KeyClient : key exchange thread job done, exit now" << endl;
148+
cerr << "KeyClient : key exchange thread job done, exit now" << endl;
149149
}
150150
break;
151151
}
152152
}
153153
#if BREAK_DOWN_DEFINE == 1
154-
cout << "KeyClient : keyGen total work time = " << keyGenTime << " s" << endl;
155-
cout << "KeyClient : short hash compute work time = " << shortHashTime << " s" << endl;
156-
cout << "KeyClient : key exchange work time = " << keyExchangeTime << " s" << endl;
157-
cout << "KeyClient : key derviation work time = " << keyDerivationTime << " s" << endl;
158-
cout << "KeyClient : encryption work time = " << encryptionTime << " s" << endl;
159-
cout << "KeyClient : socket send time = " << keySocketSendTime << " s" << endl;
160-
cout << "KeyClient : socket recv time = " << keySocketRecvTime << " s" << endl;
154+
cerr << "KeyClient : keyGen total work time = " << keyGenTime << " s" << endl;
155+
cerr << "KeyClient : short hash compute work time = " << shortHashTime << " s" << endl;
156+
cerr << "KeyClient : key exchange work time = " << keyExchangeTime << " s" << endl;
157+
cerr << "KeyClient : key derviation work time = " << keyDerivationTime << " s" << endl;
158+
cerr << "KeyClient : encryption work time = " << encryptionTime << " s" << endl;
159+
cerr << "KeyClient : socket send time = " << keySocketSendTime << " s" << endl;
160+
cerr << "KeyClient : socket recv time = " << keySocketRecvTime << " s" << endl;
161161
#endif
162162
return;
163163
}

0 commit comments

Comments
 (0)