Skip to content

Repository files navigation

Project Description:

In this project, socket connections are used to emulate communication between four computers - C1, C2, C3, C4 - and implement causally ordered broadcasting, as described below:

    • Four processes are independently started on four servers. Each process is numbered from 1 to 4.
    
    • Each process has a stream socket connection with the other three processes. The stream sockets are established with the following logic - "Each process sends a connection request to all processes with a higher node number than itself and accepts connection requests from nodes with number lower than its own.". Using this logic, pairwise connectivity is established amongst all the processes.

    • Once all pair-wise connections are set up, each of the four processes perform causally ordered broadcasting by executing the following two steps in a loop, for a total of 100 message broadcasts:
            – Wait for a random amount of time in the range (0,10] milliseconds.
            – Send a message to all processes emulating broadcast as a set of unicasts along all the local socket connections.
    
    • When a message, m, is received by a process, and all its causal predecessors have been delivered locally: (i)m is delivered, and (ii) all messages in local message buffer that now become eligible for delivery are removed one-by-one from the message buffer and delivered. Otherwise, message m is placed in the local message buffer.

    • Each process terminates when it has sent its 100 messages, and delivered, in a manner consistent with causal ordering, 100 messages from each of the other three processes.

A basic description of the structure of the code is present in the CBDesign pdf.

Compilation Instructions:

  1. Copy the causalbroadcast package to all the machines to run to communication on and extract the package. This can be done by:

    1.1. Create a tarball of the package using tar -uvf causalbroadcast.tar causalbroadcast/

    1.2. Copy the tarball using scp to all the nodes: scp -i causalbroadcast.tar @<machineName/IP>:~

    1.3. Extract the package in the home directory using tar -xvf causalbroadcast.tar

    • Optional: Logic errors during scp are common. A good practice to unsure that the package has not corrupted is to validate the checksum of the tarball at both the sender and the receiver. This can be done using the following: sha256sum
  2. Ssh to all 4 nodes at the same time. This can be done using terminals like iterm. Execute the following commands

    2.1. Compile the package using javac -d . *.java

    2.2. Run the package using java causalbroadcast.comDriver | tee .log This will create a log file of the execution on each node.

  3. To verify the results, collect the logfile you want to verify and run the message verifier.

    3.1. Compile the verifier using javac MessageVerifier.java

    3.2. Run the verifier using java MessageVerifier

Modification Instructions:

  • The current implementation has the number of nodes hardcoded as 4 in VectorClock.java, ChannelManager.java and MessageBroker.java. This can be incremented to work for more nodes. Unifying this into a singular input in the system properties file is trivial.

  • The efficiency of the communication depends on the network you run it on. This implementation is not aware of the network load and hence is prone to buffer bloat. Adjust the random delay amount present in MessageBroadcaster.java to fit your network.

  • The maximum messages generated are fixed at 100 currently. This can be changed at the MessageBroadcaster, Broker and Receiver.

Dependencies:

This project requires Java SE Development Kit (JDK) installed on your system.

Contributing:

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

About

Code to establish causally ordered broadcast communication between multiple processes.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Contributors

Languages