Important Announcement
PubHTML5 Scheduled Server Maintenance on (GMT) Sunday, June 26th, 2:00 am - 8:00 am.
PubHTML5 site will be inoperative during the times indicated!

Home Explore OpenSourceForYou201504

OpenSourceForYou201504

Published by E-book Bang SAOTHONG Distric Public library, 2019-12-11 22:00:10

Description: OpenSourceForYou201504

Search

Read the Text Version

here we have a signal called haveFortune(), which becomes the Let’s Try Developers property onHaveFortune inside the QML component, and gets assigned an event handler in the QML file, as follows: emit haveFortune(QString(fortune)); } onHaveFortune: mainFortuneLabel.setText(fortune); You already know how we’re using this inside QML. We can now take a look at the C++ code for the object: Firing it up #include “fortuneclient.h” We’ll need to write main.cpp first, which is luckily less than FortuneClient::FortuneClient() five lines of actual code. Here it is: { #include <QQmlApplicationEngine> mPort = 0; #include “fortuneclient.h” clientSocket = new QTcpSocket(this); } int main(int argc, char *argv[]) { FortuneClient::~FortuneClient() { QApplication app(argc, argv); clientSocket->disconnectFromHost(); QQmlApplicationEngine engine; clientSocket->deleteLater(); qmlRegisterType<FortuneClient>(“Fortune”, 1, 0, } “FortuneClient”); engine.load(QUrl(QStringLiteral(“qrc:/main.qml”))); /* accessors and mutators for the properties go first */ return app.exec(); } QString FortuneClient::serverHost() const { The critical line here is the qmlRegisterType() statement, which registers a component and injects it into the return mHost; QQmlApplicationEngine. The syntax is: } qmlRegisterType<object_name>(“namespace”, major_version, void FortuneClient::setServerHost(QString host) minor_version, “component_name”); { So for the above line, you’d import the Fortune 1.0 name mHost = host; space, and create a FortuneClient object within the QML code. } You can now go ahead and build the application, and quint16 FortuneClient::serverPort() const run it. Run the server that we built last month, and in the { GUI, go to Application->Set Server Details; fill in the host (127.0.0.1) and the port (56789), and hit OK. The status return mPort; bar should now say OK: Server set to 127.0.0.1:56789. Go } ahead and hit the Get Fortune button. If everything works fine, you’ll be greeted with your fortune cookie. void FortuneClient::setServerPort(int port) { References mPort = (quint16)port; [1] The QML Documentation } - http://doc.qt.io/qt-5/qtqml-index.html /* the slot we call to get a new fortune */ [2] The QML Complete Reference - http://doc.qt.io/qt-5/qmlreference.html void FortuneClient::getNewFortune() { [3] The QtQuick Documentation - http://doc.qt.io/qt-5/qtquick-index.html QByteArray fortune; clientSocket->connectToHost(mHost, mPort, [4] The QtQuick QML Types Reference QIODevice::ReadOnly); - http://doc.qt.io/qt-5/qtquick-qmlmodule.html clientSocket->waitForReadyRead(); fortune = clientSocket->readAll(); By: Boudhayan Gupta clientSocket->disconnectFromHost(); Describing himself as a ‘retard by choice’, the author believes that madness is a cure-all for whatever is wrong or right with society. A social media enthusiast, he can be reached at @BaloneyGeek on Twitter. www.OpenSourceForU.com | OpEN SOUrCE FOr YOU | april 2015 | 51





Developers Let’s Try The Link+ Project for Linux Kernel Developers Kernel developers will be interested to learn how to use the LinK+ IDE, which has been developed by a team from C-DAC. The article is detailed and comprehensive. In this article, discover how Linux kernel programming ƒ Linux device driver auto code generation, completion and can be simplified using an IDE. Let’s take a look at navigation the IDE named LinK+ which supports Linux kernel configuration, compilation and emulation, system call ƒ Wizard for kernel configuration and compilation development and device driver development. At the end of ƒ Reduced kernel compilation time through ccache and this article, developers of Linux device drivers are sure to start loving it! distcc ƒ QEMU emulator support for Linux kernel image The LinK+ IDE is a simple IDE for Linux kernel developers. It is based on the Eclipse IDE and is emulation and debugging customised for Linux kernel programming. It reduces ƒ Linux system call development development time and executes code in an elegant ƒ Supports both Debian and RPM Linux families fashion. The LinK+ IDE includes various templates in the ƒ Supports Sparse for static analysis of Linux device drivers categories of character, block and network device driver sub-systems for device driver development. It includes LinK+ IDE installation various bus infrastructure templates and also provides Linux device driver code completion, code assistance and Prerequisites for Ubuntu Linux distributions code navigation for developers. Before installing LinK+ IDE, the following set of packages Features of the LinK+ IDE needs to be installed on your machine. You can run the command shown below: The first release of this IDE is called LinK+ Avatar and it supports the following set of features: dileep@dileepk:~$ sudo apt-get install openjdk-6-jdk libqt4- ƒ Hardware architectures: x86 and x86_64 dev libncurses5 sparse qemu qemu-system openssh-server openssh-client bridge-utils iptables dnsmasq linux-headers- `uname -r` 54 | April 2015 | OpEN SOUrCE FOr YOU | www.OpenSourceForU.com

Let’s Try Developers Prerequisites for other Linux distributions are mentioned in the user manual, which you can download from the link http://sourceforge.net/projects/linkplustest/files/ documentation/. You can now install LinK+ IDE using either one of the following methods. Method 1 Download the LinK+ IDE installer from the link https:// sourceforge.net/projects/linkplustest/files/installers/. dileep@dileepk:~$ tar -xvf LinK+\\ IDE-linux.gtk.x86_64.tar.gz Figure 1: Kernel compilation project dileep@dileepk:~$ cd LinK+\\ IDE-linux.gtk.x86_64/ dileep@dileepk:~/LinK+\\ IDE-linux.gtk.x86_64$./linkplus & to LinK to or just click on the icon of the toolbar. In my experience, how long compilation takes depends Method 2 on your host system’s hardware configuration. In order Install LinK+ plugins. Before installing them, however, you to speed things up, integrate third party tools such as should have a version of Eclipse cPP of the Helios variant distcc and ccache into this IDE. To use these features already installed on your Pc. in the LinK+ IDE, go to the preference page (Windows- >Preference) and go to Linux Kernel Development. If you Start the Eclipse IDE and add the LinK+ repository by want more information on distcc and ccache, refer to the clicking on Help->Install New Software. user manual as suggested earlier. Then enter the URL of the updated LinK+ site (https:// Single step execution sourceforge.net/projects/linkplustest/files/repository/) and proceed with further installation procedures. The LinK+ IDE also provides a one-stop solution for all configuration, compilation, installation and emulation Method 3: Installation through Eclipse Market needs. To use this feature, right-click on the respective Place projects in the Project Explorer view, then go to LinK to -> Single Step Execution. Start the Eclipse IDE and click on Help->Eclipse Marketplace. Then, go to the Search button and in the Find This will open a wizard with three pages. The first page space bar, type Linux Kernel Programming IDE. You can then has configuration options, the second has compilation options click on the Install button to download the LinK+ plugins. and the third has the option to install on host or emulate with the QEMU file system of your kernel source. Now that you have installed the LinK+ IDE, we can start building our own projects. Linux kernel emulation using QEMU The Linux kernel configuration and compilation After compiling the Linux kernel image, the QEMU emulator project can be used to emulate the working of the Linux kernel before installing on the host. For this process, there are two Let us begin with configuring and compiling the Linux options—Linux kernel emulation using QEMU with the file kernel, by selecting File-> New-> Project. system and with the initrd image. You can download the Debian or RPM based ‘qcow2 file system’ image from the click on the Linux Kernel Development (Link+) option Internet and use it for the emulation. Just right click on the and expand it to select Kernel Compilation Project before respective project under Project Explorer and go to LinK to-> clicking on the Next button. This will open the kernel Emulation -> With File System compilation wizard as shown in Figure 1, where we can enter the project’s name. Then we need to select the Linux kernel The QEMU remote system source. Three options are provided: Select Archived Source Code, Import Source Code to Workspace and Link to Existing LinK+ IDE provides communication with remote systems Kernel Source Code. Select one based on your requirement. using the Eclipse Remote System Plugin. The advantage of Depending on what Linux kernel source was selected, choose the path of the kernel source by clicking on the Browse button. Next, move to the Project Build options. The LinK+ IDE is bundled with different project build options like Configuration, Compilation and Installation. These options are presented to users through multiple ways. Just right-click on the respective project in the Project Explorer view, then go www.OpenSourceForU.com | OpEN SOUrCE FOr YOU | April 2015 | 55

Developers Let’s Try Figure 3: Toolchain list image with QEMU and then copy the system call user application to the running QEMU. To do the above, go to LinK to -> System Call. Figure 2: Add system call A Linux device driver development project using this plugin is that the remote system’s rootfs, either Linux device driver projects are created by selecting File- running through QEMU or in the local network, will be >New->Project. Then go to Linux Kernel Development mounted onto the IDE as a view. So transferring files to (Link+) and select Device Driver Project. remote systems becomes easy, and the remote system shell can be viewed as a separate console in the LinK+ IDE. The This will open a wizard that contains three pages—one complete procedure to connect with the remote systems is covering general information, one on the kernel’s features and given in the user manual. the page on driver information. You can finish the project at any point in time. Linux kernel debugging using QEMU In the general information page, we need to fill the fields Debugging the Linux kernel image is possible with the Eclipse like author’s name, license type, kernel version and, finally, cDT debugger and the QEMU emulator. Avail the debugging select the architecture and the toolchain required for it from option by right-clicking on the respective project under Project the Toolchain list as shown in Figure 3. Explorer, go to LinK to-> Emulation -> Debug with QEMU and follow the steps as mentioned in the user manual. In the Development type dropdown box, there are two options: Custom Driver Development and Typical Driver A project to create a Linux kernel system call Development. In the first option, select what you require but in the latter development type, a lot of features are The LinK+ IDE has a wizard for adding new system calls to automatically integrated. the kernel source. This can be done by right-clicking on the respective kernel project in the Project Explorer view, before click on Next for other Kernel Development Features going to LinK to -> System Call -> Add System Call. clicking or Finish for Basic module programming. If you choose on Add System Call will open a wizard as shown in Figure 2. the Custom Driver Development type, follow the procedure shown below. Enter the name of the system call, then select the existing data type and click the Add Argument button. You can also Advanced kernel module program and a project create a new data type by clicking the Create a new data type to create device drivers link. If you want to test your system call with a system call application, enable the Include User Test application. It will The Linux kernel features’ page is shown in Figure 4 and create a user space application for system call testing. Finally, contains the kernel features like: rebuild the project to make changes effective. ƒ Module PArAM ƒ Delayed Works ->Kernel Timer, Tasklet, Work Queue, System call testing with QEMU Shared Queue There are just two steps to test how the system call works ƒ Synchronization->Semaphore, Spinlock and other options when using QEMU. Run the newly added system call kernel ƒ Kernel Data Types ƒ Debugging Mechanisms -> probing, proc, sys attributes All the features are optional. So you can select any feature based on requirements. On selecting a feature, the left pane 56 | April 2015 | OpEN SOUrCE FOr YOU | www.OpenSourceForU.com

Let’s Try Developers Figure 5: Linux device driver specific features Figure 4: Linux kernel features Figure 6: Driver development wizard window options change dynamically. Driver types and Bus infrastructure from the left pane either by double-clicking on the specific type, or by dragging and click on Next for specific information on the driver and dropping on to the right pane. Once this job is done, click device, or on the Finish button to create the project with the Finish to generate the device driver code. This in turn speeds above features. up and eases the job of a device driver developer. The third (and last) page has Linux device driver specific Project build and utility options features, and is divided into two parts as shown in Figure 5. By default, Build Automatically is enabled and if you want The first half contains the types of drivers, devices and to disable this feature, select Project and uncheck Build the bus type, as well as the framework method. Automatically. To build a project, right-click on that project ƒ In the Driver Type field, select the name of the driver and then click on Build Project. from the list. The LinK+ IDE is bundled with different device driver ƒ In the Bus Type field, select the bus name from the list. utility options like insmod, rmmod, modprobe, modinfo, ƒ In the Device Type field, select the device’s name from the list. dmesg and lsmod. These options can be accessed in multiple ƒ In the Framework Method field, select the name of the ways. One way is to right click on the Project and in the Project Explorer view, select Link+ Driver Development, as framework method from the list. The second half is dynamic and depends on the user’s first selection. It contains the following: ƒ File operations: This has a list of functions. You can select zero or more functions from the list. ƒ registration view: This depends on what you selected in the first half. Basic registration tab fields are compulsory and other registration fields like IrQ, IOCTL, Port and Buffer Management are optional. Finally, click on Finish to generate the complete and specific code for the device driver. Typical driver development You have an option to choose Typical Driver Development in the General Information page. Select it and click Next. This opens a wizard as shown in Figure 6. Unlike in Custom driver development, in Typical driver development you are asked only driver specific information. Based on your requirement, choose the Framework types, www.OpenSourceForU.com | OpEN SOUrCE FOr YOU | April 2015 | 57

