Client Design
Three layers of abstraction exist in the design of the client. This is illustrated in Figure 1.
The functions implemented in the Matlab Layer will be available to the user within
Matlab.
Matlab Layer. These provide high-level Matlab interface. All functions
(m files) are prefixed by USRPF (USRP Fading Simulator). Appart from
USRPF_open_connection and USRPF_close_connection, all function will
use MEX_USRPF_send_command.
MEX Layer. All functions are prefixed by MEX_USRPF (these are C
files). Three functions will exist: MEX_USRPF_open_connection,
MEX_USRPF_close_connection and MEX_USRPF_send_commmand
Communication Layer. wrsDLL.dll will provide the low-level TCP/IP
communication support to the MEX_USRPF functions.
Figure 1: The client consists of three layers of abstraction.
Functions implemented in the Matlab Layer
connection = USRPF_open_connection(ip_address)
USRPF_close_connecton(connection)
USRPF_send_file(file_name) (uses FTP)
These functions all use the MEX_USRPF_send_command() function to communicate
with the Communication Layer.
USRPF_set_rf_tx_freq(connection, rf_freq)
USRPF_set_rf_tx_power(connection, rf_power)
USRPF_play_file(connection, file_name)
USRPF_play_receiving_rf()
USRPF_play_stop(connection)
Functions implemented in the MEX Layer
MEX_USRPF_open_connection – opens a connection to the server.
MEX_USRPF_close_connection – closes an open connection
MEX_USRPF_send_command – sends a string formatted command to the server.
Client Server Communication Protocol
The server listens for command and then responds with replies. Blocking sockets are used
so it is assumed that, given a connection is open, the server will always respond to the
client. If the server does not respond then the client will block indefinitely.
Command Syntax
The client will communicate with the server using string formatted commands that
conform to the following syntax (this is used at the MEX Layer on the client side):
instruction:value,
Valid instruction arguments are keywords that the server can identify and include the
following:
set_rf_tx_freq
set_rf_tx_power
set_rf_tx_sample_rate
set_recv_speed
play_file
play_receiving_rf
play_stop
Note: Files are sent to the server computer, independent of the actual server
program, using FTP. Thus, the server (program) will not recognise the send_file
instruction.
The value argument is dependent on the instruction. For example,
set_rf_tx_freq:440100000.
Argument validation will occur on both the client and server sides.
Reply Syntax
When the server receives a command it will respond with the following reply syntax:
instruction:success:information
The instruction filed is the instruction that was received by the sever, echoed back to the
client (this allows the client to be sure that the server is working with the correct
instruction). The success field is whether the corresponding instruction could be
executed. Valid values are either “success” or “failure”. Finally the information filed is
any additional information that the server may want to append. This will provide the user
on the client side with a way of troubleshooting errors. With the exception of the
information field, all fields may only contain lower case characters.
The server response to client instructions is a simple way to ensure that all TCP/IP
communications are successfully completed.