Goals : State Recovery for User Session Management Team Size: 4-6 (on instructor approval) Description: IoT devices have become common place. From smart bulb to smart washing machine, all kinds of devices are being used by end-users. It is desirable to keep track of various actions performed on the devices by various users. This may be required for purposes of security and safety. The goal of the project is to create a graphical database using Neo4j for logging device activities and execute recovery protocols resulting due to interruptions or disruptions. We are allowed to execute a collection of activities on any device. A user can login to the network and execute a series of activities on one or more devices. We call such collection as a session. Often a user may not be able to complete all planned activities due to various reasons: 1. The user's network connection could be interrupted 2. The devices might not be responding or might have crashed 3. The database transactions might fail. (Neo4j provides transactions that satisfy the ACID properties. But the number of retries are developer dependent) In these cases, the user wishes to resume his session, the state of the user activities must be restored to the point of interruption. Skills Required: 1. Python Specifications 1. The following are the devices and the operations allowed on them. For each user operation the device responds with status: . Assume that there are no synchronization problems, i.e., a device is used by only one user at any given time. Hue Light --On --Stand_by --Increase_brightness --Reduce_brightness --Current_brightness_level (High/Medium/Low) --Change_color_blue/green/red/mixed --Reort)Current_color_status (blue/green/hue) --Report_firmware_version Smart Bulb --On --Stand_by --Increase_brightness --Reduce_brightness --Current_brightness_level (High/Medium/Low) --Report_firmware_version Camera --On --Stand_by --Change_direction --Report_current direction (East facing/West Facing/ North Facing/ South Facing) --Start_Record_stream (Writes the video data to database) --Stop_Record_stream (Stops writing the video data) --Change orientation (Up/Down) --Report_current_orientation (Up/Down) --Report_firmware_version Speaker --On --Stand_by --Play_last_song --Connect_to_radio --Connect_to_cell_phone --Connect_to_Alexa --Play_stored_playlist --Store_playlist --Report_songs_in_playlist --Increase_volume --Reduce_volume --Surround_sound --Preset_equalizer --Reset_audio_settings Motion sensor --On --Stand_by --Increase_sampling (by fixed amount) --Reduce_sampling (by fixed amount) --Write_log (start writing sensor values to data base) --Stop_log (stop writing sensor values to data base) --Report_current_sampling_rate (Samples/second) --Report_last_logged_time (end and begin times) --Report_size_of_last_logged_data (bytes) A successful log record for a given activity is given by: . The legend is as follows: (User-ID) : Uniquely identifies a user (Session-ID): System defined unique session identifier (Command) : Operation being executed (Start-time) : Time when the command was submitted (End-time) : Time when device completed its response (Logging-time-stamp): Time at which record was placed in the database A failed log record looks similar: , the items marked * might not be available depending on the failure scenario. Neo4j allows logging both these types of records by using appropriate labels ("successful") ("failed") 2. The user submits his list of activities as follows: ->---- The "-->" indicates that the next action follows previous action. This list is recorded and stored in the database as well. The user will not be submitting this list again once the session begins. Tasks Task 1. Create a Neo4j database to handle the data storage requirements as mentioned above. Task 2. You can model each device as a python object and each activity as a method. A method should mostly return positive response (i.e., success) but periodically report failure. Implement a biased (90% positive and 10% negative) probability model to implement this functionality and demonstrate Task 3. Implement a user queue that corresponds to the set of users wanting to execute a list of activities. If any user's activity fails then he is moved to the back of the list and the next user's list is processed. Task 4. Simulate the following failure scenarios to test your recovery protocol. a. Device reports a failure b. Device does not report anything c. Device response is lost in transit (All of these can be simulated in the object model) The recovery protocol should not require any user