Developers Let’s Try Figure 7: Driver development shown in Figure 7. Or just click the LinK+ Driver Utility on Figure 8: Function pointer structure Toolbar, or just right click on the Editor. Short keys Code assistance and a quick-fix utility for LinK+ driver development To get the device driver utilities (insmod, rmmod, modprobe and dmesg) with short keys, press Shift+Alt+L and it will As we all know, development of Linux device drivers open the short keys window. Then press the first letter of the is quite cumbersome. We need to understand a lot of command, like ‘d’ for dmesg. frameworks and data structures to build them. To ease this process, the LinK+ IDE has code assistance and code Extending a project completion features. After creating the device driver project, if you want to add To use this feature, press Ctrl+Space in the function pointer features, select the project under the Project Explorer view structure to get suggestions as shown in Figure 8. You can also and click on LinK+ Driver Utility on Toolbar. Then, click on type a few letters of the function name, and press Ctrl+Space to Extend Project to select the additional features you want to use. prompt for a list of names that start with a particular letter. All features are optional. Finally, click on the Finish button. After writing the function pointer’s name, the editor Compiling for other kernels automatically gets an error message. In order to solve this, press Ctrl+1 or click on the error marker icon for code suggestion. As we know, Linux device drivers are version specific. If you We can opt for any one of the suggestions for code completion. want to compile the device driver project for other kernels, select the project in Project Explorer view and click on LinK+ Examples of Linux device driver programs Driver Utility on Toolbar. click on Compile For Other Kernel and follow the steps indicated. The LinK+ IDE is also bundled with sample programs for Linux device drivers. To view them, go to Window->Show Static analysis using Sparse View->Other and then go to LinK+ Views. Then, click on the device driver examples. You can also import the example If you want to check for static analysis, this IDE allows it program into the workspace as a project by right-clicking on the through the Sparse tool. Just click on LinK+ Driver Utility on respective example program. Toolbar and then click on Static Analysis using Sparse. It will open the LinK+ console, which shows Sparse warnings. Markers This article covers the basic features provided by the LinK+ will also appear automatically on all warnings in the editor. click Avatar release. I hope this information will help you to kickstart on the warning icon in the editor and the LinK+ IDE will provide Linux kernel programming. In the next issue, I will discuss a quick fix option for code assistance and completion. more features that include support for ARM architecture, network and block device driver development. Eclipse local terminal plugin By: Dileep K. Panjala The LinK+ IDE is also bundled with the Linux terminal The author is a senior technical officer currently working with C-DAC, plugin, which is provided by the Google ELT project plugins. Hyderabad. This IDE has been developed by Dileep K. Panjala, A. To open the Linux terminal in the Eclipse IDE, click on Raghavedra Rao, Suman M., Devesh Gupta and S.V. Srikanth. Window -> Show View -> Other -> General -> Terminal. Read more stories on TOPCOMPONENTS STORIES ELECTRONICS Components in ••••••TTGIcTnhThroohdeoempeiwallaapl1tatctho2eetoneossncesftttontIiiinnnnntidnsunpimeeaeIoGscnviwctBeteoroeTrolreysrcicb,myoctrMreonapoantnonOrrvdoriScetsllFrcseatEoiregvTsmranssiiplfaaiocnbnadleennrteitnsalamIiynnsdoduuiasnttryof INDUSTRY IS AT A www.electronicsb2b.com Log on to www.electronicsb2b.com and be in touch with the Electronics B2B Fraternity 24x7 58 | April 2015 | OpEN SOUrCE FOr YOU | www.OpenSourceForU.com

Let’s Try Developers Developing a Web-app Using the Eclipse Editor This article is the first in a series on developing a Web application called ‘Online Banking’ using the Eclipse Editor.The application will perform all the normal functions of offline banking.This task will be spread over a number of articles. In this first article, the author covers the basics of what is required to develop the Web-app, starting with Java. Java is a programming language highly portable. A Java program by the Java Virtual Machine created by James Gosling from Sun (which is standards-compliant (JVM). The JVM contains a so Microsystems in 1991. The first and follows certain rules) can called ‘hotspot-compiler’, which publicly available version of Java (Java run unmodified on all supported translates performance critical byte- 1.0) was released in 1995. The Java platforms, e.g., Windows or code instructions into native code virtual machine (JVM) is a software Linux. instructions. implementation of a computer that ƒ An object-orientated programming ƒ Automatic memory management: executes programs like a real machine. language: Except for the primitive Java manages the memory data types, all elements in Java are allocation and de-allocation for The JVM is written specifically objects. creating new objects. The program for a particular operating system, e.g., ƒ A strongly-typed programming does not have direct access to the for Linux. A special implementation is language: Java is strongly-typed; memory. The garbage collector required for Windows. the types of variables used must automatically deletes objects to be pre-defined and conversion to which no active pointer exists. Characteristics of Java other objects is relatively strict. In most cases, it must be done by the An introduction to the Java The aim of the creators of Java was to programmer. editor—Eclipse be able to write a program once and then ƒ An interpreted and compiled run it on multiple operating systems. language: Java source code is Eclipse is an integrated development transferred into the byte-code environment (IDE) for developing Java has the following properties. format, which does not depend on applications using programming ƒ Platform independence: Java the target platform. These byte- languages like Java and others such as code instructions are interpreted C/C++, Python, PERL, Ruby, etc. programs use the Java virtual machine as abstraction and do The Eclipse platform provides the not access the operating system directly. This makes Java programs www.OpenSourceForU.com | OpEN SOUrCE FOr YOU | April 2015 | 59

Developers Let’s Try Figure 1: Java virtual machine foundation for the Eclipse IDE. It is composed of plugins and is designed request communication to be extensible through the use of Servlet additional plugins. Developed using Web Web Java, the Eclipse platform can be used Browser app to develop rich client applications, integrated development environments Client response Dynamic page (IDEs) and other tools. Web Eclipse can be used as an IDE for Server any programming language for which a plugin is available. Figure 2: Communication between Servlet and the browser ƒ The Java Development Tools (JDT) 1. Load Servlet Class 5. Call the project provides a plugin that allows destroy() Eclipse to be used as a Java IDE 2. Create Servlet Instance method ƒ PyDev is a plugin that allows Eclipse 3. Call the init() method to be used as a Python IDE ƒ C/C++ Development Tools (CDT) 4. Call the service() method is a plugin that allows Eclipse to be used for developing applications Figure 3: Servlet life cycle using C/C++ ƒ The Eclipse Scala plugin allows Figure 4: Welcome page Eclipse to be used as an IDE to 60 | April 2015 | OpEN SOUrCE FOr YOU | www.OpenSourceForU.com develop Scala applications ƒ PHPeclipse is a plugin to Eclipse that provides the complete development tools for PHP Introducing Servlet Servlet technology is used to create Web applications and it uses the Java language to do so. Web applications are ‘helper applications’ that reside in the Web server and build dynamic Web pages -- like a page that randomly chooses a picture to display or even a page that displays the current time. As Servlet technology uses Java, Web applications made using Servlet are secure, scalable and robust. The advantages of using Servlet are: ƒ Low response time because each request runs in a separate thread ƒ Servlet is scalable ƒ It is robust and object oriented ƒ It is platform independent The Servlet life cycle ƒ Loading a Servlet class: A Servlet class is loaded when the first request for the Servlet is received by the Web container. ƒ Creating a Servlet instance: After the Servlet class is loaded, the Web

Figure 5: Opening account page Let’s Try Developers Figure 6: Confirmation of account opened Figure 7: Balance checking page container creates an instance of it. A Figure 8: Deposit form Servlet instance is created only once in its life cycle. ƒ Calling the init() method: init() is called by the Web container on a Servlet instance to initialise the Servlet. Signature of init() method: public void init (ServletConfig config) throws ServletException ƒ Calling the service() method: The containers call the service() method each time the request for Servlet is received. Signature of service() method: public void service(ServletRequest request,ServletResponse response) throws ServletException, IOException ƒ Calling the destroy() method: The Web container calls the destroy() method before removing the Servlet instance, giving a chance for clean- up activity. An introduction to Oracle An Oracle database is a collection of data treated as a unit. The purpose of a database is to store and retrieve related information. A database server is the key to solving the problems of information management. In general, a server reliably manages a large amount of data in a multi-user environment so that many users can concurrently access the same data. All this is accomplished while delivering high performance. A database server also prevents unauthorised access and provides efficient solutions for failure recovery. Oracle Database is the first database designed for enterprise grid computing, and is a flexible and cost-effective way to manage information and applications. Enterprise grid computing creates large pools of industry-standard, modular storage and servers. With this architecture, each new system can be rapidly provisioned from the pool of components. There is no need for peak workloads, because capacity can be www.OpenSourceForU.com | OpEN SOUrCE FOr YOU | April 2015 | 61

Developers Let’s Try easily added or reallocated from the resource pools, as needed. Figure 9: Withdrawal form Figure 10: Transferring amount form The database has logical structures Figure 11: Account closing form and physical structures. Because the physical and logical structures are separate, the physical storage of data can be managed without affecting the access to logical storage structures. An introduction to Apache Tomcat Server Apache Tomcat is an open source Web server and Servlet container developed by the Apache Software Foundation (ASF). Tomcat implements several Java EE specifications including Java Servlet, JavaServer Pages (JSP), Java EL and Web Socket. It also provides a ‘pure Java’ HTTP Web server environment for Java code to run in. The components of Apache are: 1. Catalina 2. Coyote 3. Jasper 4. Cluster Figures 4 to 11 give the UI snaps for the ‘Online Banking’ Web application that we will be building in subsequent articles. The forthcoming articles in this series will deal with Oracle Database, Apache Tomcat Server and Servlet, which have been used in developing this Web application. By: Vikas Awasthy The author currently works as an applications developer-J2EE in a multinational corporation. This is his first article, which is dedicated to his late mother, Krishna Sharma, and to his family. • Exclusive: ELCINA’s rst green eld EMC project soon to get land possession ELECTRONICS • India is emerging as an attractive destination for international companies to invest • Electronics manufacturing industry in Pune needs a boost INDUSTRY IS AT A • In 5 years, India may rank 2nd in manufacturing competitiveness, worldwide • Highlights of state electronics policies • National Policy on Electronics will Boost R & D in Electronic Manufacturing • Insecure market threatens solar module makers Log on to www.electronicsb2b.com and be in touch with the Electronics B2B Fraternity 24x7 62 | April 2015 | OpEN SOUrCE FOr YOU | www.OpenSourceForU.com

Let’s Try Developers Selenium: A Popular Software Testing Tool You Can Rely On For the software enthusiast, this article begins with an overview on software testing.The various types of testing and the many software testing tools are enumerated, and then the author goes into detailed discussion on the free and open source automation testing tool, Selenium. Software testing is a process of evaluating a system ƒ Validation: This process confirms that the software meets or its components to find out whether the specified the business requirements. requirements are met. It can also be referred to as a system to identify any gaps, errors or missing requirements. ƒ Defect: This detects any differences between the expected It comprises verification and validation of the software and actual results. product. This process starts from the beginning of the Software testing can be done in various ways and is software development lifecycle (SDL) till it is delivered to the customer. broadly divided into two types: Manual testing: This type of testing involves software The purpose of software testing is to deliver a higher quality of product. If the product produces an error at a later developers running tests manually. stage, then it becomes costly to remove it. Software testing There are several stages at which manual testing can be has the potential to save money and time by identifying problems early and delivering a defect-free product. done. These are: It has three main objectives: ƒ Unit testing ƒ Verification: This process confirms that the software meets ƒ Integration testing ƒ Software testing its technical specifications. • Functional testing • Non-functional testing ƒ System testing www.OpenSourceForU.com | OPEN SOURCE FOR YOU | APRil 2015 | 63

Developers Let’s Try Software Selenium Testing IDE Selenium Selenium Selenium Grid Suite RC Manual Automation Web Testing Testing Driver Figure 1: Types of software testing Figure 2: Selenium’s components ƒ User acceptance testing ƒ Testing Anywhere ƒ Release or deployment testing ƒ WinRunner ƒ LoadRunner Automation testing: This type of testing is done using ƒ Visual Studio Test Professional automation tools. It reduces the overall effort and time ƒ WATIR required in regression testing and speeds up the overall testing process. Various automation tools can be used for this. Some Introducing Selenium of these tools are: ƒ HP Quick Test Professional With the dynamic growth in the IT industry, there has ƒ Selenium been an increase in testing costs. So, organisations have ƒ IBM Rational Functional Tester started choosing open source automation tools rather ƒ SilkTest than their commercial variants. Automation tools, as ƒ TestComplete their name suggests, provide features for automating the Elements Description Base URL This is the textbox where the URL for the application under test can be specified. All open commands Command will be relative to the Base URL unless a full path is inserted in the open command. selectbox Speed slider is used to vary the speed while playing the test from Fast to Slow Target textbox Find button Play entire test suite button is used to run all the available test cases in the IDE Value textbox Test table Play current test case button is used to run a single test which is selected in the IDE. Log Reference Pause/Resume button is used to pause/resume the test case which is currently running UI-Element Rollup Step through the test once it has paused. This is the record button. This will be engaged when the test is recording It has a list of all the commands that are needed to create a test. It is a drop down box which specifies all the available command in selenium IDE It enables to specify the element which is to be tested It can be used to find any particular element on the application under test It is used to specify the value for the target element if required. It is usually used when the requirement is to enter a value in the input box on the web page which is being tested It will keep track of all commands, targets, and values When test case is run information message and error message are displayed in this tab It will display the details about the current command It is for advanced users It allows to execute group of commands in one step 64 | APRil 2015 | OPEN SOURCE FOR YOU | www.OpenSourceForU.com

Let’s Try Developers Figure 3: Selenium download page Selenium allows testers and developers to develop test scripts to drive the browser. It prevents future regression of testing of software code; hence, it is popular. It can work on any browser that and Web applications. supports JavaScript, since it has been built using JavaScript. Various types of automation testing Recorded test cases can be exported to various tools are available programming languages such as Java, C#, Python, Ruby, for the different PHP and Perl. tests required like regression, Components of Selenium performance or functional testing. Selenium is not just a single tool but a suite of products. It One of the most has four components—Selenium IDE, Selenium Grid, Web Figure 4: Selenium IDE Menu-Items commonly used Driver and Selenium RC. Selenium RC and Web Driver have been merged to form a framework known as Selenium 2. automation tools is Selenium. It is one of the best options to test Web applications, and can be used for Selenium IDE: Selenium IDE is an integrated automating the testing of both the GUI as well as the development environment for Selenium tests. It was features. It can also be used as a unit testing tool for developed by Shinya Kasatani. It allows you to use Selenium JavaScript. It provides a record/playback facility to Core without having to copy it onto the server. authorise the tests without knowing the test scripting language (Selenium IDE). It is implemented as a Firefox Selenium Core is a JavaScript module that allows extension, which allows replaying, recording and editing Selenium to drive the browser. It can interact with Document test cases in Firefox. Object Model (DOM) using JavaScript calls. Scripts are recorded in Selenese, a special scripting language for Selenium. It provides commands for performing actions in Web browsers and for retrieving data from multiple pages. Selenium RC: This is a server written in Java, which accepts commands for the browser via HTTP. It makes it possible to write the tests for Web applications in any programming language. When using Selenium, a core user has to install the whole application under test alongwith the Web server on the local computer. So a server has been created by an engineer named Paul Hammant, which acts as a proxy to trick the browser into considering the Selenium core and Web application that is being tested as coming from the same domain. This is known as Selenium RC (remote control) or Selenium 1. Selenium Web Driver: This is the successor to Selenium RC. It is the first cross-platform framework for testing that controls the browser from the OS level. It was created by Simon Stewart in 2006. It accepts commands, Commonly used Selenium commands Command Description Open Opens a page for the specified URL Click Clicks the elements (target) on the page clickAndWait Performs the click operation and waits for a new page to load verifyTitle Verifies the target title and continues to execute even if it fails assertTitle Verifies the target title and stops execution if it fails verifyTextPresent Verifies whether the specified text is present on the page verifyElementPresent Verifies whether the specified element is present by using its HTML tag verifyText Verifies whether the specified text and its corresponding HTML tag is present on the page waitForPageToLoad Pauses execution until an expected new page gets loaded waitForElementPresent Pauses execution until an expected UI element, as defined by its HTML tag, is present on the page www.OpenSourceForU.com | OPEN SOURCE FOR YOU | APRil 2015 | 65

Developers Let’s Try sends them to a browser and retrieves the result. It does not require any special server to execute tests. Selenium Grid can be used with Web Driver to execute tests on remote systems. At present it is fully implemented and supported in Ruby, Python, C# and Java. Selenium Grid: This is a server that allows tests to use Web browsers running on remote systems. In this, Figure 5: Selenium IDE Figure 6: Sample test case execution on Selenium IDE one server acts as the hub. The tests contact the Installation of Selenium hub to obtain access to browsers. The hub consists of lists of servers that provide access to browsers (i.e., Web Driver 1. Open a Mozilla Firefox browser. nodes). It allows the running of tests in parallel on multiple 2. Type the URL http://seleniumhq.org/download/ in the machines, and the management of different versions and configurations of browsers, centrally. This helps to spread browser and download the latest version as specified in the load of testing across several machines by running the the screenshot. tests across different platforms or operating systems. 3. When the download link is clicked, Firefox will enable a pop-up that asks if you want to allow Mozilla Firefox A comparison between various automation testing tools Parameters Selenium QTP Watir GEB Licence cost Open source software Open source Open source HP licensed software Scripting language software software Ruby Groovy Operating system Java, C#, Python, VB Script Windows, Linux, support Ruby, PHP, Perl, DOS Browser support JavaScript Windows 8/XP/ Windows, Linux, Solaris Firefox, IE, Opera, Vista Safari, Chrome Object recognition Windows, Linux, IE, Firefox, Chrome Firefox, IE, Opera, Using GEB IDE Solaris Safari, Chrome Script execution Using Object Spy Open Twebst (Web Low speed Firefox, IE, Opera, recorder) Non-browser based Safari, Chrome High Low No app support Device support Selenium IDE, iOS Firebug, Firepath Ease of support Limited support Low from open source Script creation time community No Yes No Time required is Supports iOS and iOS, Android, iOS and Android more Android Blackberry, Windows Limited support from User and Has dedicated HP open source community professional support community support Time required is more is available Time required is less Time required is much more 66 | APRil 2015 | OPEN SOURCE FOR YOU | www.OpenSourceForU.com

to install Selenium IDE or not. Click the Allow Let’s Try Developers button. 4. Firefox will automatically install the Selenium IDE 3. Click on the Search option, write a new command and software. After completing the installation, it will show specify the ID of the target in the target value. This ID one pop-up that states the Selenium IDE installation can be obtained with the help of Firebug, by clicking on a has been completed. Now restart the browser to use particular target, which is the Search option in this case. Selenium IDE. Click the Restart Now button. 5. Firefox will restart automatically. Now click on the 4. After specifying every command, the screen will look like Tools menu list displayed on top to see the Selenium what’s shown is Figure 6. IDE option as shown in Figure 4. This is how a test case can be created using the 6. Click on the Selenium IDE option. This will launch the Selenium IDE software window. Selenium IDE. This is the screen for Selenium IDE, where tests can be recorded, replayed and edited. References Creating the first test script using Selenium [1] http://automationinqtp.blogspot.in/2013/01/qtp-vs-selenium.html [2] http://blog.testing-whiz.com/2013/06/comparing-qtp- We will be creating a test for clicking on the Search option to open the Search page in the Clean-clouds.com application. selenium-and-testingwhiz.html 1. Open the Selenium IDE tool and enter the link for the [3] http://kedar.nitty-witty.com/blog/selenium-vs-qtp-differences- application that is to be tested as shown in Figure 6. usage-quick-reference 2. To open any link for the application that is to be tested, [4] http://docs.seleniumhq.org/docs/01_introducing_selenium.jsp [5] http://www.xoriant.com/blog/software-testing-and-qa/ use the Open command and specify the link in the target value. selenium-open-source-test-automation-tool-an-overview.html [6] http://www.aspiresys.com/WhitePapers/QTPvsSelenium.pdf By Priyanka Agashe The author is a software engineer and loves to explore new technologies. Her professional spheres of interests include oracle apps, testing, electronics, and robotics. Please share your feedback/ thoughts/ views via email at [email protected] www.OpenSourceForU.com | OPEN SOURCE FOR YOU | APRil 2015 | 67

Developers Insight Face-off with Sizeof() developmentlanguage programmilanngguage In C programming, the unary operator sizeof() returns the size of its operand in bytes. The sizeof() operator is discussed in detail in this article, along with illustrative examples of code. Sizeof() is used extensively in the C programming language. It is a compile-time unary operator, which can case, the operand should be enclosed within parenthesis. The be used to compute the size (in bytes) of any data type sizeof operator is used when the operand is a type-name as shown in Table 1. of its operands. The operand may be an actual type-specifier Illustration: The sample demo code is shown below (such as char or ints) or any valid expression. The sizeof() (Code 1), and the output of the code when I run it in my operator returns the total memory allocated for a particular system is shown in Figure 1. object in terms of bytes. The resultant type of the sizeof() operator is size_t. Sizeof() can be applied both for primitive data types (such as char, ints, floats, etc) including pointers Code 1 1 #include <stdio.h> and also for the compound data types (such as structures, 2 #include <stddef.h> unions, etc). 3 Usage 4 int main() 5{ The sizeof() operator can be used in two different cases 6 printf(“Sizeof(char) : %lu\\n”, (long unsigned ) depending upon the operand types. Let me elaborate this with sizeof(char)); syntax, examples and sample codes. 7 printf(“Sizeof(int) : %lu\\n”, (long unsigned ) Case 1: When the operand is a type-name sizeof(int)); 8 printf(“Sizeof(float) : %lu\\n”, (long unsigned ) When sizeof() is used with ‘type-name’ as the operand (such as char, int, float, double, etc), it returns the amount of sizeof(float)); memory that will be used by an object of that type. In this 9 printf(“Sizeof(double) : %lu\\n”, (long unsigned ) sizeof(double)); 68 | April 2015 | OpEN SOUrCE FOr YOU | www.OpenSourceForU.com

Table 1: Syntax with some commonly used examples Insight Developers Syntax Examples Figure 1: Output of the demo program shown in Code 1 Sizeof (type-name) Figure 2: Output of the demo program shown in Code 2 1. sizeof (char) 2. sizeof (int) 3. sizeof (float) 4. sizeof (double) 5. sizeof (12.5) 6. sizeof (‘A’) etc... Table 2: Syntax with some commonly used examples Syntax Examples Sizeof (expression) 1. sizeof (i++) OR 2. sizeof (a+b) etc... Sizeof expression 10 return 0; 11 } Note 1: The return value of the sizeof() operator is Figure 3: Output of the demo program shown in Code 3 implementation-defined, and its type (an unsigned integer type) is size_t, defined in <stddef.h>. 13 } Note 2: C99 has included %zu as a type specifier From the above demo code, it is very clear that when for size_t. But for older compilers, %z will fail. Hence, use the sizeof() operator is applied to an expression, it yields a %lu or %llu along with a typecasting to achieve portability result that is the same as if it had been applied to the type- of the code across various platforms. name of the resultant of the expression. Since, at compile time the compiler analyses the expression to determine its Case 2: When the operand is an expression type, but it will never evaluate the expression which takes place at runtime. When sizeof() is used with expression as an operand, the operand can be enclosed with or without parenthesis. In the example shown in Code 2, ‘a’ is of int type and‘d’ The syntax of how the sizeof() operator is used preceding is of double type. When type conversion is applied, as usual, the expression is shown in Table 2 along with some the lower rank data type is promoted to a higher rank data examples. type and the resultant data type is nothing but a double in our case; hence, sizeof( a + d ) yields sizeof(double) which Illustration: The sample demo code is shown in the Code is 8 bytes as shown in Figure 2. In general, if the operand 2 snippet, and the output of the code when I run it in my contains the operators that perform type conversions, the system is shown in Figure 2. compiler considers these conversions in determining the type of the expression. Code 2 Behaviour 1 #include <stdio.h> 2 #include <stddef.h> The sizeof() operator behaves differently in comparison with 3 other operators. In this article, let me point out the uniqueness 4 int main() of this operator by taking two real-time programming 5{ examples. The first is about compile-time behaviour and the 6 int a = 10; second one is about runtime behaviour. 7 8 double d = 12.34; Case 1: Compile-time behaviour 9 10 printf(“Sizeof( a + d ): %lu\\n”, (long unsigned) To start with, let us consider the simple code as shown in the sizeof(a + d)); Code 3 snippet. 11 12 return 0; www.OpenSourceForU.com | OpEN SOUrCE FOr YOU | April 2015 | 69

Developers Insight From Figure 4, we can see that sizeof() is completely evaluated at compile time (the exception is gcc, which supports zero-sized structures as a GNU extension, which is evaluated at the runtime). And the whole sizeof(i++) is replaced by the constant value 4, which is highlighted in the box. Hence, there are no assembly instructions for i++ at all, which is supposed to be evaluated at the runtime. Case 2: Runtime behaviour As mentioned earlier, sizeof() is the only operator in C, which is evaluated at the compile time. But, there is an exception for this in C99 standards, for variable length arrays. To start with, let us consider the following code (Code 4): Figure 4: Assembly code generated by the compiler for Code 3 Code 4 Code 3 1 #include <stdio.h> 2 #include <stddef.h> 1 #include <stdio.h> 3 2 #include <stddef.h> 4 int main() 3 5{ 4 int main() 6 unsigned int size; 5{ 7 size_t array_size; 6 int i = 10; 8 7 9 printf(“Enter the size:”); 8 size_t size = sizeof(i++); 10 scanf(“%u”, &size); 9 11 10 printf(“Size of i : %lu\\n”, (long unsigned ) 12 //Declaring the variable length array 13 int array[size]; size); 14 11 15 //Finding the size of array 12 printf(“value of i : %d\\n”, i); 16 array_size = sizeof(array); 13 17 14 return 0; 18 printf(“Size of array : %lu\\n”, (long unsigned ) 15 } array_size); 19 20 return 0; 21 } Can you guess what the output of the above mentioned program Let us see the output, when the above code is compiled will be? At first glance, anybody would say it is 4 (assuming the and run (shown in Figure 5). sizeof(int) is 4 bytes) and 11. But, when I run the program in my system, it shows 4 and 10 (refer Figure 3 for output). From the above output it is very clear that the sizeof() operator is evaluated at runtime. We can observe the Why are we getting the value of variable ‘i’ as 10 instead equivalent assembly code generated by the compiler as shown of 11? Here is the reason. in Figure 6. The sizeof operator is the only one in C, which is Also, note the difference between the assembly code in evaluated at compile time, where sizeof(i++) in our example Figures 4 and 6. is replaced by the value 4 during compile time itself. We can validate this by referring to Figure 4, which contains the The need for sizeof() assembly code equivalent to the sizeof(i++) in C. Case 1: Auto determination of the number of Note: To obtain the assembly code as shown in Figure elements in an array 4, follow the steps shown below: + gcc -g filename.c (in our case, the file name is sizeof_run.c) To compute the number of elements of the array + objdump -S output_file (in our case, the output file is a.out) automatically, depending on the data-type of the element, the sizeof() operator comes in handy. 70 | April 2015 | OpEN SOUrCE FOr YOU | www.OpenSourceForU.com

Insight Developers Figure 5: Output of the sizeof_run.c For an explanation, let us consider the code snippet given below: 1 #include <stdio.h> Figure 6: Assembly code generated by the compiler, for variable length array 2 #include <stddef.h> int, multiplied by 5, ensuring sufficient space for all five 3 ints is allocated. 4 int main() 5{ Case 3: To determine the sizeof compound 6 int array[] = {10, 20, 30, 40, 50}; data types 7 8 size_t i; Sometimes, it is very difficult to predict the sizes of compound 9 data types such as structures, due to structure padding, and to 10 for(i = 0; i < sizeof(array) / sizeof(array[0]); predict the size of unions. Sizeof() is of great use here. i++) Cases when sizeof() will not work 11 { 12 //some code The sizeof operator will not work when applied to the 13 } following cases: 14 } ƒ A bit field ƒ A function type In the example shown above, at line number 10, by using ƒ An incomplete type (such as void) the sizeof() operator the number of elements is automatically ƒ Zero-sized array (except in GCC, which supports zero- computed. sized structures as a GNU extension). The sizes of primitive data types in C are implementation defined. For example, the sizeof(long) on 32-bit architecture sizeof() and incomplete data types may vary from that on 64-bit architecture. So, when we decide statically the sizeof(long) as 4 bytes wide on 32-bit An incomplete type in C is one that describes an identifier, architecture, and when the same code is ported to 64-bit but lacks the information needed to determine the size of architecture, the results may go wrong. So, in order to avoid the identifier. the portability issue, it is a best practice to use sizeof() to compute the sizeof variables or arrays, depending on the exact Examples of incompletely defined types are: size of a particular data type. 1. An array type whose dimensions have not yet been specified 2. A structure type whose members have not yet been specified Case 2: To allocate a block of memory dynamically of a particular data type Illustration: An array whose dimensions are not specified In case of dynamic memory allocation of an array, sizeof() plays an important role. For example, if we want to File1.c File2.c allocate a block of memory that is big enough to hold int array[10]; extern int array; ‘5’ integers in an array, sizeof comes in handy and is a great help, since we do not know the exact sizeof(int) to dynamically allocate the memory using malloc function for a particular architecture. int *iptr = malloc( 5* sizeof(int)); In the above example, we are mallocing the block of memory, which is equal to the number of bytes of type www.OpenSourceForU.com | OpEN SOUrCE FOr YOU | April 2015 | 71

