Voice over IP phone Software Design Software Engineering Project University of Oulu 2004
Page 2 of 48 Table of Contents 1. Version...4 2.Terminology...5 Abbreviations...5 Terms...5 3.Procedural Design...6 General...6 Process and threads...6 Internal messages of process...7 Comments / restrictions / limitations...8 4.Test Provisions...9 Test guidelines...9 Module testing...9 Interface testing...9 Special considerations...10 5.Scope...11 Major Software requirements...11 Design constraints, limitations...11 6.Human to machine interface specification...12 RS232 interface...12 Requirements...12 implementation...12 LCD-display...16 Requirements...16 implementation...16 LEDs...17 Requirements...17 implementation...17 Speaker...19 Requirements...19 implementation...19 Microphone...19 Requirements...19 implementation...20 7.Data structures...21 External / interface data structures...21 RTP header...21 RTP packet...21 Internal data structures...21 Network configuration...21 IP address and port...22 User configuration...22
Page 3 of 48 SIP connection information...22 Common RTP packet data...22 LCD text...22 8.Notes...23 9.References...24 10.Appendix...25
Page 4 of 48 1. Version Version v.1.0.0 Table 1Version Date(dd.mm.yyyy) 15.10.2004 Author Comments First version
Page 5 of 48 2.Terminology Abbreviations Abbreviation SIP ARP RTP ICMP UDP RFC Explanation Session Initiation Protocol Address Resolution Protocol Real-time Transport Protocol Internet Control Message Protocol User Datagram Protocol Request for Comments Table 2Abbreviations Terms Term Stubs RFC Explanation A stub is something which is short, underdeveloped, or partially cut off. Internet informational documents and standards Table 3Terms
Page 6 of 48 3.Procedural Design General VoIP phone will be implemented as one process main and multiple light processes called threads. Used OS is NutOS which is rather feature rich OS designed especially for Ethernut HW. Main idea of our SW design is to cover every individual HW resource (rs232, lcd, led, microphone, etc.) behind one thread. Variables (constants, data structures) can be accessed directly only one tread. With this arrangement we can avoid critical section problems and possible very hard to find bugs. If tread needs data owned by other tread then it must ask it by using XgmessageQue. All treads have own message queue where it check if new message is arrived. Process and threads Process / thread Main LCD LED Mic Spkr RTP SIP RS232 Task Head of the family. Maintains phone common settings. Controls LCD. Controls LEDs. Controls microphone. Controls speaker. Controls RPT session. Handles RTP packet sending / receiving. Encode / decode voice. Controls SIP sessions. Handles SIP packet sending / receiving. Listens SIP port for incoming connections. Controls serial interface. Handles serial UI. Table 4Process structure
Page 7 of 48 Internal messages of process Message Name id LCD_WRITE 101 LCD_CLEAR 102 LED_ON 201 LED_OFF 202 LED_BLINK 203 SPKR_ON 301 SPKR_OFF 302 SPKR_ALERT 303 SPKR_BUSY 304 SPKR_RINGBACK 305 MIC_ON 401 MIC_OFF 402 INCOMING_INVITE 501 OUTCOMING_INVITE 502 INCOMING_BUSY_HERE 503 OUTCOMING_BUSY_HER 504 E INCOMING_ACK 505 OUTCOMIG_ACK 506 INCOMING_BYE 507 OUTCOMING_BYE 508 INCOMING_OK 509 OUTCOMING_OK 510 INCOMING_RINGING 511 OUTCOMING_RINGING 512 INCOMING_USER_NOT_F 513 OUND OUTCOMING_USER_NOT 514 _FOUND INCOMING_REQUEST_TE 515 RMINATE OUTCOMING_REQUEST_ 516 TERMINATE CALL 601 END_CALL 602 ANSWER_CALL 603 RTP_CONNECT 701 RTP_DISCONNECT 702 Table 5Messages from to Parameter data Information line parameter 0 writes lcd lcd_text_t number all rows lcd led 1 to 8 0 turn off all LEDs led 1 to 8 led 1 to 8 spkr connect spkr disconnect spkr spkr spkr mic connect mic disconnect sip main sip_user_t main sip sip_user_t sip main sip_user_t main sip sip_user_t sip main main sip sip main main sip sip main main sip sip main main sip sip_user_t sip_user_t sip_user_t sip_user_t sip_user_t sip_user_t sip_user_t sip_user_t sip sip_user_t main main sip sip_user_t sip sip_user_t main main sip sip_user_t rs232main rs232main rs232main main rtp main rtp sip_user_t sip_user_t iaddr_t
Comments / restrictions / limitations arp and icmp echo reply is provided by OS. enough CPU and other HW resources? does messagequeue works as expected? NutOS limitations? Possible OS bugs? how many threads is possible to use? how much memory one threads takes? scheduling issues between threads and master? Page 8 of 48
Page 9 of 48 4.Test Provisions Testing is done in two phases; module- and interface testing. The aim of module testing is ensure internal functionality of our process family and aim of interface testing is verify protocol messaging. Module testing will be executed against software stubs and interface testing between two terminal equipments. Test guidelines Module testing Tools: software stubs network analyzer debugger test logs Things to be tested messaging between treads timers error handling user interface sip, rtp, (arp, icmp) Interface testing Tools: network analyzer other terminal equipment (IP-phone) Things to be tested
messaging between terminal equipments voice encoding/decoding voice transmission Page 10 of 48 Special considerations Speech quality can be measured by recording/hearing received voice and frequency response by example generating needed tones using signal generator (sin-signal) and measuring received signal by using oscilloscope. Also it could be possible to capture/record voice via computer sound-card and then measure signals using some audio software.
Page 11 of 48 5.Scope Major Software requirements Work assignment gives following guidelines: The VoIP phone has similar functionality as we know it from our contemporary telephone: It alerts the callee, user can make a call, transmits voice, receives voice and terminates a call. The phone uses state of the art Internet protocols: SIP (Session Initiation Protocol) and RTP (Real Time Protocol). SIP serves as the control protocol - to initiate and terminate calls. RTP is transporting the encoded voice. [Course Assignment; 521426A Software Engineering Project] Work assignment can be reached with parallel processing and distributing tasks to multiple threads. Parallel processing is required to get system working smoothly. Asynchronous data exchange between processes and threads will be used. NutOS is rather versatile real time platform which offers many helpful functionalities for multitasking. Process with multiple threads can be used to meet real time requirements. Only RTP data transfer needs quite hard real time processing. Design constraints, limitations See chapter: Comments / restrictions / limitations
Page 12 of 48 6.Human to machine interface specification User interfaces are: RS232 terminal connection (input/output) 4*16 characters text mode LCD-display (output) 8*LED (output) Speaker Microphone Ethernut board includes RS232 port and LEDs, LCD-display, speaker and microphone found on external IO-board which is connected to Ethernut board. RS232 interface Requirements call answer hangup reject on-line help set user set IP address set IP hostmask set MAC address (HW address) show configuration implementation startup (power on): Connected... NutOS version x.y.z
Page 13 of 48 Use help for basic help. Use help <command> for help on a specific command. help command: prompt> help List of available commands: call answer hangup help set_user set_ip set_hostmask set_mac show_config help call command: prompt> help call ### call <sip url (sip:username@host)> Calls to given user. Host can be given only in number format. For example 'call sip:babo@192.168.1.30' help answer command: prompt> help answer ### answer Answers to incoming call. Answer command can be shortened as one charter 'a'. help hangup command: prompt> help hangup ### hangup Disconnects ongoing call or rejects incoming call depending which one situation is in case. Hangup command can be shortened as one charter 'h'.
help help command: prompt> help help ### help [command] Help command without any arguments prints out the list of all possible commands. Use help <command> for help on a specific command. help set_user command: prompt> help set_user ### set_user <username> Set/change phone user. Username length can be between 1-xx characters. help set_ip command: prompt> help set_ip ### set_ip <x.x.x.x> Sets/change phone ip address. Every decimal must be between 0-255. IPv6 addressing is not supported. help set_hostmask command: prompt> help set_hostmask ### set_hostmask <x.x.x.x> Sets/change phone hostmask. Every decimal must be between 0-255. IPv6 addressing is not supported. help set_mac command: prompt> help set_mac ### set_mac <XX:XX:XX:XX:XX:XX> Sets/change phone ethernet HWaddress. Every value must be between 0-FF (HEX values). help show_config command: Page 14 of 48
Page 15 of 48 prompt> help show_config ### show_config Outputs current confguration. (user, ip address, hostmask, mac address) show_config command: prompt> show_config Current configuration: user: john ip: 192.168.1.10 hostmask: 255.255.255.0 mac: 00:0D:88:C8:24:76 execution, command success: OK: command executed obs. this text is not implemented at the first phase. It will be added later if necessary. execution error, unknown command: ERROR: unknown command execution error, invalid value (user enters unreasonable values): ERROR: invalid value execution error, change is not possible due to ongoing call etc.: ERROR: change not possible at the moment $ (dollar + one space) will be used as prompt. Enter without any
Page 16 of 48 character (empty command) prints new prompt on new line (linefeed + prompt). LCD-display Requirements display counterpart SIP address display call information display call duration (will be implemented if enough time) implementation Outcoming call: Call to sip:user @host Incoming call: Call from sip:us er@host Call connected: Call connected t o sip:user@host Call disconnected: Call disconnecte d by sip:user@ho st
Call canceled: Call canceled by sip:user@host User not found: User not found s ip:user@host User busy: User busy sip:us er@host Idle state: Idle LEDs Requirements display phone state implementation Outcoming call: LED 1 blinking Incoming call: LED 2 blinking Page 17 of 48
Outcoming call connected: LED 1 on Incoming call connected: LED 2 on Call disconnected: LEDs off Call canceled by local end: LED 3 on Call canceled by remote end: LED 4 on Local user not found: LED 7 on Remote user not found: LED 8 on Local user busy: LED 5 blinking Remote user busy: LED 6 on Idle state: LEDs off Page 18 of 48
Page 19 of 48 Speaker Requirements alerting voice implementation Incoming call: Alerting tone. Typical ringing tone; to be defined better during implementation. Remote user busy: Busy tone. Waiting for remote answer: Ring-Back tone. Call connected: Remote users voice. Dial tone is not needed and not implemented. Microphone Requirements Receive voice
implementation Not relevant. Page 20 of 48
7.Data structures External / interface data structures RTP header typedef struct { unsigned int version:2; unsigned int p:1; unsigned int x:1; unsigned int cc:4; unsigned int m:1; unsigned int pt:7; u_int16 seq; u_int32 ts; u_int32 ssrc; u_int32 csrc[1]; } rtp_hdr_t; /* /* /* /* /* /* /* /* /* /* protocol version */ padding flag */ header extension flag */ CSRC count */ marker bit */ payload type */ sequence number */ timestamp */ synchronization source */ optional CSRC list */ [12] Speak-Freely, http://speak-freely.sourceforge.net/ RTP packet #define MAX_PAY xxx typedef struct { rtp_hdr_t hdr; /* RTP headers */ u_char payload[max_pay]; /* RTP payload */ } rtp_packet_t; Internal data structures Network configuration typedef struct { u_long iaddr; u_long mask; u_long gateway; u_char hwaddr[16]; } ethconf_t; /* /* /* /* IP address */ hostmask */ gateway IP address */ Hardware address */ Page 21 of 48
Page 22 of 48 IP address and port typedef struct { u_long remote_iaddr; u_short remote_port; } iaddr_t; /* remote IP */ /* remote port */ User configuration #define USER_LEN xxx #define HOST_LEN xxx typedef struct { char user[user_len]; char host[host_len]; } userconf_t; /* username */ /* host */ SIP connection information #define SURI_LEN xxx typedef struct { char from[suri_len]; char to[suri_len]; char cseq[32]; iaddr_t remote_addr } sip_user_t; /* /* /* /* SIP uri */ SIP uri */ call sequence */ remote IP / port */ Common RTP packet data typedef struct { unsigned int version:2; unsigned int p:1; unsigned int count:5; unsigned int pt:8; u_int16 length; word */ } rtcp_common_t; /* /* /* /* /* protocol version */ padding flag */ varies by payload type */ payload type */ packet length in words, without this [12] Speak-Freely, http://speak-freely.sourceforge.net/ LCD text typedef union { char all[64]; char row[4][16]; } lcd_text_t; /* whole text */ /* text in a rows */
Page 23 of 48 8.Notes Some parts software design is defective due to lack of time. Course assignment is too large to design complete given time. Major weakness of our design is missing design of treads. Missing design will be updated during this project.
Page 24 of 48 9.References [1] Course Assignment; 521426A Software Engineering Project, http://www.ee.oulu.fi/research/tklab/courses/521426a/ [2] RFC3261, SIP: Session Initiation Protocol, http://www.ietf.org/rfc/rfc3261.txt [3] RFC2327, SDP: Session Description Protocol, http://www.ietf.org/rfc/rfc2327.txt [4] RFC3665, Session Initiation Protocol (SIP) Basic Call Flow Examples, http://www.ietf.org/rfc/rfc3665.txt [5] RFC1889, RTP: A Transport Protocol for Real-Time Applications, http://www.ietf.org/rfc/rfc1889.txt [6] RFC1890, RTP Profile for Audio and Video Conferences with Minimal Control, http://www.ietf.org/rfc/rfc1890.txt [7] The Internet Encyclopedia, G.711 Protocol Overview, http://www.freesoft.org/cie/topics/127.htm [8] Understanding SIP, http://www.iptel.org/sip/siptutorial.pdf [9] Functions for g711 coding, http://www.mnlab.cs.depaul.edu/~ehab/courses/tdc573/resources/a udioresources/g.723/g711.c [10] Ethernut HW and NutOS manufacturer, http://www.ethernut.de [11] Telecommunications Reference Index, http://nemesis.lonestar.org/reference/telecom/ [12] Speak-Freely, http://speak-freely.sourceforge.net/
10.Appendix All diagrams are developed using Prosa UML tools. Use case diagram use_case.ucd (hw) Class diagram class_diagram.cld(hw) Sequence diagram call.sqd (hw) other_call.sqd (hw) disconnect.sqd (hw) other_disconnect.sqd (hw) not_found.sqd (hw) other_not_found.sqd (hw) busy.sqd (hw) other_busy.sqd (hw) terminate.sqd (hw) other_terminate.sqd (hw) ethernut_call.sqd (sw) ethernut_other_call.sqd (sw) ethernut_disconnect.sqd (sw) ethernut_other_disconnect.sqd (sw) ethernut_not_found.sqd (sw) ethernut_other_not_found.sqd (sw) ethernut_busy.sqd (sw) ethernut_other_busy.sqd (sw) ethernut_terminate.sqd (sw) ethernut_other_terminate.sqd (sw) Page 25 of 48
Date and place 15.10.2004 Oulu Antti Palosaari Jaakko Tiri Kimmo Hettula Page 26 of 48
Page 27 of 48
Page 28 of 48
Page 29 of 48
Page 30 of 48
Page 31 of 48
Page 32 of 48
Page 33 of 48
Page 34 of 48
Page 35 of 48
Page 36 of 48
Page 37 of 48
Page 38 of 48
Page 39 of 48
Page 40 of 48
Page 41 of 48
Page 42 of 48
Page 43 of 48
Page 44 of 48
Page 45 of 48
Page 46 of 48
Page 47 of 48
Page 48 of 48