Starting from:

$30

CMPSC311-Assignment 5 Solved

Assignment #5 – mdadm Linear Device (Networking)

CMPSC311 - Introduction to Systems Programming 
 
Protocol
The protocol defined by the JBOD vendor has two messages. The JBOD request message is sent from your client program to the JBOD server and contains an opcode and a buffer when needed. The JBOD response message is sent from the JBOD server to your client program and contains an opcode and a buffer when needed. Both messages use the same format:

Bytes
Field
Description
0-1
length
The size of the packet in bytes
2-5
opcode
The opcode for the JBOD operation
6-7
return code
Return code from the JBOD operation
8-263
block
Where needed, a block of size JBOD BLOCK SIZE
Table 1: JBOD procotol packet format

Implementation
In addition to replacing all calls in mdadm.c, you will implement functions defined in net.h in the provided net.c file. Specifically, you will implement jbod_connect function, which will connect to JBOD SERVER at port JBOD PORT, both defined in net.h, and jbod_disconnect function, which will close the connection to the JBOD server. Both of these functions will be called by the tester. The file net.c contains some functions with empty bodies that can help with structuring your code, but you don’t have to implement them. Other than implementing the functions in net.h, it is up to you how you structure your code.

1

Testing
Once you finish implementing your code, you can test it by running the provided jbod_server in one terminal, which implements the server component of the protocol, and running the tester with the workload file in another terminal. Below is a sample session from the server and the client:

Output from the jbod_server terminal:

$ ./jbod_server

JBOD server listening on port 3333...

new client connection from 127.0.0.1 port 32402 client closed connection

Output from the tester terminal:

$ ./tester -w traces/simple-input >my-out connected to the JBOD server at 127.0.0.1

Cost: 0 Hit rate: -nan%

closed connection to the JBOD server

You can also run the jbod_server in verbose mode to print out every command that it receives from the client. Below is sample output that was trimmed to fit the space.

$ ./jbod_server -v

JBOD server listening on port 3333...

new client connection from 127.0.0.1 port 38546 received cmd id = 0 (JBOD_MOUNT) [disk id = 0 block id = 0], result = 0 received cmd id = 2 (JBOD_SEEK_TO_DISK) [disk id = 0 block id = 0], result = 0 received cmd id = 5 (JBOD_WRITE_BLOCK) [disk id = 0 block id = 0], result = 0 block contents:

0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00

0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 Grading

There are not tests for this implementation. All of your 10 points will come from traces.

2

More products