ENGG*44200 Real Time System Design Lab3 Implement VoIP on ARM 1 Outline Features of VoIP IP Communication Device Examples Phone Protocol of the Lab 2
VoIP Voice Calls are transmitted over Packet Switched Network instead of Public Switched Telephone Networks (PSTN) Modes of Operation: PC to PC (MSN, Yahoo Messenger) PC to Telephone (Net2Phone home page) Telephone to Telephone 3 Why VoIP? Cheaper Call More Applications Security 4
5 6
7 LCD KEYPAD SOFTWARE I/O CODEC TCP/IP uc/os-ii RTOS A/D & D/A S3C44B0X S3CEV40 ETHERNET PORT VOICE ETHERNET8
Lab3 Architecture Applications (tasks and FSM) Communication Protocol (TCP/IP our own protocol) Real Time Operation System Kernal (UCOS-II) and Device Drivers (Ethernet.c, IIS.c, LCD.c, etc.) Boot loader (44binit.s, etc.) Communication Hardware (Embest HW including RTL8019, IIS chip, etc.) \ 9 Voice In Voice Out A/D D/A CODEC CODEC Buffering Buffering Text In Transmit Receive Text Out Ethernet 10
Functional Requirements Broadcast your phone status (online/busy) to other groups. Use the PC keyboard to introduce a group number to be called to establish a connection. Use the PC keyboard to send short messages to a group once connection is established. LCD is used to show information like on-line groups, send message, received messages, sending and receiving status, states, connection time. Use the LCD or UART0 to display the time passed while communicating with a MAC address (i.e. a specific group once connected). 11 Functional Requirements Cont. The 7-segment display is used to display the group currently connect to, up to a maximum of 15 (F). For groups larger than 15, rollover back to 1 and continue from there (i.e. group # 16 = group #1, group #2 = 17, etc..) Use the microphone and the earphones to perform a duplex audio communication. Use a packet length of 1000 for voice communication and recording length of 0x8000. At the minimum, you should at least be able to send a prerecorded sound to a connected group (doesn t necessarily have to be recorded and sent in real time) 12
Protocol Format The protocol format should be in the format of: DESTINATION ADDRESS[6] + SOURCE ADDRESS[6] + LENGTH[2] + MESSAGE TYPE[1] + PACKET NUM[2] + MESSAGE[?] MESSAGE TYPE is the first byte of your data to be sent. 0x10: Broadcast AVAILABLE, followed by your group number. 0x11: Broadcast BUSY, followed by your group number. 0x12: REQUEST a connection, followed by the group number to be connected. 0x13: ACCEPT a connection, followed by your group number. 0x14: Send a TEXT MESSAGE, followed by the text message. 0x15: Corresponds to voice data 0x16: Corresponds to the last portion of buffered voice data, begin playback after receiving 0x17: CLOSE a connection, followed by your group number. 13 MAC Address You have to setup you own NIC MAC address in the format of: 00-20-05-44-20-XX XX is your group number, Hex number For example, your group number is 0x12, then you should use 00-20-05-44-20-12 as your NIC MAC address. 14
System Constrains The system broadcast its status every 10-15 seconds (some give here depending on how busy the network gets). The maximum length of message to be sent is 1514 bytes. One board can communicate to only one another board simultaneously. 15 Deadlines and Marking Lab 3 is worth a total of 16% 2% for the demo requirements (3.3.2, review of template code), 2% for the Petri Net Diagram (included with report), 6% for the Demo, 6% for the Report The Lab 3 Demo is Due Nov 20/22 in your lab The report is due along with the demo (i.e. Nov 20/22) 16
FAQ1: How do I Send and Receive Data? This functionality is located in the predefined functions located in Ethernet.c. Initialization is handled by NicInit(), sending is performed by EtherOutput(), and receiving is done using EtherInput(). There are at least two ways of integrating these functions. One is including the Ethernet.c file to your project. The other is copying the functions from Ethernet.c and placing them in your main code. 17 FAQ2: What do I need to change In NicInit(void) function? Check to make sure the following changes are made in your NicInit(void) code: /* set MAC address */ change to your MAC address here /* broadcast address is 0x0 */ change from 0x0 to 0xff /* only accept destination address message */ change from 0x0 to 0x4 (accept broadcast addresses) 18
FAQ3: What do I need to change in the EtherOutput() function? Eliminate the eh structure. Define a unsigned char packet_to_send[1514]; Set destination MAC address */ Set source MAC address */ Calculate length Assemble data (header and message) Send package ***Note: if you re assembling your packet in the fashion outlined in the template before sending it to EtherOutput(), you shouldn t need to make any changes. (for details, please refer to the template function EtherOutput()) 19 FAQ4: What About the EtherInput() Function? Function takes in a pointer to an array of characters (i.e. a string), where the received data will be copied to. Returns length as an integer value (length should be at least 17 for a valid packet, 6+6+2+1) Can do your processing on the received packet within EtherInput() or within the main code (for more details, please refer to the template function EtherInput()) 20
FAQ5: How do I Send Voice Data? General Process: Record a sound sample of length specified by recording length parameter After recording is finished, copy the recorded sample to a DIFFERENT MEMORY LOCATION than your recording location. This can be done using the memcpy() function memcpy((void *)0x0C400000+2*REC_LEN, (void*)0x0c400000,rec_len); Divide the recorded sound into sound packets based on your maximum packet length. Mark each packet with the identifier 0x16, except for the last, which should be 0x17, sending them to EtherOutput(), allow for some delay between packets. 21 FAQ6: How do I Receive Sound? General Process: Look for a packet with Voice as it s type Copy the data portion of that packet to a specified memory location (once again, use memcpy()) Wait until a packet of LastVoice is received Copy from the storage location to the memory destination defined in Playwave() Call Playwave() 22
FAQ 7: How and When Do I Do DMA? Since you re transferring data from an peripheral (the microphone) to a memory location, the type of DMA being performed is Bridge DMA (BDMA) Iis_wav.c already has some BDMA functions in place. Depending on your implementation, you may need to move and change them. 23 FAQ 8: What do I Need to Change in Record_Iis()? You ll need to change the IIS register settings You ll notice that Record_Iis() also plays back the recorded sound. You probably want to take that part of the code out. Be careful with the interrupt masking as problems can arise from it. Also: Remember to change your REC_LEN!! 24
FAQ 9: What do I Need to Change in Playwave()? Once again, be careful with the interrupt masking (rather than strictly working with the bits, use the BDMA functions) Make sure your copying the sound data from the memory location you stored it in Change the sound length to the defined recorded length (i.e. sound_len = 0x8000) After copying from the memory location to the playback buffer, you ll need to perform a BDMA done check before actually playing the sound You ll need to change the values of the IIS registers 25 FAQ 10: Where do I get Information About the IIS and DMA Registers? Information about the DMA and IIS registers can be found in the S3C44B0X PDF 26
Other Notes Don t try to send packets while you re receiving sound. Due to the volume of data, the Ethernet port will likely crash The TA boards at the back have code flashed on to them. If something isn t working, try turning the board off and back on. If things are still broken, email me and I ll come in as soon as I can to take a look/reflash the program If no one is working with the TA boards, please turn them off 27 Other Notes Cont. A user s guide can be found with each of the TA boards. If the guide is missing, please let me know and I ll print off a new copy and replace it Once everyone is working on their labs and sending information, the network will likely become very slow. This will likely cause problems with voice communication. It may be worthwhile consulting with other groups and establishing work slots for different groups. 28