- All the header files are in the
includedirectory, where they are further divided into folders. Every header file has a respective C file in thesrcdirectory. - All the C code files are in the
srcdirectory. Thepkgmain.cfile is the Command Line Interface of part 1. Thebtide.cfile is the Command Line Interface of part 2. - Run
make allto build both parts of the project, ormake pkgmainfor part 1 ormake btidefor part 2. - All binaries and object files in the root directory can be removed using
make clean
src/crypt/sha256.c: used for compute hashes on data.src/tree/merkletree.c: implementation of the merkle tree, which is implemented using tree as an array. This file includes the data structure of merkle tree and helper functions such as computing hashes and tree operations. The key of each node represents its index in the array. The root node is the first element in the array, and linear probing on the array represents level-order traversal. For a given node with indexi, its left child's index is calculated by2i+1and right child index is2i+2.src/chk/pkgchk.c: implementation of the bpkg data structure, and helper functions for bpkg operations.src/pkgmain.c: command line interface that utilises functions inpkgchk.c.
src/config/config.c: used for parsing configuration files when starting the btide application.src/p2p/peer.c: implements the underlying data structure (dynamic array) and helper functions for managing peers in the btide application.src/p2p/package.c: implements the underlying data structure (dynamic array) and helper functions for managing packages in the btide application.src/p2p/p2p_node.c: includes thread functions for initialising connection requests, acting as a server and handling any packets. Responsible for request listening and chunk handling.src/net/packet.c: implements the data structure of network packets and payloads, including helper functions for sending and receiving packets.src/btide.c: the command line interface of the btide application, utilises all the above C files,pkgchkfor bpkg helper functions andmerkletree.cfor packet data integrity check. Responsible for handling commands and sending packets.
- Run
make btideand then./btide <config file>
- All the part 1 test cases are located in the
p1_testsdirectory. - All the part 2 test cases are located in the
p2_testsdirectory. - Each folder represents a test case, and it includes all the input files, output files and the test script required for the test case.
- The folder name represents the situation that is being tested by the test case.
- The tests cases are ran by main test scripts in the root directory:
p1test.shandp2test.sh, which run Part 1 testcases and Part 2 testcases respectively.
- Make sure the project is built by using
make allin the project root directory - Run the shell command
chmod u+x p1test.sh p2test.shto add execution permission for the test scripts - Run the shell command
./p1test.shfor part 1 tests and./p2test.shfor part 2 tests. - Any differences in the actual outputs and expected outputs will be printed to the terminal.
- Build the project using
make all - Part 1 tests:
make p1tests - Part 2 tests:
make p2tests