How To Accelerate Your Internet A practical guide to Bandwidth Management and Optimisation using Open Source Software How To Accelerate Your Internet For more information about this project, visit us online at http://bwmo.net/ Editor: Flickenger R. Associate Editors: Belcher M., Canessa E., Zennaro M. Publishers: INASP/ICTP © 2006, BMO Book Sprint Team First edition: October 2006 ISBN: 0-9778093-1-5 Many designations used by manufacturers and vendors to distinguish their products are claimed as trademarks. Where those designations appear in this book, and the authors were aware of a trademark claim, the designations have been printed in all caps or initial caps. All other trademarks are property of their respective owners. The authors and publisher have taken due care in preparation of this book, but make no expressed or implied warranty of any kind and assume no responsibil- ity for errors or omissions. No liability is assumed for incidental or consequen- tial damages in connection with or arising out of the use of the information con- tained herein. This work is released under the Creative Commons Attribution-ShareAlike 2.5 license. For more details regarding your rights to use and redistribute this work, see http://creativecommons.org/licenses/by-sa/2.5/ Contents Preface ix About This Book xi Introduction 1 Bandwidth, throughput, latency, and speed 2 Not enough to go around 3 Where to begin 5 Policy 9 The importance of policy 10 Explosive network growth at Havensburg 10 Bandwidth as a public good 11 Desperate measures 12 Policy, strategy, rules and regulations 13 Real policy development at Havensburg 14 Characteristics of good policy 15 The new Havensburg network policy 16 The policy development process 17 Policy is needed in all environments 19 Policy pitfalls 20 Example policies 20 Policy checklist 21 References 22 Monitoring & Analysis 25 Networking 101 26 Introduction 26 Cooperative communications 28 The OSI model 28 The TCP/IP model 31 The Internet protocols 32 Networking hardware 44 Physical connectivity 49 Virtual connectivity 58 What is network monitoring? 62 An effective network monitoring example 63 Monitoring your network 66 The dedicated monitoring server 67 What to monitor 70 How to select tools to monitor the network 71 Types of monitoring tools 72 Walking around the lab 73 Spot check tools 74 Log analysers 80 Trending tools 83 Realtime tools 87 Benchmarking 89 What is normal? 91 How do I interpret the traffic graph? 95 Monitoring RAM and CPU usage 97 Resources 99 Implementation 101 The importance of user education 102 The 5/50 rule 102 Providing feedback to users about network load 103 General good practices 105 Essential services 112 Firewall 114 Caching 134 Mirroring 144 Email 148 Resources 156 Troubleshooting 159 Proper troubleshooting technique 159 Preparing for problems 160 Responding to a problem 160 A basic approach to a broken network 161 Common symptoms 164 Automatic updates 164 Spyware 165 P2P 165 Email 165 Open email relay hosts 166 Email forwarding loops 167 Open proxies 167 Programs that install themselves 167 Programs that assume a high bandwidth link 167 Windows traffic on the Internet link 168 Streaming media / Voice over IP 169 Denial of Service 170 Rogue DHCP servers 170 Port analysis 171 Browser prefetch 172 Benchmark your ISP 172 Large downloads 172 Large uploads 173 Users sending each Before You Begin • Prerequisite Software – Latest iPhone SDK – Android SDK with 1.6 and any later SDKs installed – Titanium Developer • Getting Started Guide – http://developer.appcelerator.com/doc/mobile/get_st arted – Linked in tutorial notes at http://oscon.com Native Mobile Applications USING Open Source Want to give this talk? • Your local user group • Your company • To your wife and kids • Package includes: – Slides in various formats – Example code – Resources for presenters http://github.com/kwhinnery/MeetupPack Today’s Agenda • Titanium Mobile Overview • Hello World and Project Walkthrough • Building Titanium Apps: Fundamentals • Code By Numbers: Oh Snap! • Where To Go From Here • Questions and Answers • Independent Hacking About Me Kevin Whinnery Engineer/Platform Evangelist http://kevinwhinnery.com Twitter: @kevinwhinnery Web developer by trade and training, lover of JavaScript and open web technologies in general About Appcelerator • Open Source Software Company based in Mountain View • ~25 employees and growing • Developing Titanium for about two years, with Mobile coming in the last year • 95% Developers About You New To Mobile Development Mobile Dev Veteran Either way, you’ve come to the right place Amazing Mobile Platforms Which is great and exciting! Cross-Platform Tips 10 • iPhone/Android subdirectories • Ti.Platform.osname • Display height/width • OS version • Check Out Kitchen Sink Platform example • Questions? App Composition • Runtime environment • UI Layouts “Code By Numbers” • Demo App: Oh Snap! • Condensed version of Snapost – Source: http://github.com/kwhinnery/Snapost • App Features: – – – – • Multiple Window/Tabbed UI Properties API Camera and Local Photo Gallery Upload to remote web service (TwitPic) Want to develop and deploy to a device in the space of a few minutes A Nicer Version • Our example will be somewhat basic • For a nicer example with better styling and slightly more robust handling of images, check out Snapost • 3D iPhone transitions, laser noises! http://github.com/kwhinnery/Snapost iPhone SDK Users • Will need to download build to address iOS issues that is not in basic 1.3.0 release • Nightly Builds: – http://builds.appcelerator.com.s3.amazonaws.com/index.html • Let’s go through install of “latest and greatest” build 0: Create “Oh Snap!” http://gist.github.com/481044 • New Project via Titanium Developer • Grab new icons from Glyphish • Configure tab icons, new windows/execution contexts 1: Arrange Basic UI http://gist.github.com/481058 • Create necessary buttons, image placeholders, text labels • Arrange using vertical layout • Check out styling options 2: Persist Un/Pw Combo http://gist.github.com/481078 • Pre-populate text fields with Properties • Persist un/pw combo • Add event listener to save button 3: Select Media http://gist.github.com/481081 • Open Photo Gallery • Show Camera • Dynamically update ImageView source file 4: Upload Image http://gist.github.com/481111 • Create HTTPClient object • Open a POST request • Upload image media and Twitter update 5: Deploy to a device • Demo: Deploy via Titanium Developer • On your own, provision your system for development on device • Android == super easy • iPhone not so much • Video Tutorial: – http://vimeo.com/10278960 • All Appcelerator Videos: – http://vimeo.com/appcelerator Recapping Oh Snap! • < 200 Lines of code • Persistent App Preferences • Fully native UI (ugly, but see Snapost for the pretty ) • Integrated camera/photo gallery • XHR Upload to remote server • 100% Cross-Platform But wait, there’s more! • Animation APIs • Social Networks • Custom Module Development • iPad Development • HTML and CSS • Explore Desktop!!! Resources • Community Q&A • Reference Docs (new getting started guides just finished) • Premium Support (Pro Subscribers) • Kitchen Sink and Demo Apps • Dev Blog: Tutorials, Updates from dev team, developer-focused content • Follow @appcelerator for news and updates You Call It • Questions? Comments? • Need Help? Let’s hack your project! • Want to get in contact with someone regarding X, Y, or Z? I’ll direct you to the right folks • Anything else at all Kevin Whinnery http://kevinwhinnery.com http://twitter.com/kevinwhinnery IRC (irc.freenode.net): #titanium_app www.dbebooks.com - Free Books & magazines Christian B. Lahti Roderick Peterson This page intentionally left blank Elsevier, Inc., the author(s), and any person or fi rm involved in the writing, editing, or production (collectively “Makers”) of this book (“the Work”) do not guarantee or warrant the results to be obtained from the Work. There is no guarantee of any kind, expressed or implied, regarding the Work or its contents. The Work is sold AS IS and WITHOUT WARRANTY. You may have other legal rights, which vary from state to state. In no event will Makers be liable to you for damages, including any loss of profi ts, lost savings, or other incidental or consequential damages arising out from the Work or its contents. Because some states do not allow the exclusion or limitation of liability for consequential or incidental damages, the above limitation may not apply to you. You should always use reasonable care, including backup and other appropriate precautions, when working with computers, networks, data, and fi les. Syngress Media ® , Syngress ® , “Career Advancement Through Skill Enhancement ® ,” “Ask the Author UPDATE ® ,” and “Hack Proofi ng ® ,” are registered trademarks of Elsevier, Inc. “Syngress: The Defi nition of a Serious Security Library”™, “Mission Critical™,” and “The Only Way to Stop a Hacker is to Think Like One™” are trademarks of Elsevier, Inc. Brands and product names mentioned in this book are trademarks or service marks of their respective companies. PUBLISHED BY Syngress Publishing, Inc. Elsevier, Inc. 30 Corporate Drive Burlington, MA 01803 Sarbanes-Oxley IT Compliance Using Open Source Tools, 2E Copyright © 2007 by Elsevier, Inc. All rights reserved. Printed in the United States of America. Except as permitted under the Copyright Act of 1976, no part of this publication may be reproduced or distributed in any form or by any means, or stored in a database or retrieval system, without the prior written permission of the publisher, with the exception that the program listings may be entered, stored, and executed in a computer system, but they may not be reproduced for publication. Printed in the United States of America 1 2 3 4 5 6 7 8 9 0 ISBN 13: 978-1-59749-216-4 Publisher: Amorette Pedersen Page Layout and Art: SPi Acquisitions Editor: Patrice Rapalus Copy Editor: Judy Eby Project Manager: Greg deZarn-O’Hare Indexer: SPi Cover Designer: Michael Kavish For information on rights, translations, and bulk sales, contact Matt Pedersen, Commercial Sales Director and Rights, at Syngress Publishing; email m.pedersen@elsevier.com. This page intentionally left blank Christian B. Lahti is a computer services consultant with more than 18 years experience in the IT industry. He is an expert and evangelist in the fi eld of Open Source technologies in the IT enterprise and has successfully implemented global IT infrastructures. His focus and expertise lies in cross-platform integration and interoperability, security, database, and web development. Christian currently holds the position of Director of IT at a technology startup in Mountain View, CA and is a frequent speaker at both LinuxWorld and O’Reilly’s OSCON on a wide variety of topics such as Enterprise authentication and infrastructure monitoring and has contributed to several Open Source projects. Christian has a degree in Audio Engineering and has several certifi cations. He is an original co-author of the fi rst edition of this book and served as technical editor and contributing author to Windows to Linux Migration Toolkit (Syngress Publishing, ISBN: 1-931836-39-6). Roderick Peterson has more than 20 years’ experience in the IT industry. He has held various positions with both Fortune 500 public companies and small private companies. Roderick currently holds the position of IT Director at a public technology company 1 Before You Begin • Prerequisite Software – Latest iPhone SDK – Android SDK with 1.6 and any later SDKs installed – Titanium Developer • Getting Started Guide – http://developer.appcelerator.com/doc/mobile/get_st arted – Linked in tutorial notes at http://oscon.com 2 Native Mobile Applications USING Open Source 3 Want to give this talk? • Your local user group • Your company • To your wife and kids • Package includes: – Slides in various formats – Example code – Resources for presenters http://github.com/kwhinnery/MeetupPack 4 Today’s Agenda • Titanium Mobile Overview • Hello World and Project Walkthrough • Building Titanium Apps: Fundamentals • Code By Numbers: Oh Snap! • Where To Go From Here • Questions and Answers • Independent Hacking 5 About Me Kevin Whinnery Engineer/Platform Evangelist http://kevinwhinnery.com Twitter: @kevinwhinnery Web developer by trade and training, lover of JavaScript and open web technologies in general 6 About Appcelerator • Open Source Software Company based in Mountain View • ~25 employees and growing • Developing Titanium for about two years, with Mobile coming in the last year • 95% Developers 7 About You New To Mobile Development Mobile Dev Veteran 8 Either way, you’ve come to the right place. 9 Amazing Mobile Platforms 10 Which is great and exciting! [...]... Enter Titanium Titanium is an open source framework for building native mobile (or desktop) applications using open web technologies (JavaScript - optionally HTML and CSS) 1 Titanium Key Facts • Open Source (Apache 2.0) • Professional Services, SLA Support, Training, and Analytics available from Appcelerator Titanium Platforms 1 • Desktop: Win32, OS X, Linux • Mobile: iOS, Android, BlackBerry, webOS (soon)... faster and smoother on resource constrained devices Ideally, we build crossplatform native apps 1 .but we don’t want to “write once, suck everywhere”* *Loren Brichter, creator “Twitter for iPhone”/Tweetie 1 X-Platform Requirements • Target multiple platforms from a single codebase • Apps must feel like they belong on the platform • Apps need to perform like native • Bonus: Open source and extensible... only how do we target all these cool platforms? 1 Well, you could build native, but 1 • Which platforms do you choose? • How many codebases do you want to (or even can you) support? • How long will it take to build native on N platforms? • How much effort will be duplicated? • What if you bet on the wrong platform? • Who writes the code?... will focus on Developer and the Mobile SDK Titanium Features Native UI 2 Real native tables, tabs, sliders, and views Rich Media APIs Local and streaming audio and video, media recording Location APIs Open Source and Extensible Native Maps, Compass, and Geolocation Extend Titanium with custom modules in native code Local and Remote Data Integrated Analytics Local SQL Database, Lightweight Key/Value Store,... that is interpreted at runtime on the device • app.js defines the root execution context of the app • Note that we are not running in a browser • We use the WebKit KJS JavaScript engine (iOS) or Rhino (Android/ BB) 3 Titanium JavaScript API • Organized into logical namespaces • “Titanium” (or just “Ti” for short) is the root namespace for all Titanium functionality • A few other odds and ends in the global... a single context) Demo: Contexts 3 • New Project - Two Tabs with “Lightweight” windows • Switch to contain urls and contexts • Symbols not defined in other contexts • The View Hierarchy Views are the building blocks of Titanium UIs – Specialized views: table views, image views, map views, etc 3 • Views can contain child views, which are positioned relative to the parent • Layout Options: Absolute, ... • Bonus: Open source and extensible • Bonus: Use skills we already have Hmmm, I wonder if he has a specific technology in mind Enter Titanium Titanium is an open source framework for building... Applications USING Open Source Want to give this talk? • Your local user group • Your company • To your wife and kids • Package includes: – Slides in various formats – Example code – Resources for... building native mobile (or desktop) applications using open web technologies (JavaScript - optionally HTML and CSS) Titanium Key Facts • Open Source (Apache 2.0) • Professional Services, SLA