CSE 145 Underwater Modem Project Networking Library Robert Chen
Purpose β’ Goal: To develop an API that will enable programmable devices and appliances to easily interface with the underwater acoustic modem β’ Deliverable: C API and programming library β’ Requirements: β’ Portable on different platforms β’ Microcontrollers, Computers, Cell Phones, etc. β’ Easy to use, well documented
Modem Components Packet/Host Layer Transport Datalink/Network FPGA/DSP Physical Layer PSK FSK DSSS ASK Transducer/Amplifier
Simple Model SOFTWARE ZONE βstringβ 1010001010011111010001010010β¦. HARDWARE ZONE HARDWARE ZONE 1010001010011111010001010010β¦. SOFTWARE ZONE βstringβ
Frame Format = 8 bits Total: 72 bits / 9 bytes β’ Data Bytes β’ Type β’ CRC β’ Counter β’ To β’ From
Simple Example Frame sendString(0x02, βHI!β); 0x01 0x02 0x25 0x00 βHβ βIβ β!β β/0β 0xE9
Structure Representation
Example Programs β’ Program 1 (0x21): β’ sendString(0x31, βHELLO WORLD!!!β); β’ Program 2 (0x31): β’ recvString(0x21, β%sβ, buffer);
Program 1: String to Frames 0x01 0x00 0x00 0x00 βHβ βEβ βLβ βLβ 0x00 0x01 0x00 0x00 0x00 βOβ β β βWβ βOβ 0x00 0x01 0x00 0x00 0x00 βRβ βLβ βDβ β!β 0x00 0x01 0x00 0x00 0x00 β!β β!β β/0β β/0β 0x00 β’ String is broken up β’ Put into frames that hold 4 bytes each
Program 1: Addressing 0x01 0x31 0x21 0x00 βHβ βEβ βLβ βLβ 0x00 0x01 0x31 0x21 0x00 βOβ β β βWβ βOβ 0x00 0x01 0x31 0x21 0x00 βRβ βLβ βDβ β!β 0x00 0x01 0x31 0x21 0x00 β!β β!β β/0β β/0β 0x00 Fill in To / From address fields
Program 1: TX Queue β’ Frames are then added to transmit queue in string order β’ What happens now? β’ Blocking Implementation β’ Process queue immediately β’ Non-Blocking Implementation β’ Manual function call to process queue when convenient, i.e. by interrupt
Program 1: Process TX Queue 0x01 0x31 0x21 0x00 βHβ βEβ βLβ βLβ 0x00 0x01 0x31 0x21 0x00 βOβ β β βWβ βOβ 0x00 0x01 0x31 0x21 0x00 βRβ βLβ βDβ β!β 0x00 0x01 0x31 0x21 0x00 β!β β!β β/0β β/0β 0x00 0x01 0x31 0x21 0x00 β/0β β/0β β/0β β/0β 0x00 β’ For all frames on TX Queue: β’ POP and add to a window of size X β’ Window = fixed length set of frames, 5 in this ex.
Program 1: Numbering and CRC 0x01 0x31 0x21 0x00 βHβ βEβ βLβ βLβ 0xB7 0x01 0x31 0x21 0x01 βOβ β β βWβ βOβ 0x9F 0x01 0x31 0x21 0x02 βRβ βLβ βDβ β!β 0x03 0x01 0x31 0x21 0x03 β!β β!β β/0β β/0β 0x25 0x01 0x31 0x21 0x04 β/0β β/0β β/0β β/0β 0xC0 Number off Frames Calculate CRC β Cyclic Redundancy Check
Program 1: Send Window START HERE STOP HERE For all frames in window, send byte by byte as a stream of bytes Waits for ACK responses
Program 2: Receive Window #1 #2 #3 #4 #5 β’ Receive stream of bytes β’ Known:WINDOW SIZE XFRAME LENGTH β’ 5 X 9 bytes = 45 bytes
Program 2: Reconstitute Frames OK! 0x01 0x31 0x21 0x00 βHβ βEβ βLβ βLβ 0xB7 BAD! 0x01 0x31 0x21 0x01 βOβ β β βXβ βLβ 0x9F OK! 0x01 0x31 0x21 0x02 βRβ βLβ βDβ β!β 0x03 BAD! 0x01 0x31 0x21 0x03 β!β β!β β/0β β/0β 0x00 OK! 0x01 0x31 0x21 0x04 β/0β β/0β β/0β β/0β 0xC0 Perform CRC check on each received frame
Program 2: ACK Response 0x01 0x31 0x21 0x00 βHβ βEβ βLβ βLβ 0xB7 0x06 0x21 0x31 0x00 0x00 0x00 0x00 0x00 0x7F β’ For all OK frames β’ Respond: βI got frame #Xβ β’ For all BAD frames, do nothing β’ Sender will send the missing frame again if it doesnβt get a valid response before timeout
Program 2: Re-build Window 0x01 0x31 0x01 0x00 βHβ βEβ βLβ βLβ 0xB7 0x01 0x31 0x01 0x01 βOβ β β βWβ βOβ 0x9F 0x01 0x31 0x01 0x02 βRβ βLβ βDβ β!β 0x03 0x01 0x31 0x01 0x03 β!β β!β β/0β β/0β 0x25 0x01 0x31 0x01 0x04 β/0β β/0β β/0β β/0β 0xC0
Program 2: Reform String βHβ βEβ βLβ βLβ βOβ β β βWβ βOβ βRβ βLβ βDβ β!β β!β β!β β/0β β/0β β/0β β/0β β/0β β/0β β’ βHELLO WORLD!!!000000β β’ Assume 0 = β/0β
Example Program β’ Program 1 (0x21): β’ sendString(0x31, βHELLO WORLD!!!β); β’ Program 2 (0x31): β’ recvString(0x21, β%sβ, buffer);
Simulation Application #1 Library COM 4 | | COM 5 Library Application #2
Design Constraints β’ Use of a constant time, fixed sized queue which does not use the heap β’ No use of heap: β’ Flaky memory management support on some embedded platforms. β’ The runtime memory space of the library is known by compile time β’ βThe lowest average instruction path length required to allocate a single memory slot was 52 (as measured with an instruction level profiler on a variety of software)β β’ Small CRC algorithm, 8 bit output β’ Plain standard C, no special libraries
Key Features β’ KISS Principle β’ Usability- Printf style statements β’ Works with many data types β’ Easy to Debug and Troubleshoot β’ Flexible, rapid development β’ Tradeoff β’ Less efficient, sends more data β’ May be slightly disadvantageous in a low power setting
Possible Applications β’ Underwater UAV β’ sendString(0xF3, βx: %d y: %d z: %dβ, my_x, my_y, my_z); β’ recvString(0xF3, βx: %d y: %d z: %dβ, &uav_x, &uav_y, &uav_z); β’ Underwater Sensor Platform β’ sendString(0xF2, βtemperature: %2.f, oxygen: %dβ, temp, oxy); β’ recvString(0xF2, βtemperature: %2.f, oxygen: %dβ, &temp, &oxy);
Possible Applications (contβd) β’ Communications Device for Divers β’ sbroadcast(β%s: %sβ, username, message); β’ rbroadcast(β%s: %sβ, buddy, his_message); β’ Message Beacon on a Buoy floating above an Underwater Archaeological Dig β’ sbroadcast(βBUOY 3 IS GRID 7B β); β’ rbroadcast(β%sβ, broadcastbuffer);
Room for Improvement ⒠Interface and test with actual hardware ⒠Experiment with⦠⒠Different Environments ⒠Dynamically adjust according to error rate ⒠Different windows sizes and frame data field lengths
Challenges & Problems Late project start Matlab+ Serial = ο
Results Library is highly functional and usable Major objectives achieved, project is a success
Acknowledgements β’ Thanks! β’ Prof. Ryan Kastner β’ DibaMirza β’ Jennifer Trezzo β’ Nancy Wu
Questions?