Developers Insight In the above example, for the code in file1.c, sizeof() can In the above example, sizeof() will work even if be applied to find the size of the array, as it is completely the braces are not present across operands, whereas in defined in file1.c. But, in file2.c, the sizeof() operator will functions, braces are a must. So, here are three reasons not work since the dimensions of the array are missing. why sizeof is not a function: Without this information, the compiler has no knowledge of how many elements are in the array and cannot calculate the 1. It can be applied for any type of operand. sizeof of the array. 2. It can also be used, when type is an operand. 3. No brackets needed across operands How sizeof() is different from a function call You can implement your own SIZEOF() macro, which should work like a sizeof() operator. Let us consider the following code to understand how sizeof() According to the C99 standards, the sizeof() operator is different from a function call: yields the size (in integer bytes) of its operand, which may be an expression or the parenthesised name of a type. If 1 #include <stdio.h> the type of the operand is a variable length array type, the 2 #include <stddef.h> operand is evaluated at runtime; otherwise, the operand is 3 not evaluated and the result is an integer constant, during 4 int main() the compile time itself. 5{ 6 int x = 5; By: Satyanarayana Sampangi 7 8 printf(“%lu:%lu:%lu\\n”, (long unsigned )sizeof(int), The author is a member of the embedded software team at Emertxe Information Technology (P) Ltd (http://www.emertxe. (long unsigned )sizeof x, (long unsigned )sizeof 5); com). His areas of interest are embedded C programming 9 combined with data structures and microcontrollers. He can be 10 return 0; reached at [email protected] 11 } 72 | April 2015 | OpEN SOUrCE FOr YOU | www.OpenSourceForU.com

How To Developers Creating an Awesome Web Experience with Drupal Drupal offers developers quick fix solutions for an instant website. However, it is not child’s play. It powers many critical websites including those of the POTUS (President of the United States), Warner Music, NBC, etc. This in-depth article takes the reader through the steps to create and operate a Drupal website. Drupal is an open source content management platform that powers millions of websites and applications. It is built, used and supported by an active and diverse community of people around the world (website: www.drupal.org). Drupal is a PHP based Web content management system (CMS), which is distributed under the GNU-GPL license, making it free and open source software that is used to power millions of sites on the World Wide Web. Drupal was originally created by Dries Buytaert as a message board project, and was released as an open source project in 2001. It is now continuously fuelled by contributions from a huge community of around 39,000 users. It is used by organisations large and small, across various verticals like healthcare, retail, government, consumer, media and entertainment, life sciences and many more. Some sample sites One really famous Drupal site is whitehouse.gov. The Warner www.OpenSourceForU.com | OpEN SOUrCE FOr YOU | April 2015 | 73

Developers How To authorize.php CHANGELOG.txt COpyriGHt.txt cron.php includes drupal.local:8083/install.php Select an installation profile index.php INSTALL.mysql.txt INSTALL.pgsql.txt install.php iNstALL.sqlite.txt standard install with commonly used features pre-configured. iNstALL.txt LiCENsE.txt MAiNtAiNErs.txt misc modules Choose profile Choose language Minimal Verity requirements Start with only a few modules enabled. Set up database Install profile Save and continue Configure site profiles rEAdME.txt robots.txt scripts sites Finished themes update.php upGrAdE.txt web.config xmlrpc.php Figure 3: Drupal installation page Figure 1: Drupal directory structure http://drupal.local:8083/install.php?profile=standard&locale=en Database configuration Figure 2: Virtual host config Choose profile Database type* Music Group uses Drupal to power its artists’ websites, while Choose language fashion brand Lush uses Drupal for its e-retail store lushco.uk. Verify requirements MySql, MariaDB, or equivalent The Weather Channel at NBC is also powered by Drupal… Set up database PostgreSQL and the list is long. Install profile SQLite Configure site The type of database your Drupal data will be stored in. To check out case studies, you can visit https://www. Finished drupal.org/case-studies and http://www.drupalshowcase. Database name* com/ The name of the database your Drupal data will be stored in. It must exist on your server Start building your own website before Drupal can be installed. So let’s learn how to install and get started with a Drupal Database username* site, and add some basic content to it. A basic knowledge about using computers and how to install software on them Database password* is required. Experience in working on a LAMP, WAMP or MAMP stack is preferable. ADVANCeD oPTIoNS Save and continue Prerequisites Figure 4: Database configuration You will need a *AMP stack, which implies a computer, laptop or server with a stable operating system like For a quick start, you can choose one of the preconfigured Windows, Mac OS, UNIX or any Linux based OS packages like WAMPServer, MAMP, XAMPP, or a LAMP- like Ubuntu, Fedora, Red Hat, etc. Note that PHP is a server package on a Linux based OS or Acquia’s Dev Desktop. requirement since Drupal has been written in it. PHP 5.4 or higher is recommended. Usually, the database used Download Drupal is MySQL. However, other databases like PostgreSQL, SQLite, MS SQL server or Oracle can be chosen. We need Go to https://www.drupal.org/project/drupal to download a Web server, which could be Apache, Nginx, or Microsoft Drupal, which will be in the form of a .tar.gz or a .zip file. IIS. Apache is usually chosen. Extract it and place it into your Web server docroot. Create a virtual host that points to your docroot and assign a dev domain to the virtual host. Do not forget to update your IP tables to point this dev domain to your local host. Ensure that the .htaccess file and .gitignore files also get copied with the Drupal files. Go into your MySQL administration and create a database for the Drupal site. Creating settings.php and the files directory Within the sites/default/ directory, as seen in Figure 1, there will be a sample settings file default.settings.php which is what we will use to create our settings.php. Copy default. 74 | April 2015 | OpEN SOUrCE FOr YOU | www.OpenSourceForU.com

How To Developers Figure 5: Front page Figure 7: ‘About me’ page that has been created Figure 6: Content type list settings.php to the same location as settings.php and make Figure 8: Home page sure that the file permissions are such that the Apache Web server can write into this file for now. Make sure that you Database configuration have both the files in the directory, default.settings.php and the newly created settings.php. Remember the database you had created earlier? Now, fill in the details like the database’s name, user name and Within this sites/default directory, create another directory password as shown in Figure 4. In case your database is on named files. Make sure this directory can be written to by the a non-standard port or on a different machine, update the Web server too. Any file uploaded to the Drupal site or any database server details accordingly. JavaScript or CSS aggregated files will be stored in here. If all the previous steps went fine, you should now see a Running the installation script screen that displays all the Drupal modules and components being installed, the database being set up and necessary Now get on to your browser and visit this Base URL or settings being saved. the domain set on your virtual host as shown Figure 2, to begin installing Drupal. You should be seeing the page Site information shown in Figure 3. Now this is where you add your site’s name, slogan and Select the Standard installation profile and click on create an administrative user number 1. Don’t forget to set Save & Continue. The next page should show you a list the country, time zone and to make sure you enable Check for of languages available to install Drupal in. Since we updates automatically. have not added any support for additional languages, it will, for the time being, just show ‘English’. Click on Congratulations! Your site is up. Let’s go visit it. Save & Continue to proceed. Front page It next checks for the prerequisites for the Web server, PHP version, PHP settings, permission to write into the Figure 5 shows the front or home page of your site. It settings.php file and the files directory. In case there is any shows your site’s name at the top, with the user menu on issue with any of these aspects, an appropriate message will the right side, a navigation menu, some blocks on the left be displayed. Use corrective measures as suggested by the hand side and an admin menu on top. message and then retry the same step. www.OpenSourceForU.com | OpEN SOUrCE FOr YOU | April 2015 | 75

Developers How To Figure 9: Managing the fields Figure 10: User profile Figure 11: List of registered users Figure 12: List of menus Admin dashboard a menu link. This will prompt you to add the Menu link title, indicating which menu you want it on. Add details as The administration section will be visible to you as you shown in Figure 8 and save them. are currently logged into the site as an administrator. Notice a black coloured menu on top that presents a list Now, when you save the form, the page content gets saved of links for all administrative tasks. Click on the one and is displayed to you. You can also see a menu link on top that that says Dashboard. reads ‘About me’ and the links to this page that you have created. Let’s create the ‘About Me’ page Congratulations! You have created your first ever Drupal page. Now let us quickly create an ‘About Me’ page. From the top admin menu, click on Add Content. This gives you a list of Let us now create a few articles in the same way. To choices like those shown in Figure 6. create a new article, go to the same Add content link and choose the content type as Article. In the form, you will Click on Basic Page. This will now open up a form for notice that we now have an extra field to upload an image you to add content to. Add the page title as ‘About Me’ and and one to categorise your article using tags. Go ahead in the Body field, add any HTML that you desire to be part and add a few articles with images along with this tag of your content -- something like what’s shown below: information. <h2>Read all about me.</h2> Now take a look at the front page; it shows a list of all the <p>Hi! I am an enthusiastic Drupal developer. I like to:</p> articles that you added just now. <ul> A few Drupal basics <li>Build sites</li> <li>Explore new technologies</li> We will now discuss the internal structure of Drupal and a </ul> few key concepts. Now, let's add a menu link, from where this page Content and content types will be accessible. Scroll down the form and check the checkbox in the Menu settings section that says Provide Everything in Drupal revolves around content, which could be a static Web page, an article, a blog post, product 76 | April 2015 | OpEN SOUrCE FOr YOU | www.OpenSourceForU.com

How To Developers Figure 13: Add module Webform Figure 14: Webform builder information, a slide in a slide show, etc. Each of these Menu and path system make up a content type. We can alter the data structure of each content type so that it has all the relevant information In Drupal, every path lands at a unique page that runs a set captured in the best way. of functions to create the content and structure for that page. This could be individual content, a list of contents, a list of To create your own content type, from the admin menu users, the Home page with aggregated content from the rest on top, click on Structure and from the list shown, click on of the site, a form and more. In order to make the URLs user Content types. This will now show you a list of the content friendly, URL aliases are used and mapped to these paths types that are present in the system. generated by the Drupal system. You can add a new content type, edit the fields that are a Next, you can create a list of the paths to build a menu part of it, and even decide which fields are to be shown and and display it as the main menu or a user menu, secondary which hidden (Figure 9). side navigation menu and more. Go to Structure from the admin menu, and click on Menus to view the list of menus Taxonomy and a list of links added to each menu (Figure 12). Another important aspect of arranging content on a CMS is Modules categorising features. Using Drupal’s inbuilt taxonomy system, one can easily create vocabularies and associate them with the The module system of Drupal is at the heart of its various contents on the system. These could be a pre-entered extensibility. The plain Drupal installation has some core list of terms or a free tagging system. Content can then be features and a hook based system that helps other added easily categorised, sorted and filtered using the terms associated modules to extend its features. These additional features with it. You can see them as a list of taxonomies and terms. To are packaged into modules that can be added and enabled view them, click on Structure from the admin menu and then as per requirements. Some examples could be: a Commerce on Taxonomy. This will show a list of the taxonomies in the module to enable commerce capabilities, a ‘Five Star’ system and then you can click to add or view more terms. rating, CKEditor, Devel for debugging and more. There are close to 30,000 modules that have been published on To add it to the contents, just make a Taxonomy Term field www.drupal.org, which can be added to your Drupal site to as a part of the Content type, to capture which category is enhance its features. associated with the content added. Go on and try one. Let’s try the Webform module at Users https://www.drupal.org/project/webform. No digital system is complete without its users. Drupal’s Go to the URL and download the .tar.gz or .zip file. Unzip inbuilt user module provides a very good solution for users to it and extract the contents into the sites/all/modules/contrib be registered on the system and role based permissions to be folder within the docroot of your Drupal site. Now, from the assigned to them. You can extend the information about a user top admin menu, click on the Modules page link. This should by adding more fields into the user’s profile information. From show you a list of modules with this new module that can be the top user menu, click on the My account link to view your selected to be enabled and installed. user profile (Figure 10). As seen in Figure 13, the system checks if there are To check the list of users registered on the system, click any dependencies for installing this module. You can see on the People link from the admin menu (Figure 11). that it requires two other modules, ctools and views, to be installed too. So quickly download them from https:// To add more roles or assign special permissions to each www.drupal.org/project/ctools and https://www.drupal.org/ role, click on the Permissions tab in the People page that you project/views, respectively and extract them into the sites/ opened right now. www.OpenSourceForU.com | OpEN SOUrCE FOr YOU | April 2015 | 77

