ecs152b winter 2010 project 1 discussion

ecs152b winter 2010 project 1 discussion - My website...

Info icon This preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: My website Yichuan Wang [email protected] http://www.cs.ucdavis.edu/~yichuan/ Discussion material Project 1 From Word to Code How to perceive a program User requirement Run time behavior Program architecture Object, Class, Interface, etc. Data structure Real life SIP Simple SIP scenario '*!+ 3 &%2,1+ 4+*&%(" (5 &+&&%(" '("#*(1 ,*(#('(1 &#6'7 '611+8 )9!: %" ;646 #$6# *+&+2 9+&&%(" !"%#%6#%(" :*(#('(1 =9!:>? 3 &2611 ,*(@*62 '611+8 )9!:A+&# <6&+8 (" #$+ )9!: &#6'7 %" ;646? A$+ '16&& "62 ,*(@*62 &$()18 <+ !"#$%&'(? Out-of-band signalling The session is independent to the signaling )9!: %& )&+8 #( %"%#%6#+ 6 &+&&%(" <+#0++" #0( ,++*&? 3& &$(0" %" #$+ 5%@)*+ 6<(4+. B+ #$*()@$ CE 6*+ )9!: 2+&&[email protected]+&? A$+ 6'#)61 &+&&%(" %"%#%6#+8 </ )9!: %& %"8+,+"8+"# (5 ) A$+ &+&&%(" '6" <+ 8+&'*%<+8 </ 6"/ ')&#(2 &+&&%(" 8+&'*%,#%(" 16"@)[email protected]+ '6**%+8 </ #$ 2+&&[email protected]+ 6& ,6/1(68? What we require A simple SIP stack + application (uSIP) Handle simple call setup Handle wrong (out of order) signal No packet loss in the network The user session is plain text message with specific message structure Run time uSIP apps communicate on UDP (both signaling and actual data) and client) uSIP use P2P architecture (combine server As client, take user input. (user data) Handle one outgoing session. sessions. As server, accepts multiple incoming Architecture Separate SIP stack and User application, with interface public interface SipListener extends EventListener { public void processMsg(SipMessage msg); } class MyListener implements SipListener { public void processMsg(SipMessage msg){ ... } } class SipProvider{ public void addListener(SipListener ls){ ... } } Message Parser Reading byte array decode to String Fill the Message object with string content INVITE 11 21 192.168.2.2 6000 [Method] [Branch] [CallID] [Payload] [Payload] Threading Main Thread !"#$%&' *+,,%-.$' Server thread ()!"#$%&' ()/.%00' 12-3$450'%#$'5"#$%&06' 9%:' 12-3$450'785"'#+,16'-2&)6' 9-:' Shared memory IPC/RMI Datagram (UDP) Socket DatagramSocket clientSocket; try { clientSocket = new DatagramSocket(); byte sendData = msg.getBytes(); InetAddress IPAddress; IPAddress = InetAddress.getByName(ip); DatagramPacket sendPacket = new DatagramPacket(...); clientSocket.send(sendPacket); } catch --------------------------------DatagramPacket packet = new DatagramPacket(); sock.receive(packet); Server Client public class ServerThread implements Runnable { public void run() { try { while (this.isRunning) { DatagramPacket packet = new DatagramPacket(); sock.receive(packet); } } catch (IOException e) { System.out.println("public void run()"); } } public void start() { if(isRunning == false){ isRunning = true; serverThread.start(); } } public void stop() { if(isRunning == true){ isRunning = false; serverThread.interrupt(); sock.close(); } } Finite State Machine .%$1 2+33$'% ./04'1 .9:.;- public void processMsg(Message msg) { if (state == INIT_STATE) { ... } else if (state == S_WAIT_ACK) { ... } !"##$%& 4'1 566 !'%($)*+, 2+%, 566 2+%, <!= 2+33$'% 2+%, 78- !"##+, 4'1 <!= !'%($)*+, !#'3+ 3+33$'% !#'3+, ... 4'1 782+%, 566 -%,+, 4'1 566 -%,+, !"##$%& '"#()$*+$%& .% 1>$3 ?)'@+A1 B+ C3+ " D+)E 3$*?#+ #"%&C"&+ 1' ,+3A)$F+ 1>+ 3+33$'% B+ ")+ C3$%&G HC31 C3$%& .I ",,)+33J ?')1 %C*F+) "%, A>")"A1+) +%A',$%& B+ B$## F+ "F#+ 1' FC$#, " K/I 3+33$'%G User session Open new UDP connection (on different port/IP) different protocol (user defined, for different media) used. For project grading, a simple one will be Test scenario Text S txeT Text <student id> Session 2 Session 1 Questions? ...
View Full Document

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern