SWE 622- Distributed Systems Project Phase III Eric Barnes, David Chang, David Nelson Fisayo Oluwadiya, Xiang Shen.

Slides:



Advertisements
Similar presentations
Socket Programming ENTERPRISE JAVA. 2 Content  Sockets  Streams  Threads  Readings.
Advertisements

Multiplexing/Demux. CPSC Transport Layer 3-2 Multiplexing/demultiplexing application transport network link physical P1 application transport network.
IPv6 and Microsoft Windows (as of April 14, 2002) IPv6 Workshop Bill Cerveny.
April 5, 2004 Prof. Paul Lin 1 CPET 355 Data Communications & Networking 6. The Transport Layer (Transmission Control Protocol) Paul I-Hai Lin, Professor.
CPSC 441 Tutorial - Network Tools 1 Network Tools CPSC 441 – Computer Communications Tutorial.
Java Threads A tool for concurrency. OS schedules processes Ready Running 200 Blocked A process loses the CPU and another.
CSCE 515: Computer Network Programming Chin-Tser Huang University of South Carolina.
System Programming Practical session 10 Java sockets.
Java sockets. From waiting.
System Programming Practical session 11 Multiple clients server Non-Blocking I/O.
Welcome to CIS 235 Computer Networks Fall, 2007 Prof Peterson.
7/11/2007 AIIT Summer Course - D# 1 Wireless Embedded Systems and Networking Lab Day 3: Part 1: IP access using standard client programs Lab Assistant:
CISCO NETWORKING ACADEMY Chabot College ELEC ping & traceroute.
Web Proxy Server. Proxy Server Introduction Returns status and error messages. Handles http CGI requests. –For more information about CGI please refer.
1 ICMP : Internet Control Message Protocol Computer Network System Sirak Kaewjamnong.
Server Design Discuss Design issues for Servers Review Server Creation in Linux.
Practical Session 11 Multi Client-Server Java NIO.
Module 1: Reviewing the Suite of TCP/IP Protocols.
1 CMPT 471 Networking II ICMP © Janice Regan, 2012.
CS 6401 Internet Protocol Outline Introduction to Internet Protocol Header and address formats ICMP Tools.
1 Computer Networks and Internets Spring 2005 Assistant Professor JainShing Liu.
The Relationship of the Protocol Stack to the Operating System Last Update Copyright Kenneth M. Chipps Ph.D.
© Janice Regan, CMPT 128, CMPT 371 Data Communications and Networking Network Layer ICMP and fragmentation.
CS 352-Socket Programming & Threads Dept. of Computer Science Rutgers University (Thanks,this slides taken from er06/
NET0183 Networks and Communications Lecture 31 The Socket API 8/25/20091 NET0183 Networks and Communications by Dr Andy Brooks Lecture powerpoints from.
ICMP : Internet Control Message Protocol. Introduction ICMP is often considered part of the IP layer. It communicates error messages and other conditions.
School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae, VUW Networking COMP # 21.
IP Forwarding.
School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae david streader, VUW Echo Networking COMP
© Jörg Liebeherr (modified by M. Veeraraghavan) 1 ICMP: A helper protocol to IP The Internet Control Message Protocol (ICMP) is the protocol used for error.
1 Software Construction and Evolution - CSSE 375 Exception Handling - Principles Steve Chenoweth, RHIT Above – Exception handling on the ENIAC. From
Practicum: - Client-Server Computing in Java Fundamental Data Structures and Algorithms Margaret Reid-Miller 13 April 2004.
Mr C Johnston ICT Teacher BTEC IT Unit 05 - Lesson 05 Network Protocols.
1 (Worker Queues) cs What is a Thread Pool? A collection of threads that are created once (e.g. when a server starts) That is, no need to create.
© Lethbridge/Laganière 2005 Chap. 3: Basing Development on Reusable Technology The Client-Server Architecture A distributed system is a system in.
1 Perl Syntax: control structures Learning Perl, Schwartz.
School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae, VUW Networking COMP # 22.
Networks Sockets and Streams. TCP/IP in action server ports …65535 lower port numbers ( ) are reserved port echo7 time13 ftp20 telnet23.
School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae david streader, VUW Networking and Concurrency COMP.
CS390- Unix Programming Environment CS 390 Unix Programming Environment Java Socket Programming.
Distributed Trading System SWE 622 Charles Beach James Wolfe Scott Jones Sharita Green.
CSC 480 Software Engineering Socket. What is Socket? A socket is one end-point of a two-way communication link between two programs running on the network.
IP Telephone Lab 1 Connectivity Test IP Telephone Lab 2 Outline Ping & ICMP Fast Ping (fping) & AutoStatus One-Way Ping.
Practical Session 11 Multi Client-Server Java NIO.
SWE 622- Distributed Systems Project Phase I Eric Barnes, David Chang, David Nelson Fisayo Oluwadiya, Xiang Shen.
LSNDI RMRA 1 Design and troubleshooting M Clements.
Java Server Sockets ServerSocket : Object to listen for client connection requests Throws IOException accept() method to take the client connection. Returns.
Module 16: Distributed System Structures Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Apr 4, 2005 Distributed.
MT311 Java Application Development and Programming Languages Li Tak Sing ( 李德成 )
Network Programming: Servers. Agenda l Steps for creating a server Create a ServerSocket object Create a Socket object from ServerSocket Create an input.
Spring/2002 Distributed Software Engineering C:\unocourses\4350\slides\DefiningThreads 1 Java API for distributed computing.
Li Tak Sing COMPS311F. Case study: a multithreaded chat server The source contains 3 files: ChatServer //the chat server ChatThread //the thread on the.
Connect communicate collaborate Performance Metrics & Basic Tools Robert Stoy, DFN EGI TF, Madrid September 2013.
1 7 Ping Program. 2 7 Introduction - Problem How do I know if a host is reachable?
School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae david streader, VUW Echo Networking COMP
CCNA 2 Router and Routing Basics Module 8 TCP/IP Suite Error and Control Messages.
Lecture#6:Connectivity Verification
Echo Networking COMP
Threads in Java Two ways to start a thread
Connectivity Verification
Network Tools and Utilities
Networking COMP
or call for office visit,
ICMP ICMP = Internet Control Message Protocol Layer 3
Client-server Programming
Lecture#7:Connectivity Verification
Lecture#6:Connectivity Verification
Internet Control Message Protocol
Distributed Trading SWE 622 Spring 2009.
TCP/IP Protocol Suite 1 Chapter 9 Upon completion you will be able to: Internet Control Message Protocol Be familiar with the ICMP message format Know.
Presentation transcript:

SWE 622- Distributed Systems Project Phase III Eric Barnes, David Chang, David Nelson Fisayo Oluwadiya, Xiang Shen

Initial Design

Final Design

Initial Class Diagram

Final Class Diagram

public void init() throws Exception { _serverSocket = null; try { _serverSocket = new ServerSocket(_exchangePort); } catch (IOException e) { log.error("Could not listen on port:" + _exchangePort); System.exit(1); } while (true) { Socket clientSocket = null; try { log.info("WAITING"); clientSocket = _serverSocket.accept(); log.info("ACCEPTING"); } catch (IOException e) { log.error("Accept failed."); System.exit(1); } TraderConnectionManager manager = new TraderConnectionManager(clientSocket, this); traderManagers.add(manager); } Class Exchange init() method

public TraderConnectionManager(Socket clientSocket, Exchange _exchange) { this.exchange = _exchange; this.outMsgQueue = new ArrayBlockingQueue (50); try { out = new PrintWriter(clientSocket.getOutputStream(), true); in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream())); } catch (IOException e) { } Thread tin = new Thread(new TraderInput(clientSocket, outMsgQueue)); tin.start(); Thread tout = new Thread(new TraderOutput(clientSocket, outMsgQueue)); tout.start(); //set last keepalive so that we don't time out right away lastKeepaliveReceived = System.currentTimeMillis(); //schedule keepalives keepaliveTimer = new Timer("keepallive"); keepaliveTimer.scheduleAtFixedRate(new CheckTimeout(), KEEPALIVE_INTERVAL, KEEPALIVE_INTERVAL); } Class TraderConnectionManager constructor

public void run() { boolean connectedToExchange = initSocket(exchangAddr, port); if (connectedToExchange) { // set last keepalive so that we don't time out right away lastKeepaliveReceived = System.currentTimeMillis(); // schedule keepalives keepaliveTimer = new Timer("keepalive-" + _timeMsgQueue); keepaliveTimer.scheduleAtFixedRate(new SendKeepalive(), KEEPALIVE_INTERVAL, KEEPALIVE_INTERVAL); // schedule clock syncs clockSyncTimer = new Timer("clockSync-" + _timeMsgQueue); clockSyncTimer.scheduleAtFixedRate(new SyncClock(), 0, CLOCK_OFFSET_CHECK_INTERVAL); } Note: KEEPALIVE_INTERVAL = 5000; MAX_MISSED_KEEPALIVES = 2; //check every 1 hour (1000 ms/sec * 60 sec/min * 60 min/hour CLOCK_OFFSET_CHECK_INTERVAL = 1000 * 60 * 60; Class ExchangeConnectionManager run() method

TradeTransaction t = new TradeTransaction(fromServer); boolean outOfOrder = t.getMessageID() < newestMessageProcessed; //if the message was out of order, flag it, but don't set it as the last ID recieved to // ensure that subsequent out of order messages are also flagged. e.g. if IDs arrive // in the order 5 3 4, both 3 and 4 should be flagged if(outOfOrder) { log.error("Out of order"); t.setOutOfOrder(true); } else { newestMessageProcessed = t.getMessageID(); log.info("Message sequence:" + newestMessageProcessed); } t.setStale(_clockDelta + System.currentTimeMillis()); processedTAQueue.put(t); Just in case the echo messages are out of order

TradeTransaction t = new TradeTransaction(fromServer); boolean outOfOrder = t.getMessageID() < newestMessageProcessed; //if the message was out of order, flag it, but don't set it as the last ID recieved to // ensure that subsequent out of order messages are also flagged. e.g. if IDs arrive // in the order 5 3 4, both 3 and 4 should be flagged if(outOfOrder) { log.error("Out of order"); t.setOutOfOrder(true); } else { newestMessageProcessed = t.getMessageID(); log.info("Message sequence:" + newestMessageProcessed); } t.setStale(_clockDelta + System.currentTimeMillis()); processedTAQueue.put(t); Just in case the echo messages are out of order

private class SyncClock extends TimerTask public void run() { long requestTime; long receiveTime; long oneWay; long exchangeTime; long totalDelta = 0; int tryTimes = 3; String timeStr = ""; for (int i = 0; i < tryTimes; i++) { requestTime = System.currentTimeMillis(); log.info("requestTime " + i + "=" + requestTime); requestTime(requestTime); try { timeStr = _timeMsgQueue.take(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } exchangeTime = Long.parseLong(timeStr.replace("time:", "")); log.info("exchangeTime " + i + "=" + exchangeTime); receiveTime = System.currentTimeMillis(); log.info("receiveTime " + i + "=" + receiveTime); oneWay = (receiveTime - requestTime) / 2; totalDelta += exchangeTime + oneWay - receiveTime; } _clockDelta = totalDelta / tryTimes; log.info("clockDelta=" + _clockDelta); } How to figure how to the clock delta between exchange and trader

All SLOC: SLOC Directory SLOC-by-Language (Sorted) 435 gui java= exchange java= trader java= common java=147 Totals grouped by language (dominant language first): java: 1325 (100.00%) Reused SLOC (GUI code provided by Prof. Sousa): SLOC Directory SLOC-by-Language (Sorted) 311 gui java=311 Totals grouped by language (dominant language first): java: 311 (100.00%) Total New SLOC: SLOC Directory SLOC-by-Language (Sorted) 1014 src java=1014 Totals grouped by language (dominant language first): java: 1014 (100.00%) Total Physical Source Lines of Code (SLOC) = 1,014 Development Effort Estimate, Person-Years (Person-Months) = 0.20 (2.44) (Basic COCOMO model, Person-Months = 2.4 * (KSLOC**1.05)) Schedule Estimate, Years (Months) = 0.29 (3.51) (Basic COCOMO model, Months = 2.5 * (person-months**0.38)) Total Estimated Cost to Develop = $ 27,415 (average salary = $56,286/year, overhead = 2.40). SLOCCount, Copyright (C) David A. Wheeler Source Lines Of Code

Effort spent in design: 120 Effort spent in design coding: 100 Effort spent in design integrating: 40 Effort spent in design experiments: 60 Total effort: 320 Note: All of them are estimates Effort spent for the project (man-hour)

SUSE Linux 10 SP1 (i586) –Kernel: bigsmp #1 SMP Thu May 17 14:00:09 UTC 2007 –Memory: 4GB –CPU: 2 x Intel(R) 3.40GHz –Java: java version "1.6.0_12“ Solaris 10 – Kernel: SunOS mason 5.10 Generic_ sun4u sparc SUNW,Sun-Fire-V890 – Memory: 32GB – CPU: 8 x Sparc 1350 MHz – Java: java version "1.6.0_11“ Microsoft Windows XP SP3 –Java: java version "1.6.0_01“ Microsoft Windows Vista SP1 –Java: java version "1.6.0_12“ Testing Environment

LAN: Ping < 1ms Direct connected by a network switch WAN: 10ms < Ping < 30ms Pinging mason.gmu.edu [ ] with 32 bytes of data: Reply from : bytes=32 time=13ms TTL=246 Reply from : bytes=32 time=14ms TTL=246 Reply from : bytes=32 time=19ms TTL=246 Reply from : bytes=32 time=12ms TTL=246 Ping statistics for : Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 12ms, Maximum = 19ms, Average = 14ms Many network hops Tracing route to mason.gmu.edu [ ] over a maximum of 30 hops: 1 1 ms 1 ms 1 ms ms 9 ms 8 ms ms 9 ms 9 ms ip dc.dc.cox.net [ ] 4 9 ms 10 ms 9 ms mrfddsrj01-ge110.rd.dc.cox.net [ ] 5 13 ms 10 ms 10 ms ashbbbrj01-ae0.0.r2.as.cox.net [ ] 6 13 ms 64 ms 11 ms ae car1.Washington1.Level3.net [ ] 7 16 ms 13 ms 12 ms GEORGE-MASO.car1.Washington1.Level3.net [ ] 8 * * * Request timed out. 9 * * * Request timed out ms 15 ms 12 ms mason.gmu.edu [ ] Testing Network and network latency

LAN: Ping statistics for : Approximate round trip times in milli-seconds Minimum = 0ms, Maximum = 0ms, Average = 0ms WAN: Ping statistics for (mason.gmu.edu): Approximate round trip times in milli-seconds: Minimum = 17ms, Maximum = 20ms, Average = 18ms

Avg=86.7

Between each Exchange and Trader there is a TCP connection If the Trader fails, each Exchange will know immediately –Read failed error –Depends on the network latency If the network also fails, each Exchange will disconnect the failed Trader after the time-out –MAX_MISSED_KEEPALIVES* KEEPALIVE_INTERVAL In the log file: ERROR TraderConnectionManager:130 - Read failed. Client seems gone or the exchange is closing. INFO TraderConnectionManager:68 - Disconnecting INFO TraderConnectionManager:85 - disconnecting trader INFO TraderConnectionManager:137 - EXIT INPUT INFO TraderConnectionManager:177 - EXIT OUTPUT Latency between a trader failure and the last exchange stopping echoing orders

Linux and the Sun box all have ntpd running All Windows boxes all have the Windows time service running Clock Skew we observed on the Linux box (from the NTP log): …… 25 Apr 04:56:57 ntpd[3151]: time reset s 25 Apr 05:01:13 ntpd[3151]: synchronized to LOCAL(0), stratum Apr 05:02:18 ntpd[3151]: synchronized to , stratum 1 25 Apr 05:28:11 ntpd[3151]: time reset s 25 Apr 05:32:28 ntpd[3151]: synchronized to LOCAL(0), stratum Apr 05:33:31 ntpd[3151]: synchronized to , stratum 1 25 Apr 05:47:29 ntpd[3151]: time reset s …… Testing Scenario: –Stop ntpd on Linux –Change time, for example: date +%T -s "17:07“ –Test Clock Skew