Developers How To own theme and install it. The Drupal community has contributed over 2000 themes for you to start with. Some Figure 15: Home page of them are base themes that put in a framework for you all/modules/contrib directory. Now revisit the Modules to build a branded theme and some give you a complete page and see that the Webform module can be installed and coloured theme. You can find them at https://www.drupal. automatically enables the prerequisite modules too. org/project/project_theme. The aim of this module is to provide you with a way Let’s try one at https://www.drupal.org/project/ to add more forms to your site using an easy form builder corporateclean. Download the .tar.gz or .zip file, extract facility. It would have created a content type ‘Webform’ it and place it in the sites/all/themes directory. Now for you on the Content types listing page. You can now navigate to the Appearance page from the admin menu on go ahead and create a form in the same way as creating a top. It shows you a list of themes available and the one page. Go to Add content and see that Webform is listed as you just added. a type there. Click on it, and you will be asked for a title for the form and any menu, path or permissions that you Enable it and set it as the default in the Corporate would like to associate with the form. Once you add this Clean theme, and then navigate to the front page and see information and save it, you will be led to the form builder the magic (Figure 15). page, where you can add text fields, select boxes, text area, date and other types of form components. Next, you can A good start to building your site on Drupal program what actions should be taken after submitting the form, like sending a confirmation message, email to the You are probably well into getting your site built on administrator, etc (Figure 14). Drupal. For a quick try out, you can start building and hosting your site on Acquia’s cloud servers, which provide Themes developers with a free version to kickstart their Drupal development. Go to http://www.acquia.com/free to register Drupal’s UI architecture beautifully separates out for your free dev cloud. The Drupal community site hosts logic, data and presentation. The features that govern an awesome documentation section that provides details the data architecture and logic are separated into the about working in the Drupal ecosystem. Do feel free to modules and the presentation layer is governed by the register on www.drupal.org and visit its forum section to Theme layer. Drupal comes with a default theme, Bartik, interact with the Drupal community, post your questions which is enabled when you install it. Now, to change and participate in local events. Drupal has been adopted the appearance, install another theme, or create your by major systems integrators and IT companies to create great digital experiences for their customers. The Drupal community in India regularly organises events like the Drupal Camps in Delhi and Mumbai held earlier this year, ‘Global training days’ that happen every quarter, and many monthly meet-us for training, code sprints or contribution drives. Come, join for the technology and stay on for the community. References [1] Documentation: https://www.drupal.org/documentation [2] Case studies: https://www.drupal.org/case-studies, http:// www.drupalshowcase.com/ [3] Drupal modules: https://www.drupal.org/project/modules [4] Drupal themes: https://www.drupal.org/project/themes [5] Hosting your site on Acquia Cloud: https://www.acquia. com/free, https://docs.acquia.com/cloud/free [6] Using Acquia Dev Desktop: https://docs.acquia.com/dev- desktop2 [7] Acquia library: https://www.acquia.com/resources By: Pavithra Raman The author is a solutions architect with Acquia Inc and specialises in the architecture of Drupal based solutions. To know more about her, visit in.linkedin.com/in/ramanpavithra/. Connect on Twitter @pavithra_raman. 78 | April 2015 | OpEN SOUrCE FOr YOU | www.OpenSourceForU.com

How To Admin FSlint: A ‘Laundromat’ for File Systems Traditionally, lint refers to small loose pieces of fibre that stick to fabric. In computer terminology, lint initially implied programs that flagged suspicious and non-portable constructs, which were likely to be bugs in C programming. Likewise FSLint helps to find and eliminate various kinds of lint on a file system. FSlint is a collection of tools to find and clean updated packages various forms of lint on a file system. Excess or unnecessary files are referred to as file system lint. [narendra]$ sudo apt-get install fslint # Install FSlint FSlint has an intuitive GTK+ GUI as well as command line interface. But for the sake of simplicity we are going package to discuss only the GUI interface. The most common forms of lint are duplicate files, improper names, empty [narendra]$ whereis fslint # Verify the directories, broken symbolic links, etc. FSlint provides various utilities to clean file system lint and reclaim disk installation space. This column walks you through each of the major tools that FSlint provides. FSlint: /usr/share/FSlint /usr/share/man/man1/Fslint.1.gz Installation That’s it. We are done with the installation. To install FSlint on other GNU/Linux distributions, go The FSlint package is part of the official repositories of through the official website of the FSLint at http://www. Ubuntu and Fedora. It can be installed using the apt and yum pixelbeat.org/FSlint/ which describes installation steps. package managers, respectively. To install FSlint on Ubuntu, execute the commands shown below in a terminal: Demystifying the GUI interface [narendra]$ sudo apt-get update # Request Now that the installation is done, let us get our hands dirty with FSlint. For this demonstration, I am using the Ubuntu 14.04.1 MATE edition but FSlint’s usage and experience should be the same on other distributions. To launch FSlint from the GTK+ GUI, traverse to Applications->System Tools->FSlint. Command line junkies www.OpenSourceForU.com | OpEN SOUrCE FOr YOU | April 2015 | 79

Admin How To Figure 1: FSlint main window Figure 2: FSlint duplicates Figure 3: FSlint installed packages Figure 4: FSlint bad names can launch it by executing the fslint-gui command from the types and directories. By default, it excludes a few directory terminal. After launching it, you will be shown the main paths and file types, but the user can easily manipulate these window of FSlint (Figure 1). settings with the help of the Add and Remove buttons. FSlint has a few common interface items. Not every tool There is also an Extra find parameters text box, which is uses every interface option, so it is important to understand capable of performing a more refined search. This text box is how these buttons and interfaces work. This will make it used to pass parameters to the GNU/Linux’s find command. easier for you to understand their importance at various times. For instance, to search for the files that only belong to the user, Let’s take a look at detailed examples of each of these tools. Jerry, the user can add the following text: -user ‘id -u Jerry’. Search path tab: After launching FSlint, you will find Select button: By using this button, the user can select the Search path tab. This provides Add and Remove buttons, specific files from the results window. It also provides you the which allow the user to add or remove one or more directory option to select multiple entries using wild cards. This button paths to be searched. By default, it searches from the directory provides other options as well, but these are self-explanatory. that it has been launched from. If it is launched from the GUI, Additionally, the user can bring up the same menu by right- then it starts searching from the user’s HOME directory. clicking within the results window. On the right hand side of the main windows there is a Save button: Besides the Select button, there is a Save recurse? check box, which determines the depth of the search button. After selecting files, the user can save the search while searching duplicate files. results on the disk. Please note that this will save only the absolute path of the files and not the files themselves. This Advanced search parameters tab: FSlint allows advanced option is useful if you are planning to do more advanced tasks and powerful filtration with the aid of regular expressions like providing this result to some automated script. and wild cards. This tab allows the user to exclude certain file 80 | April 2015 | OpEN SOUrCE FOr YOU | www.OpenSourceForU.com

How To Admin Figure 5: FSlint name clashes Figure 6: FSlint temp files Figure 7: FSlint bad IDs Figure 8: FSlint empty directories Delete button: As its name suggests, this button is used Duplicate files to delete selected items. I would advise you to perform this operation very carefully, because it deletes files permanently One of the very common forms of file system lint is duplicate from the system. Before deleting, a confirmation window will files. We often copy music files, documents, images and appear each time unless the Ask me this in the future? check videos at multiple locations on the file system while taking box is unchecked. backups. As duplicates grow, they eat up available disk space. So let us figure out how to find and remove duplicate files Merge button: This operation merges all the files within with just a few clicks of the mouse. a group into one physical file using links. To do this, either a hard link or a symbolic link will be used depending on the The Duplicates tab on the left hand side of the screen is the location of the file. Let us suppose you have two duplicate default tab selected at FSlint startup. Just choose the appropriate files, namely, file1.txt and file2.txt; then the merge operation directory using the Add button and then click on the Find button. will delete one of the files and create a link (using the ln FSlint will show the summary of the duplicate files in the results command) to the other file. If one or more duplicate files are window. Figure 2 shows the result of the operation. present on the same file system, then the merge option will create a hard link; otherwise, it will create a symbolic link. All duplicate files are grouped together under a gray bar giving information such as the number of files in the group Find button: The Find button instructs FSlint to perform and the number of bytes wasted in duplicate files. The total the selected actions. After completion, it displays the results number of bytes wasted in all the files and groups is shown in the window. below the Find button. Now that we are familiar with FSlint’s GUI interface, let FSlint uses the following algorithm to find duplicate files: us get some insight into it. 1) First, it scans the file system and filters out the files of different sizes. www.OpenSourceForU.com | OpEN SOUrCE FOr YOU | April 2015 | 81

Admin How To Figure 9: FSlint non-stripped binaries Figure10: FSlint redundant white spaces 2) Then, files of the same size are checked to ensure that or when a program wishes to report and save a problem. these are not hard links. Removing these temporary files can free up valuable space, 3) Subsequently, it calculates the checksum of the file using and FSlint can find these files so that they can be purged. md5sum. It is also possible to direct the program to find only files 4) Finally, to guard against md5sum collisions, FSlint of a specified minimum ‘age’—like those modified in the last ‘N' number of days, for instance. When the minimum age is rechecks signatures of any remaining files using the set to 0, FSlint reports all temporary files. FSlint provides a sha1sum checksum. check box core file mode? which enables a more thorough search for the core files. Figure 6 shows the results of the Installed packages operation. This tool lists the installed packages according to their sizes. Bad symlinks It supports the Debian package manager (dpkg), the Red Hat package manager (RPM) and the Packman package manager. Symbolic links are widely used in GNU/Linux. But broken When a package is selected, a description of it is shown symbolic links cause great frustration for the user. FSlint below the results window in a gray box. Figure 3 shows the looks for symbolic links that have some kind of problem results of the operation. and immediately reports them. It specifically looks for the following problems. Bad names 1) Dangling: In this type, a broken symbolic link points to a Another common form of file system lint is bad names. file that no longer exists in the file system. Even though they do not eat up disk space, they may be 2) Suspect: In this type, symbolic links point to a file below difficult to use or move. The Bad names tool searches all the files and inspects their naming conventions. You can set their directory structure. the sensitivity level by using the slider bar at the top of the 3) Relative: In this type, a symbolic link points to a path selection window. Level 1 implies the least strict while Level 4 implies a strict POSIX check. Besides the slider, there is a that is determined by the current location. check box, which allows you to select UTF-8 checking. The 4) Absolute: In this type, a symbolic link points to a path image in Figure 4 shows the results of the operation. that is determined by the full path. Name clashes Note: It seems that there is a bug in the GUI tool for Another form of file system lint involves files that have identical this operation. Because, though the command line tool (/ or similar names. This usually does not cause any significant usr/share/fslint/fslint/findbl) reports broken links correctly, problems for the user other than slight inconvenience. But the GUI is unable to show correct results. finding files with name clashes can be of great help when dealing with multiple versions of files (Figure 5). Bad IDs Temp files GNU/Linux assigns a positive integer number as ‘user id' to each user. When the user moves files between multiple Temporary files eat up a lot of hard disk space. These are computers, a file will occasionally end up with a user ID created while editing files, while running some programs, that the current system cannot resolve to that user. The most common forms of bad IDs are generated when we extract 82 | April 2015 | OpEN SOUrCE FOr YOU | www.OpenSourceForU.com

How To Admin compressed files created by another user on another system. Now, remove the trailing white space using FSlint’s clean But FSlint finds and reports such problems. Figure 7 shows option. Our modified file will now look like what’s shown below: the results of the operation. [narendra]$ cat -e hello.c In this example, the FSlint utility reports a file with a #include <stdio.h>$ bad ID because there is no user or group with ID 1001. $ int main(void)$ Empty directories {$ Empty directories clutter a file system, and make it printf(“Hello, World!!!\\n”);$ difficult for the average user to find information quickly $ and efficiently. FSlint can find and clean these annoying empty directories (Figure-8 shows the result of the return 0;$ operation). }$ Non-stripped binaries In the above examples, the dollar ($) symbol implies the end of the line. Non-stripped binaries contain extra debugging symbols and tend to be larger in size. These extra debugging FSlint is an extremely useful tool that can be used regularly. symbols are needed while debugging binary files with These simple yet powerful utilities make GNU/Linux debuggers like GDB. But often, this extra debugging more interesting. You can always learn more about FSlint by information is not needed, and a considerable amount of digging into it yourself. drive space can be freed by stripping the binaries. FSlint finds such non-stripped binaries (Figure-9 shows the By: Narendra Kangralkar result of the operation). The author is a FOSS enthusiast and loves exploring In this example, the hello binary was purposefully anything related to open source. He can be contacted at compiled to contain debugging information. [email protected]. With this tool, when the Search $PATH check box is enabled, FSlint searches the system path for non-stripped binaries. This tool provides a Clean button, which removes extra debugging symbols from the binary. Redundant white spaces FSlint can check text files for a number of white space issues like unnecessary tabs and spaces. This feature is very useful for programmers and writers who need to be aware of the white space within their files. The average user may never need to use this feature, but knowing about this tool could be beneficial. This tool also provides the check box for Bad indenting for indent width which checks text files to ensure that the indenting width is uniform. FSlint can also check for a white space at the end of a line. The Clean button will attempt to fix the white space issues in the selected files (Figure-10 shows the result of the operation). To try this out, let us create a file with a trailing white space, which will look like what follows: [narendra]$ cat -e hello.c $ #include <stdio.h> $ $ int main(void) $ {$ printf(“Hello, World !!!\\n”); $ return 0; $ }$ www.OpenSourceForU.com | OpEN SOUrCE FOr YOU | April 2015 | 83

Admin Insight Make Your Own IVR with Asterisk Interactive voice response (IVR) is ubiquitous and now pervades the business and commerce milieu. Using Asterisk, IVR can be easily set up and coded. This fifth article in the series on Asterisk takes a look at how IVR is coded. Asterisk provides a generic switching platform to run [from-pstn] a variety of applications. IVR is commonly used exten => _.,1, Answer(); today in most large corporate PBXes. Typically, exten => _.,2, Playback(welcome); these are automated voice menus – what you hear when you exten => _.,3, Dial(SIP/${EXTEN},60); call a bank or insurance company. The recorded voice will exten => _.,4, Voicemail(${EXTEN},u); prompt you to input the intended transaction as a choice exten => _.,5, Hangup(); in the form of digits (DTMF or dual tone multi-frequency tones). The transactions requested for are executed based on [from-pstn] indicates the context in which the call is the user inputs. In this session, we will look into IVR coding processed, which is the incoming calls from the PSTN and then the hardware configuration required. (public switched telephone network – normal PRI or FXO trunk). exten => is a standard keyword to indicate a Let’s start with a welcome menu, which is a very common pattern matching routine. ‘_.’indicates that any extension feature nowadays in any Asterisk installation. The code is is matched and the following actions need to be carried written in the dial plan, which is the central routing control out. The second digit ‘1’ after the comma indicates a based on pattern matching. The dial plan is generally found in sequence number. The lines that follow increase the /etc/asterisk/extensions.conf. sequence number in ascending order. Answer() indicates the call has to be answered so that the voice channels are Example 1 open in both directions. This is required, so that the users can hear the greetings message and provide their inputs. ƒ Play the welcome message to the caller Playback (welcome) instructs the system to search for a ƒ Ring the extension for 60 seconds file welcome.gsm or welcome.wav in the default voice ƒ If unavailable, pass the call to voicemail directory, and play that file for the user to hear. The file ƒ Hang up Here’s the code snippet for this example: 84 | April 2015 | OpEN SOUrCE FOr YOU | www.OpenSourceForU.com

