Professional Documents
Culture Documents
Computer Networks
Goal
Simulating a peer-to-peer file-sharing network via ad-hoc connections using TCP and UDP sockets. 10% of the final grade. Individual Assignment Cheating = F Grade Hardcode nunki.usc.edu NOT 68.181.201.3.
Phases
The project has 3 major phases:
Registration of peers with the bootstrap server Authentication of the content providers by the bootstrap server peer-to-peer content sharing.
Sockets
Order of execution
bootstrap_server peers (all 4 of them concurrently) content_provider
Phases 1 and 2
all communications are through UDP sockets.
Phase 3
all the communications are over TCP sockets.
Code Files
bootstrap_server content_provider
You must create 2 concurrent content_providers (by using fork() or a similar Unix system call).
peer
You must create 4 concurrent peers (by using fork() or a similar Unix system call).
Identifier String
Message Payload
Any of the following strings: peer1, peer2, peer3, peer4 provider1, provider2 bootstrap
The actual content of the message such as, names, port numbers or IP addresses
Bootstrap Server
UDP Port Creates a text file directory.txt only ONCE. Writes the information to it every time a new peer registers itself with the bootstrap_server. The bootstrap_server expects to hear messages from all 4 peers before it receives any messages from the content_providers.
Bootstrap Server
Bootstrap Server must retrieve some information from the message(s) and store them on a single line (for each peer) separated by one space in the file directory.txt:
senders name , e.g. peer1 its TCP port number, e.g. 3451 its IP address, e.g. 128.125.61.23 group number, e.g. group1
Bootstrap Server
Authentication of the Content Provider The bootstrap_server sends the filename directory.txt as a message to that content_provider. Terminate bootstrap_server.
BOOTSTRAP_SERVER
UDP SOCKET
Peer4
Content Provider
Creates UDP socket and sends the username and password to the bootstrap_server. Receives filename. Read the files in turn and find the peers that subscribed to them. Group# defines which peer subscribed to the content_provider.
Content_Provider1
Peer3 Peer1
Peer4 Peer2
Content Provider
Identifies the peers. Opens up a TCP connection Sends the count of the number of peers and welcome message to the peer. Receives an ACK from the peer for every message.
Content Provider
The content provider then sends the names and TCP port numbers of the rest of its peer subscribers to this peer subscriber in one long message or several short messages. Tears down the TCP connection
Peers
TCP/ UDP sockets It then sends a message through the UDP socket to the bootstrap_server. This message contains its TCP port number, its IP address and a randomly chosen group number (either group1 or group2). Checks whether the message is from the Content Provider or a Peer.
BOOTSTRAP_SERVER
UDP SOCKET
Peer4
Peers
First peer has a number and a list of the names and the TCP ports of the other peer subscribers . It first checks the number. If the number is greater than 1, it decrements it by 1 and establishes a new TCP connection through its TCP socket to contact the first peer subscriber in this list.
Peers
Once the connection is accepted, it sends this new number, the sentence welcome to group # and the names and the TCP port numbers of the rest of the subscribers in one long message or several short ones. This goes on iteratively till the last peer is reached.
Content_Provider2
Content_Provider1
Group2
Peer3 TCP SOCKET
Group1
Peer1 STEP 1 TCP SOCKET
Peer4
STEP 3
TCP SOCKET
Other Instructions
Assumptions Requirements Grading Criteria Cautionary Words Etc