Insight Admin The welcome message is played in the background, if the user dials the extension 1234. The function Playback() is blocked and the user will be able to provide the inputs only after the message is completed. In case of Background, the welcome message and ivr-options are played one after the other. The users can input their choice at any point of time. The function TIMEOUT is set for two cases: 1) if the user presses one digit, and 2) if the time exceeds 10 seconds. Also, note that the second parameter ‘n’ takes away the burden of sequencing, like in Example 1, and makes the sequence dynamically next to the previous statement. The ivr-options plays the message, “Please press 1 for sales, 2 for support, 3 for operator...” Figure 1: A very simple IVR exten => 1,1,Dial(SIP/2000&SIP/2001); exten => 1,n,Playback(sendback-to-ivr); 1 exten => 1,n,Goto(1234,1); exten => 2,1,Dial(SIP/2002&SIP/2003); exten => 2,n,Playback(sendback-to-ivr); exten => 2,n,Goto(1234,1); If the user presses 1, the extensions 2001 and 2002 will ring in parallel. If no one picks up, a voice file stating that, “Currently, no agents are available,” is played and the call is sent back to the main IVR loop. Similarly, if the user presses 2, both the extensions 2003 and 2004 in the sales department will ring. Figure 2: IVR with user input (all details are not shown) exten => 0,1,Dial(SIP/2111,50); exten => 0,n,Voicemail(2111,u); could contain a voice recording of the message, “Welcome exten => 0,n,Hangup(); to OSFY.” EXTEN saves the value of the extension dialled by the caller. Dial the EXTEN using the SIP protocol and If the user presses 0 to talk to the operator, the extension ring for 60 seconds. The user may pick up the call and talk 2111 will ring for 50 seconds. If nobody responds, then the to the caller. If the user is unavailable, call the service’s call is redirected to the voice mail. voicemail with the same EXTEN extension number. After returning from the voicemail, hang up. exten => i,1,NOOP(wrong input received); exten => i,n,Playback(invalid); Example 2 exten => i,n,Goto(1234,1); The next example demonstrates how calls can be routed If the user presses anything other than 1, 2 or 0, the based on the user’s inputs: message file with, “You have chosen an invalid input,” is played and the call is sent back to the main loop. [from-pstn] exten => 1234,1,Answer(); exten => t,1,NOOP(no input received); exten => 1234,n,Set(TIMEOUT(digit)=1); exten => t,n,Playback(pls-select-option); exten => 1234,n,Set(TIMEOUT(response)=10); exten => t,n,Goto(1234,1); exten => 1234,n,Background(welcome); exten => 1234,n,Background(ivr-options); If the user comes out of the loop without any input due exten => 1234,n,WaitExten(); to the timeout setting of 10 seconds, then another message, “You have not selected any input,” is played and sent back to the main loop. The dial plan also provides the choice to query and store to an external database. In the next example, we will have www.OpenSourceForU.com | OpEN SOUrCE FOr YOU | April 2015 | 85

Admin Insight students inputting their roll number. After verification, the users’ name and password, and the total attendance is queried. attendance will be reconfirmed and stored in the database. The total attendance is then announced. Similarly, the program can execute any database operation including [from-pstn] updation, deletion, etc. exten => 1234,1,Answer(); exten => 1234,n,Set(DID=${EXTEN}); As a good programmer, you will have already noticed exten => 1234,n,Playback(welcome); that the program gets more and more unmanageable as the exten => 1234,n,Playback(pls-enter-enroll); size grows. Also, the usage of Goto makes the program exten => 1234,n,Read(enroll,beep,10); unreadable, as the size grows. There are multiple other ways exten => 1234,n,SayDigits(${enroll}); to write IVR scripts like AGI-script (Asterisk Gateway exten => 1234,n,Set(TIMEOUT(digit)=1); Interface-script) or PHP. Let’s explore the latter. exten => 1234,n,Set(TIMEOUT(response)=10); exten => 1234,n,Background(pls-confirm); To write in PHP, download phpagi2.2 from http://phpagi. exten => 1234,n,WaitExten() sourceforge.net/. Unzip and keep the file inside /var/lib/ asterisk/agi-bin. The welcome message and the request for inputting the roll number is played. After that, the roll number is read up Now, in the dial plan, we can initiate the PHP script by to 10 digits. Then the input digits are read out loud and a including the following line: confirmation is requested. [from-pstn] exten => 1,1,NOOP(Caller confirmed entry); exten => _.,1,AGI(welcome.php); exten => 1,n,Goto(autoprocess,submenu,1); The following is the printout of welcome.php: exten => 2,1,NOOP(Caller wants to re-enter); !/usr/local/bin/php -q exten => 2,n,Goto(1234,3); <?php set_time_limit(0); require(‘phpagi.php’); $agi = new AGI(); If the user confirms that the entry is correct, then the $agi->answer(); control proceeds to the auto-process sub-menu. Else, the $agi->verbose(“Call Answered inside AGI script\\n”,3); control proceeds to re-enter the inputs. $agi->stream_file(‘welcome’); $agi->hangup(); [autoprocess] ?> exten => submenu,1,Set(TIMEOUT(digit)=1); exten => submenu,n,Set(TIMEOUT(response)=1); The PHP program also uses the AGI library. The exten => submenu,n,Background(Pls-select-frm-menu); script creates a new AGI object. It answers the incoming exten => submenu,n,WaitExten(); call, renders a verbose three-level message and plays the welcome.gsm file. After playing the message, the call is A request is made to the user to input the service hung up. All the flexibility that PHP offers can be used in needed. If the user wants to check the attendance so far, ‘1’ this mode. This includes database access, accessing third can be pressed. party APIs, etc. exten => 1,1,NOOP(Caller wants to check attendance); The power of Asterisk as a platform for creating strong exten => 1,n,MYSQL(Connect connid localhost Admin_DbUser applications has been proven once again by doing so with P@55_DbPass school_db); simple programming. exten => 1,n,MYSQL(Query resultid ${connid} SELECT count(date) from attendance where enroll_no=${enroll} and Hardware present=”Y”); exten => 1,n,MYSQL(Fetch fetchid ${resultid} total); The hardware required is quite simple. You can use almost exten => 1,n,MYSQL(Clear ${resultid}); any Linux hardware with a PCI slot for a PRI card or FXO exten => 1,n,MYSQL(Disconnect ${connid}) card. Asterisk needs to be installed on Linux hardware, and exten => 1,n,Playback(total-attendance-is); then the PCI card must be configured. Connect the PRI line exten => 1,n,SayDigits(${total}); from the service provider to the card, and you are ready to exten => 1,n,goto(submenu,1); experience the power of Asterisk IVR! When ‘1’ is pressed, a NOOP statement is executed. A By: Devasia Kurian connection is made to the database with the correct user The author is the founder and CEO of *astTECS, an Asterisk software based company providing IP PBX, call centre diallers, etc. He can be contacted at [email protected]. 86 | April 2015 | OpEN SOUrCE FOr YOU | www.OpenSourceForU.com

Let’s Try Admin An Overview of OpenShift OpenShift provides all the resources needed to develop, host and scale Web applications in the public or private cloud. Available on GitHub, it has built-in support for various Web application frameworks. This article provides a tutorial on installing OpenShift and applications like WordPress, Jenkins and Tomcat through it. Cloud computing is an innovative paradigm that delivers services on demand with a utility .NET) and the platforms/tools provided by PaaS providers based billing model. NIST (National Institute of like Web servers, application servers and databases. Since PaaS providers manage the underlying infrastructure Standards and Technology, under the US Department resources such as operating systems, virtual servers, of Commerce) has compartmentalised cloud computing networks, Web servers, application servers, databases, into three service models (SaaS, PaaS and IaaS) and backup, disaster recovery, etc, users can focus on the most four deployment models—public clouds, private clouds, significant aspect of their business, which is the application hybrid clouds and community clouds. Cloud computing itself, rather than worrying about managing resources, is reshaping the computing and Internet landscape. With platforms and versions. breakthroughs made in appropriate service and business PaaS includes not only the deployment environment models, it will certainly expand its role as the backbone but also repositories such as the build environment, the for IT services. Cloud computing provides elastic and testing environment, performance management, mail unlimited resources, which can be efficiently utilised services, log services, database services, big data services, during periods of peak loads and normal loads, with a pay search services, enterprise messaging services, application per use pricing model. performance management for modern application As already stated, the cloud model covers Software architectures, code inspection services and so on. OpenShift as a Service (SaaS), Platform as a Service (PaaS) and is a PaaS from Red Hat. OpenShift Origin is an open source Infrastructure as a Service (IaaS). In PaaS, the user can version available on Git. deploy applications on the cloud infrastructure using Red Hat OpenShift is a PaaS with Apache License supported programming languages (Java, PHP, Ruby and 2.0. OpenShift Enterprise is a private cloud version. www.OpenSourceForU.com | OpEN SOUrCE FOr YOU | April 2015 | 87

Admin Let’s Try Figure 1: Supported technologies also allows deployment of WAR files. The benefits of OpenShift are: ƒ Easy and fast self-service for application deployment ƒ Easy application scaling ƒ Runs on any hardware, virtual machine, cloud or even on laptops that support Red Hat ƒ Enterprise Linux ƒ Git integration with automatic deployment triggered by a Git push ƒ Gear idling allows OpenShift to support a high density of applications ƒ Support for various languages, Web frameworks, databases and application stacks How to install OpenShift Origin or OpenShift Enterprise To install OpenShift Origin, copy the sh <(curl -s https:// install.openshift.com/) command and run it from a bash shell. To install OpenShift Enterprise, copy the sh <(curl -s https:// install.openshift.com/ose) command and run it from a bash shell. Table 1: Parameters to execute commands Figure 2: Select the type of application Short Full parameter Explanation Figure 3: WordPress configuration on OpenShift-I parameter OpenShift supports Web-application frameworks such as Rack for Ruby, WSGI for Python and PSGI for Perl. -u --username Red Hat login username It also supports MySQL, PostgreSQL and MongoDB. It has built-in support for Java, Python, PHP, Perl, Node.js, USERNAME Ruby and extensible functionality to add languages. For Java, it covers end-to-end support for JBoss AS7, JBoss -p --password Red Hat login EAP6, Java EE6, CDI/Weld, Tomcat 6 and 7 (JBoss EWS 1.0 and 2.0), Spring, Liferay, Scala/Play!, Cloud9 IDE, PASSWORD password Appcelerator Titanium, Git, Glassfish as DIY, Jetty as DIY, Eclipse, JBoss Tools, Jenkins, SSH access, Maven 3 and --use-existing-puppet Ant. OpenShift offers a Linux platform with lightweight containers called gears that can run applications with open -a --advanced-mode It enables access to source languages and frameworks, using common services the database server such as databases, as shown in Figure 1. and message server for customisation OpenShift uses Git to deploy application source code. It -c --config-file Provides a path to an FILEPATH alternate configuration file -w --workflow Represents installer WORKFLOW_ID workflow for unattended deployment -l --list-workflows Lists the workflow IDs available for use with unattended deployment -e --enterprise-mode Shows OpenShift Enter- prise options -s --subscription-type Software source for TYPE installation packages -d --debug Enables debugging of messages OpenShift Online OpenShift Online is a public cloud application development and hosting platform from Red Hat. It automates the 88 | April 2015 | OpEN SOUrCE FOr YOU | www.OpenSourceForU.com

Let’s Try Admin Figure 4: WordPress configuration on OpenShift-II Figure 6: WordPress dashboard provisioning, deprovisioning, management and scaling of applications in an efficient manner. It supports Figure 7: WordPress site programming languages such as Java, Ruby, PHP, Node. js, Python and Perl, and a set of developer tools to WordPress on OpenShift increase developer productivity and accelerate application deployment and delivery. It supports command line client Let’s start with the WordPress application. Click on tools and a Web management console to launch and WordPress 4. Provide a domain under which your manage applications easily. applications will be grouped. The application will start with an exact copy of the code and configuration provided To sign up for OpenShift Online, visit https://www. in this Git repository https://github.com/openshift/ openshift.com/app/account/new. Check your inbox for an wordpress-example.git. email confirming your account. You must click the link in the email to complete the registration process. Accept the Gears are the application containers running your code. legal terms after verifying your account. You will get a For most applications, the small gear size provides plenty of welcome screen at https://openshift.redhat.com/app/console/ resources. applications. Click on Create your first application now. From multiple options, choose the type of application. Applications are composed of cartridges, each one of which exposes a service or capability to your code. All applications must have a Web cartridge. Note the credentials and other important information such as connection URL. Select the language for WordPress installation. Give your username, password, site title, email and other information required. Click on Install Wordpress. Log in to the admin area at https://mywordpress-msclouds.rhcloud.com/wp-login.php. Figure 6 gives the dashboard for the WordPress site we have created on the OpenShift Online. Visit the site (Figure 7). Figure 5: WordPress configuration for user Figure 8: Jenkins login screen www.OpenSourceForU.com | OpEN SOUrCE FOr YOU | April 2015 | 89

Admin Let’s Try Table 2: Comparison of OpenShift, Heroku and CloudFoundry OpenShift Heroku CloudFoundry PaaS Type PaaS, Web development Subsidiary, PaaS cloudfoundry.org Website openshift.com heroku.com Apache License 2.0 License Apache License 2.0 Proprietary Ruby, Go Written in Ruby - VMware Developers Red Hat Salesforce.com Pivotal Software Released Development Released Released Production status Production Horizontal, vertical Horizontal, vertical Status Production Private PaaS Public PaaS Go, Groovy, Java, Node, Ruby, Scala Scaling supported Horizontal, vertical, auto Clojure, Groovy, Java, Node, PHP, Python, Ruby, Scala Grails, Play, Rails, Sinatra, Spring scaling Django, Flask, Grails, Play, Rails - Deployment style Public PaaS Postgresql Supported Java, Node, Perl, PHP, runtimes Python, Ruby Supported Django, Flask, Drupal, frameworks Rails, Switchyard, Vert.x Supported Jenkins, Mongodb, services Mysql, OpenShift Met- rics, Pgrouting, Postgis, Postgresql Figure 9: Jenkins dashboard Figure 10: OpenShift Online dashboard Jenkins on OpenShift creating these three applications, verify the OpenShift Online dashboard. Jenkins is an open source continuous integration server that is a vital part of the DevOps culture. The Jenkins app References is provided by OpenShift Online. Select Jenkins from the application types available. Give the public URL for your [1] https://install.openshift.com/ Jenkins server. [2] http://en.wikipedia.org/wiki/OpenShift [3] http://www.infoworld.com/article/2608610/cloud- Click on Create application, and then click on Visit app in the browser. computing/cloud-computing-paas-shoot-out-cloud- foundry-vs-openshift.html Access Jenkins in the Web browser. Log in with the [4] The NIST Definition of Cloud Computing, Version 15 credentials provided in the OpenShift dashboard. Figure 9 [5] https://www.openshift.com/ shows the Jenkins dashboard. [6] http://www.paasify.it/ Tomcat on OpenShift By: Mitesh Soni TBheya:utAhonr iisl aKteuchmnicaalrleaPdu. Hgealolvieas to write about new Tomcat is an open source Web server developed by the Apache Software Foundation. Select Tomcat as the type of technologies. Blog: http://clean-clouds.com application from the OpenShift Online dashboard. View Tomcat related information and its status on the OpenShift Online dashboard. Visit and verify the Tomcat server in the browser. OpenShift dashboard OpenShift Online supports three free applications. After 90 | April 2015 | OpEN SOUrCE FOr YOU | www.OpenSourceForU.com

Overview For U & Me TSemnfoUAranSedevrreoortinyddpAAYphyopsoUrne An Android phone can be greatly enhanced by installing some good apps. For a newbie, the selection of apps becomes a herculean task as the choice is so vast. This article offers some guidelines for selecting apps, while reviewing the top 10 Android apps for regular use. Google Play is one of the key reasons why Android has been a grand success in the smartphone market. This store hosts more than 1.3 million applications or apps of every kind, but how does a first time Android user select an app from such a vast range? Each app is unique in nature and serves its purpose, but the real catch is how well suited it is for you and your device. This article showcases some of the best apps in Open source that can be suitable for your daily needs. ƒ Device compatibility ƒ Resource consumption (such as memory, CPU, data, etc) ƒ Updates ƒ Data protection ƒ Performance ratings All the open source apps mentioned here are available at Google Play as well as F-Droid. Mozilla Firefox Mozilla Firefox has been the best open source browser for years. The mobile version of Mozilla Firefox comes with a sleek interface, which enables the user to switch through various options such as recent tabs, history, top sites, bookmarks, etc. Although there are many features and add-ons available for Firefox, I’d like to mention just two of the most outstanding. www.OpenSourceForU.com | OpEN SOUrCE FOr YOU | April 2015 | 91

For U & Me Overview The Reading List add-on enables you to save Web pages automatically scans all the files in your device so you’re for offline reading. set to play your media files. The Save as PDF add-on enables you to convert the Web You can easily switch between the audio and video pages to the PDF without much hassle. players by using the side bar. The app also remembers the position at which the video file last stopped and resumes Telegram playing from that point onwards. Telegram was originally launched in 2013, but it soon VLC Player has emerged from the beta stage and has became a popular instant messenger (IM) for Android. At released its first stable version 1.0.0. present, there are more than 35 million users of Telegram worldwide. Tinfoil for Facebook Telegram is based on the cloud platform and is aimed at It is pretty well known that Facebook tracks users speed and security. via cookies, but most of us are still compelled to this social networking platform because many of our While there are plenty of other IM clients for Android, friends and colleagues use it and we cannot sever all what makes Telegram really stand out from the rest of the communications with the outside world. But if you are apps out there, are the following: concerned about your privacy, Tinfoil for Facebook ƒ It is open source protects you by using a wrapper. ƒ Secret chats ƒ Self-destructing messages This app uses the mobile view protected by a wrapper, ƒ Group with a maximum capacity of 200 members can be which prevents the mobile site from accessing online activity. The app provides various options such as allowing created you to check and open links inside the app instead of an ƒ Support for almost every file format external browser, blocking all the images. K-9 Mail Tinfoil for Facebook doesn’t consume much battery power and is low on data consumption. Most of the email clients that come by default in Android devices are sufficient for personal use, but if you’re looking The ‘Duck Duck Go’ search widget for an option to address your business needs and you receive a lot of mail, then it is worth taking a look at K-9. As you are aware, Google searches are not secure and your search history is made available to some private It can support multiple accounts and each can be corporations for profit. So if you want complete privacy configured by you based on your needs. K-9 Mail can on your searches, then ‘Duck Duck Go’ is the best connect to Web servers using all popular protocols such as choice for you. POP3, IMAP and WebDAV. Duck Duck Go enables you to search the Web Another important feature is that you can encrypt and anonymously. Below the search field, there’s a stream of decrypt mail using Open PGP and APG methods. interesting content that is collected from various sources such as Reddit, Quora, BBC, Ars Technica, etc. You also GNU Cash get to choose the sources as they are provided in the app under various categories. GNU Cash helps you to track your personal finances. It acts as a companion to the GNU Cash desktop client. Since the sole purpose of the Duck Duck Go app is So, you can import your accounts and transactions from to provide anonymity for your searches, you can increase your desktop client to your mobile app. But you cannot your anonymity by integrating the app with Orbot. synchronise the desktop client with the mobile client. The search results can be modified by changing the Some of the features of GNU Cash are: ‘Region Setting’ to a country of your choice, so that you ƒ Creates multiple accounts and transactions may get the search results with respect to that country. ƒ Double-entry accounting with support for multiple splits ƒ Nested account hierarchy Orbot ƒ Exports the transactions in OFX (Open Financial Orbot is the TOR anonymity client for Android, which Exchange) and QIF (Quick Interchange Format) formats protects you from network surveillance. Orbot works both ƒ Saves your transactions in Google Drive, Sky Drive, in rooted and non-rooted devices. Dropbox, etc If your device is not rooted and you do not have super user access, then you can use other apps that work with VLC Player Orbot to secure your privacy. Merely installing Orbot doesn’t guarantee privacy, though. VLC Player is the open source media player for Android, which is capable of playing audio and video files. The app 92 | April 2015 | OpEN SOUrCE FOr YOU | www.OpenSourceForU.com

Overview For U & Me Some of the other apps that work with Orbot are: are stored in the memory card for offline use. ƒ Chat Secure OSMAND~ provides turn-by-turn voice guidance, ƒ Orweb ƒ Duck Duck Go optional lane guidance, street name display and estimated ƒ Mozilla Firefox time of arrival. When you are done with configuration, you are now ready Note Cipher to run the app. There is an icon of an onion on the notification area to indicate that Orbot is running. Note Cipher is a simple note-taking app that employs the industry standard 256-bit AES encryption. You can check if Orbot is properly configured by using the ‘Check browser’option. If your device is successfully After installing the app, you will be asked for your configured, a Web page will show that the browser is password, which once set cannot be changed. configured to use TOR. Once the app is unlocked, it will show the unlocked icon OSMAND~ on the notification, but it will be automatically locked if the app is idle for a few minutes. It will never store data in an OSMAND~ is the acronym for OSM Automated Navigation unencrypted state. Directions, which is an Android app for offline map and navigation purposes. OSMAND~ relies on OSM (Open You can share your notes with others just by clicking the Street Map—a huge collection of offline maps that was ‘Share’ icon on the interface. contributed by users around the globe) for data. By: Magimai Prakash To begin, you need to download the maps according to iTsBhdeyea:eupAtlhyoninr ithelaresKsctueodmmipnlaeLtiernduPxa,uBhe.gEs.apinelincadosmmpuotsetrosfchieisncleeis. uArse he your preference. These maps often get updated so you can have more precise details about your location. All these maps time exploring open source. Customer Feedback Form Open Source For You None OSFY? You can mail us at [email protected] You can send this form to ‘The Editor’, OSFY, D-87/1, Okhla Industrial Area, Phase-1, New Delhi-20. Phone No. 011-26810601/02/03, Fax: 011-26817563 www.OpenSourceForU.com | OpEN SOUrCE FOr YOU | April 2015 | 93

For U & Me Insight Android Lollipop: What’s in it for Enterprises? Enterprise mobility offers a wealth lot of opportunities for OEMs, solutions providers, UX designers, and developers. On the face of it, this may appear as easy as mobile applications grabbing business data from enterprise servers, but the reality is completely different. Read on to learn more. L et’s start this discussion by defining what mobility. Various enterprise mobility management (EMM) enterprise mobility actually is. In my opinion, it solutions are available in the market, which are capable is the trend that denotes the shift in how today’s of addressing an organisation’s data security and device employees think about working from out of the office. management needs. It’s about their current expectations regarding accessing enterprise business flows from their mobile devices in a Android’s Lollipop OS is quite different from its seamless manner. predecessors in terms of enterprise capabilities. One of the core requirements for supporting BYOD is the From the perspective of an enterprise’s CIO (Chief identification of enterprise applications and personal Information Officer) or CISO (Chief Information Security applications on the users’ devices. So far, established Officer), enterprise mobility is an immensely investment EMM providers have been addressing this challenge hungry trend, because it requires mobile access to in customised ways. Hence, the capabilities they offer enterprise data and sometimes business-critical enterprise vary from one product to another. However Lollipop is data over non-trusted networks—all from an employee’s coming out with a new set of APIs called ‘Android for mobile device. Work’, built over Samsung’s Knox security framework. Currently, all popular OEMs are working with Google to The ‘bring your own device’ (BYOD) practice at work provide support for ‘Android for Work’ on their devices. is now inevitable for any enterprise interested in enterprise 94 | april 2015 | OpEN SOUrCE FOr YOU | www.OpenSourceForU.com

Let’s take a closer look at what this means for Insight For U & Me enterprises and IT workers. Figure 1: Comparative view Lollipop aims to provide a physical separation between a user’s personal data and enterprise data, using the Knox Figure 2: A typical EMM solution framework. There will be a separate launcher app for enterprise apps, and all enterprise applications will be Figure 3: An EMM solution in the era of Android Lollipop marked by the ‘Android for Work’ icon. Support for IT policies and restrictions This separation will empower IT administrators to control enterprise apps and their corresponding data EMM providers will be able to use a new set of APIs without affecting the user’s personal applications and powered by Knox to enforce a wide set of policies ranging data. All leading EMM providers are claiming support from system settings to application-specific settings. of Lollipop by leveraging the native capabilities offered by Google. Knox APIs for secure enterprise apps Figure 1 gives a comparative view of the ‘pre-Lollipop’ EMM providers will be able to use new backend and ‘Lollipop’ eras. APIs powered by Knox APIs. This will empower IT administrators to take care of remotely deployed devices Changes at the application layer and the Android OS and securely manage the applications installed on them. layer are expected to bring enterprise-class security in a default manner in Android Lollipop-powered devices. All Android Lollipop is the largest and most ambitious EMM providers will then be able to leverage this default release from Google, especially from an enterprise support in their upcoming releases. mobility perspective. Last but not least, all the changes disscussed above will enable Google to address OEM A typical EMM solution consists of the following: fragmentation issues to a certain extent. ƒ A web console ƒ An on-device EMM agent References ƒ An EMM library to be used with enterprise applications [1] http://android-developers.blogspot.in/2014/07/knox- for policy compliance contribution-to-android.html In the pre-Lollipop scenario, an on-device EMM agent and the EMM library were specific to particular EMM [2] https://www.samsungknox.com/en/androidworkwithknox providers. Hence, the enterprise acceptability of an Android device was driven by the capabilities of the selected third- By Aditya Saxena party EMM solution. But now, in the Lollipop era, the equivalent of The author is director of the mobile practice for Syntel’s an on-device agent will be provided by Google, and Enterprise Solutions Group, which develops and delivers ‘Android for Work’ APIs will replace the EMM library. business mobility and BYOD enablement solutions to leading Hence, going forward, it can be assumed that, by global enterprises. default, Lollipop-powered devices will be enterprise ready. However, third party EMM solutions will still be required to perform administrative activities like enterprise policies management, their deployment on selected sets of devices, etc, in a remote manner. Figure 3 shows an overview of a typical EMM solution in the Lollipop era. Device and data security We have already discussed the strong separation between personal and enterprise data and applications in Lollipop. Apart from this, Lollipop includes a device protection feature called the Kill Switch. If this anti-theft protection is enabled on the device and the ‘Lock password’ feature is available, then the device’s ‘Factory reset’ option will ask the user for their registered Google ID credentials. Without providing valid credentials, a thief will not be able to implement a factory reset on a stolen device, and the device will remain unusable. www.OpenSourceForU.com | OpEN SOUrCE FOr YOU | april 2015 | 95

For U & Me Overview MwaintahgeCYoaurmMaprkaetiinggnACctivhitiaesin Open source has extended its reach to all spheres of human endeavour, and business is no exception. CampaignChain is a very handy tool for organising online marketing activities. With a little bit of imagination, this tool can be used to manage social campaigns too. When every other person is trying to run a business module includes defining goals/milestones, scheduling of their own, marketing becomes a must. Be a campaign, and viewing and modifying the campaign it a start-up or an established firm, everyone activities and operations using an interactive time line. depends on marketing to grow their business. And the Automatic execution of a scheduled activity, collection Web is currently one of the fastest growing marketing of data for analysis and automatic notifications in case platforms. Facebook, Twitter, LinkedIn and Google+—all of errors, come under the ‘Execution’ module. The cater to the growth of businesses by providing platforms ‘Monitoring’ module comprises the Analytics Report for advertisements. However, the downside is that it is covering the number of Facebook ‘likes’, comments, quite hard to manage one’s online marketing efforts. number of Twitter re-tweets and so on. The Budget Report That’s exactly why a group of open source enthusiasts defines the budget spent per channel, and the Sales Report have launched CampaignChain, a tool for managing digital is integrated with CRM and other tools to view and analyse marketing campaigns. leads generated by each campaign. CampaignChain is an open source campaign The many benefits of CampaignChain management software to plan, execute and monitor a digital marketing campaign across multiple online Let’s find out just how handy this tool is. I will jot down communication channels, which include Twitter, Facebook, some of the problems faced and then offer solutions using Google Analytics, or third party CMSs, e- commerce CampaignChain. and CRM tools. The key features of CampaignChain are planning, execution and monitoring. The ‘Planning’ There are many online channels for advertising. So it 96 | April 2015 | OpEN SOUrCE FOr YOU | www.OpenSourceForU.com

Overview For U & Me Figure 1: Create a new location Figure 3: Announcement on Facebook Figure 2: New Facebook status Figure 4: Managing all activities becomes cumbersome and hectic to go to individual sites and Improper management is a glitch associated with a post an advertisement. CampaignChain provides a common campaign and this arises mostly because of incomplete platform where the user can choose whatever online channel data or inconsistent information. The CampaignChain tool is desired. There is an option to add sites, apart from those provides a tab named ‘Execute’ which shows a clear picture already being used. of the upcoming activities, the milestones to achieve and the ongoing activities. This helps in planning one’s marketing The second hurdle is when we are unclear about campaign accordingly. scheduling a campaign, that is, when to post an advertisement on a specified channel. This tool has configured a feature to Any software is considered worthy if it is user friendly resolve this issue. All one has to do is create an activity and and takes good care of the customer. CampaignChain schedule it. (Creating a new post for a blog channel is an ranks high on both counts. It has a very user-friendly UI, example of an activity.) The benefit of scheduling is that it backed by a group of professionals, who help in adapting saves a lot of time and lets you plan your campaign. CampaignChain to fit your marketing objectives and processes. Training is also provided with respect to the After posting the advertisement, one may want to know technical details of this tool. All you have to do is drop a mail more about how the advertisement is being received, so to [email protected]. statistics about the number of tweets, re-tweets, Facebook ‘likes’, comments, subscriptions or any other key parameters If you wish to try your hand at it, download are welcome. This feature is well integrated in CampaignChain. CampaignChain by visiting http://www.campaignchain.com/ All one has to do is paste a code snippet on the server pages try/. The complete installation is provided in a manual at and that’s it. The monitor tab gives a chart of statistics collected http://doc.campaignchain.com/wp-content/doc/pdf/current/ per activity per online channel, along with data on how the CampaignChainDocumentation.pdf. But there are some marketing budget has been utilised. Statistics give a clear prerequisites, such as your system must have PHP5.4 or a indication about how many leads have been generated per later version, Java 1.5 or a more current version and MySQL; campaign and which activity has the highest impact. This helps PHP’s system() function must work, etc. All these details can in deciding future marketing plans. As an example, the video of be found in the documentation. the ‘Clean India’ campaign or the Ice Bucket Challenge gained a lot of views on YouTube as compared to the 160-character By: Ashish Kumar Sinha quote on Twitter on the same topics. So more emphasis was TsBohfeytwa:aurAtehonerniitslhuaKssiuaosfmttwaatarhereeanPrtg,uinheegeirsabplaiasasesdioinnaBteeanbgoaluutruu.sAing given to online video channels for promoting the campaign, as people could see their idols taking up the challenge of cleaning open source technology and sharing it with the world. He can India or going under the ice bucket. be reached at [email protected] www.OpenSourceForU.com | OpEN SOUrCE FOr YOU | April 2015 | 97

Open Gurus Insight Audio Video Bridging: Evolution of Multimedia Streaming Technology The Institute of Electrical and Electronics Engineers (IEEE) has developed a set of technical standards that allow time-synchronised low latency streaming services through IEEE 802 networks.This is commonly known as audio video bridging. Read on to learn more about the concept. Initially, when our project was instituted, I was oblivious that non-AVB devices don’t degrade the performance of the AVB of the potential of the audio video bridging (AVB) network and devices. The AVB ecosystem is evolving and creating standard and its applications, as I was mainly involved its own niche in the automotive infotainment, consumer electronics, in the protocol implementation to get the desired outcome. broadcast system design and other domains. It was only when I started monitoring AVB products and the AVB demonstrations held by companies in this domain that I Before the AVB standard came into existence, there was no learned about its significance. standard way to synchronise the audio-video devices, to reserve the bandwidth and resources to stream real-time AV data between Let us start with a brief introduction to Ethernet AVB, which these devices, and to discover and control them. To understand has evolved from the existing Ethernet standard. This technology the functionality of AVB, assume you have listener devices - one ensures tight control over the quality of service required for speaker in the kitchen, one in the garage and one in your bedroom. streaming real-time high-quality audio and video over wired You have a talker device, like a mobile, connected with the three Ethernet. Before the existence of AVB standards, the audio speakers in an AVB network, and you wish to stream AV data to and video set-up involved a large number of cables intertwined these listener devices in real-time. You also want to download data with each other. Now, AVB technology provides a high quality from the Internet, simultaneously, on your mobile device. The real- audio and video experience using structured wiring without any time streaming will not be affected even when non-AVB traffic complicated set-ups, while coexisting with the other non-media faces traffic congestion, and the AV data will be played at the same network traffic. AVB technology involves fundamental changes instant by all the listeners. to the Ethernet standards to support the audio-video media distribution, by furnishing high precision network synchronisation, AVB is the name given to a set of protocol standards dynamic bandwidth reservation to ensure packet delivery within developed by the IEEE Audio Video Bridging Task Group. To stipulated latency and traffic shaping to minimise bandwidth standardise and improve the interoperability of AVB devices and needs. It also eliminates media bursts even when passing through networks, a consortium of automotive and consumer electronics multiple network hops, and provides admission control to ensure companies, called the AVnu Alliance, was formed in August 2009. It constantly strives to establish and certify AVB products which 98 | April 2015 | OpEN SOUrCE FOr YOU | www.OpenSourceForU.com

Insight Open Gurus Applications Let me introduce you to the first four basic AVB protocols required to form an AVB network. With these standards, one can have IEEE 1722.1 Streaming Media TCP/UDP a single talker-listener set-up working in an AVB network. But to Services Services establish an AVB network comprising multiple talkers and listeners, Discovery, one needs to provide the support of the other two (AVDECC and Enumeration, MAAP) standards to manage and control these devices. Configuration and IEEE 802.1AS Control The IEEE 802.1AS protocol plays a pivotal role in IEEE 1722/1722a/1733 TCP/UDP on IP OS synchronising AVB devices by exchanging timing information Protocol over the network. This exchange of timing information allows 802.1 Qat AV Transport Protocol Stack the AVB devices to synchronise their local clocks with reference to a standard AVB clock. SRP 802.1 AS 802.1 Qav The model adopted by gPTP is analogous to the slave-master gPTP FQTSS model, where the master exchanges its timing information with the other AVB devices (slaves) and the slaves synchronise their Ethernet Driver clock with the master (see Figures 3 and 4). Silicon (Core + EMAC +EPHY) IEEE 802.1Qav Figure 1: AVB stack layout This traffic shaping (queuing and forwarding) protocol is implemented at the hardware layer (MAC). Traffic shaping involves LISTNER TaLkER prioritising the transmission of packets to maintain the standard Stereo Line Out Stereo Line In streaming rate required to transfer AVB packets while handling non- audio Source AVB network traffic. It can also be termed as bandwidth reservation protocol. To recap, the definition of bandwidth means the number Ethernet Hub of bits transmitted per unit of time, and the hardware controls the number of packets transmitted per unit of time, using credits. LISTNER TaLkER Let us assume credit to be an X constant value. Now, whenever Stereo Line Out Stereo Line In there is an AVB packet to be transmitted, the hardware checks for the value of X. The credits, i.e., the value of X, keeps getting audio Source accumulated at a constant rate when an AVB packet is queued. If the value of X is positive, the AVB packet is transmitted out Master Clock Slave Clock Now, It’s PTP Network jitter remains - PTP OK, thanks ... UDP other techniques must be UDP 9:25! used to reduce this effect Hardware TS IP Hardware TS Figure 2: A simple talker and listener set-up removes IP TSMAC removes ensure interoperability and improve audio/video quality. effect of effect of protocol PHY protocol In general, an AVB ecosystem deploys the following stack jitter protocols: stack jitter MACTS IEEE 802.1AS: Timing and synchronisation for time- ... 9:25! sensitive applications (gPTP) PHY Network IEEE 802.1Qav: Forwarding and queuing for Now it;s 9:25 IEEE 1588 stack timesensitive streams (FQTSS) Minimize imapct of protocol stack jitter Network protocol by generating timestamps as close to the stack & OS IEEE 802.1Qat: Stream reservation protocol (SRP) physical interface boundary as possible IEEE 1722 Layer 2 AVB transport protocol Timestamp MI / IEEE 1722.1: Audio video discovery, enumeration, generation GMI connection management and control protocol (AVDECC) / message IEEE 1722.MAAP: MAC address acquisition protocol detection How the AVB stack resides in an AVB device can be understood from Figure 1. PHY The talker and listener set-up forming an AVB network can be understood from Figure 2. Figure 3: Clock synchronisation using gPTP 1:30:05 1:30:05 MASTEr 1:30:05 1:30:05 1:30:05 1:30:05 Figure 4: Slaves synchronised to master www.OpenSourceForU.com | OpEN SOUrCE FOr YOU | April 2015 | 99

Open Gurus Insight idle Slope send Slope requirements. The bridge receiving this message sets aside or reserves the requested resources, and propagates the message Credit to the next system. The listener responds with a ‘listener ready’ message, which is sent back to the talker. If any bridge fails to three aVB packets 4th aVB packet allocate the requested resources, it sends a ‘talker fail’ message are queued is queued to the other systems, which results in AV traffic streaming getting aborted. This is how a stream is actually registered with the Queue 3 2 1 bridges and the two endpoints – talker and listener – communicate 2 1 0 with each other. The resources comprise ensuring port throughput, data rate and registering AVB class. Refer Figure 6 and Figure 7. Depth 0 1 IEEE 1722 Layer 2 AVB transport protocol 0 This protocol basically handles the packetising of the AV data Transmitted Interfering into a standard 1722 Ethernet frame. It also shoulders the Data traffic responsibility of passing down the 1722 AVB packet to the driver for it to transmit over the Ethernet. Time credit positive, aVB credit positive, 3rd credit positive, 3rd packets launched as aVB packet launched aVB packet launched This protocol is implemented as part of the talker soon as interfering application, which does the following: credit negative, 3rd ƒ Reads raw audio/video data from a file traffic is finished aVB packet held ƒ Packetises the same data into a standard AVB Ethernet frame ƒ Delivers the AVB Ethernet frame to the lower layer driver Figure 5: Qav traffic shaping for its transmission advertise R D B3 R This application has also undergone significant modifications, D D advertise which involve reading data directly from the AV devices and D B4 streaming it to the listener application. The main purpose of R advertise advertise R D T Talker station this is to extract the raw data and play it in real-time over the advertise R loudspeaker/headphones, or when using an ALSA sub-system. T R D B2 D B6 L Listener station We are currently experimenting with an AVB set-up that involves AVB endpoints (talker/listener) designed and developed D advertise R Other end station by XMOS and an AVB Ethernet switch from DSP4U. Initially, advertise R our set-up included only one talker and one listener, with support Bridge from the first three AVB protocols, but now the AVB stack has R D D B5 evolved and is mature enough to handle multiple AVB devices advertise advertise r - registration in an AVB network. We will discuss the AVDECC, MAAP and D D B1 D - declaration IEEE 1722 layer 2 transport protocols in the next article about propagation of talker multiple AVB devices in an AVB network. advertise advertise advertise towards But before we do that, here’s some food for thought. intended listener Can you think of another domain where this technology can R R propagation of talker penetrate? What will an entire AVB network set up using R advertise towards Ethernet LAN cables look like? Quite clumsy, right! So what’s other endpoints next? An AVB wireless chip? Figure 6: Successful reservation (talker advertise) References ready RD B3 [1] http://en.wikipedia.org/wiki/Audio_Video_Bridging D D R [2] http://www.ieee802.org/1/pages/avbridges.html D B4 [3] http://blog.meinbergglobal.com/category/ieee1588/ R ready advertise ready R R Videos T advertise R D Talker station [1] https://www.youtube.com/watch?v=R8Hjyu4IIkE D B2 D B6 Listener station [2] http://www.xmos.com/news/videos?search=AVB [3] https://www.youtube.com/watch?v=kQ7FBbH-krM D advertise Other end station ready R By: Sumeet Jain R Bridge eTBnhgeyina:euetAhr.onYroiwulocKrkasnuarmet aecIanhforhcimPhipaust [email protected] D D B5 D D B1 advertise advertise r - registration D - declaration ready advertise propagation of listener ready back to talker (on R R asame path as advertise R propagation of talker advertise towards other endpoints Figure 7: Reservation acknowledged (listener ready) of the hardware; otherwise (if the value of X is negative), the AVB packet is buffered until the value of X rises again and becomes positive. During this interval, the hardware gets busy dealing with non-AVB traffic, thus handling AVB and non- AVB traffic efficiently. This is just a short summary of how the hardware reserves bandwidth for AV traffic, to ensure the desired QoS. Refer Figure 5. IEEE 802.1Qat The stream reservation protocol ensures the reservation of network resources for specific AV streams traversing bridged networks. It determines the resources required, and exploits a mechanism for dynamic maintenance of those resources. Before the source starts initiating the AV traffic, it sends the ‘talker advertise’ message across the network. This message consists of the following: source and destination MAC address, 16-bit unique ID and information about the resource 100 | April 2015 | OpEN SOUrCE FOr YOU | www.OpenSourceForU.com


Like this book? You can publish your book online for free in a few minutes!
Create your own flipbook