Monday, October 13, 2008

Do u know Daknet??? Wireless Point to Point Connectivity??

Information delivery and communication efficiency in rural and remote areas in a developing country is the main concern of this article. Here we see how wirelless networks can achieve this point to point conectivity while providing the broadband access to remote areas at very low prices. "Daknet" is an initiative of this kind which has been successfully implemented and functioning even in some rural parts on India.

DakNet, is an ad hoc network that uses wireless technology to provide asynchronous digital connectivity,is an evidence that the marriage of wireless and asynchronous service may be the beginning of a road to universal broadband connectivity. Developed by MIT Media Lab researchers, DakNet has been successfully deployed in remote parts of both India and Cambodia. The DakNet wireless network takes advantage of the existing communications and transportation infrastructure to distribute digital connectivity to outlying villages lacking a digital communications infrastructure. How is that achieved?



The above figure illustrates the Daknet concept that has been applied in real time. Instead of relaying information over long distances which would be expensive and consume more power, Daknet makes use of short point -to-point links to transmit data between the Kiosks in each village and portable storage devices call Mobile Access Points (MAP). Mounted on and powered by a bus, a motorcycle, or even a bicycle with a small generator, a MAP physically transports data among public kiosks and private communications devices (as an intranet) and between kiosks and a hub (for nonreal- time Internet access). Low-cost WiFi radio transceivers automatically transfer the data stored in the MAP at high bandwidth for each point-topoint connection.

1)As the MAP-equipped vehicle comes within range of a village WiFi-enabled kiosk, it automatically senses the wireless connection and then uploads and downloads tens of megabytes of data.

2)When a MAP-equipped vehicle comes within range of an Internet access point (the hub), it automatically synchronizes the data from all the rural kiosks, using the Internet.

These steps are repeated each time a MAP equipped vehicle passes through the village which enables low cost wireless network and seamless connectivity. Even a single vehicle passing by a village once per day is sufficient to provide daily information services and the connection quality is also high. Daknet also incorporates means for seamless scalability in future when the village's ecconomy grows and people can afford to spend more and they will also be able to obtain real time communication services.

Even local entrepreneurs currently are using DakNet connections to make e-services like e-mail and voice mail available to residents in rural villages. Daknet concept has helped many more initiatives in India like the Bhoomi initiative. Bhoomi, an initiative to computerize land records. Daknet helps on this a lot. A detailed article on Daknet and other initiatives which has enabled digital connectivity in remote areas through wireless networks is available here.

http://www.keepandshare.com/doc/view.php?id=867331&da=y






Tuesday, September 16, 2008

Using Sun's Wireless ToolKit for CDLC to develop a simple J2ME App

The Sun Java Wireless Toolkit (formerly known as J2ME Wireless Toolkit) is a set of tools for creating Java applications that run on devices compliant with the Java Technology for the Wireless Industry (JTWI, JSR 185) specification and the Mobile Service Architecture (MSA, JSR 248) specification. It consists of build tools, utilities, and a device emulator. The application, a MIDlet, was designed for the Mobile Information Device Profile, one of the Java ME specifications. here we write and deploy a normal servlet and hook it up with a MIDlet to run the same app in a mobile device. we can test it using the emulator provided in the toolkit.

First prepare for a normal web app deployment using Tomcat 4.1 or above. the folowing code just counts the number of hits and displays it to the user.
import javax.servlet.http.*;
import javax.servlet.*;
import java.io.*;

public class HitServlet extends HttpServlet {
private int mCount;

public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
String message = "Hits: " + ++mCount;

response.setContentType("text/plain");
response.setContentLength(message.length());
PrintWriter out = response.getWriter();
out.println(message);
}
}
Compile and deploy the servlet using configurations in the web.xml as its done usually.Test the application by providing the URL specified in the web.xml.now we'l connect the servlet with the MIDlet.Install the wireless Toolkit and create a new project HelloSuite. The following shows the Toolkit interface.

The window will show where you have to store the source code files after creating the project.
Savethe below code as HitMIDlet.java inside the apps/HelloSuite/src directory underneath the Sun Java Wireless Toolkit root directory.
import java.io.*;

import javax.microedition.io.*;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;

public class HitMIDlet
extends MIDlet
implements CommandListener {
private Display mDisplay;
private Form mMainForm;
private StringItem mMessageItem;
private Command mExitCommand, mConnectCommand;

public HitMIDlet() {
mMainForm = new Form("HitMIDlet");
mMessageItem = new StringItem(null, "");
mExitCommand = new Command("Exit", Command.EXIT, 0);
mConnectCommand = new Command("Connect",
Command.SCREEN, 0);
mMainForm.append(mMessageItem);
mMainForm.addCommand(mExitCommand);
mMainForm.addCommand(mConnectCommand);
mMainForm.setCommandListener(this);
}

public void startApp() {
mDisplay = Display.getDisplay(this);
mDisplay.setCurrent(mMainForm);
}

public void pauseApp() {}

public void destroyApp(boolean unconditional) {}

public void commandAction(Command c, Displayable s) {
if (c == mExitCommand)
notifyDestroyed();
else if (c == mConnectCommand) {
Form waitForm = new Form("Waiting...");
mDisplay.setCurrent(waitForm);
Thread t = new Thread() {
public void run() {
connect();
}
};
t.start();
}
}

private void connect() {
HttpConnection hc = null;
InputStream in = null;
String url = getAppProperty("HitMIDlet.URL");

try {
hc = (HttpConnection)Connector.open(url);
in = hc.openInputStream();

int contentLength = (int)hc.getLength();
byte[] raw = new byte[contentLength];
int length = in.read(raw);

in.close();
hc.close();

// Show the response to the user.
String s = new String(raw, 0, length);
mMessageItem.setText(s);
}
catch (IOException ioe) {
mMessageItem.setText(ioe.toString());
}
mDisplay.setCurrent(mMainForm);
}
}

There are two other things to configure to get HitMIDlet working. First, you need to tell the toolkit about this new MIDlet. Click on Settings..., then select the MIDlets tab. Click on Add and fill in "HitMIDlet" for both the MIDlet name and class name. You can leave Icon blank. Click on OK and you should see HitMIDlet listed.

click on
Settings..., then select the User Defined tab. Click on the Add button. Fill in the property name as HitMIDlet.URL; the value should be the URL that invokes HitServlet, the same URL you used in a browser to test the servlet. When you're finished, click on OK to dismiss the project settings window.
Click on Build button and then Run button to run the application. you will see the emulator now..launch and connect and u will see the same result you saw in the webbrowser earlier as shown below..



Sunday, August 3, 2008

Mounting Devices on Linux

Before accessing a hard disk or any other storage medium in Linux or UNIX they should be mounted. Note that there is no concept of mounting in windows platforms. Mount allows you to merge two file systems. Mounting of file systems are done with mount command.


The figure shows the unix file system before mounting and after mounting.

The Mount command
Mount command has many options and hence little complex. But most of the time you will be able to mount file systems easily with few options. Mount command takes following general format.
mount -t filesystem_type -o mount_options /dev/device_file /mnt/mount_point

Usually we don't specify t option because kernel can usually identify the file system type by looking at partition table. The o options are also optional.We can unmount a device by it's device file name or by the mount point.
#umount /dev/sda
#umount /mnt/flash

Mounting a CD ROM/DVD ROM
Following command tells the kernel to auto detect (t auto) file system type and mount the device /dev/cdrom on /mnt/cdrom.
#mount -t auto /dev/cdrom /mnt/cdrom

If mounting fails, check whether you have a /mnt/cdrom directory, you can do it by using ,
#ls -l /mnt/cdrom

If it is not there then create it,
#mkdir /mnt/cdrom

Now try the mount command if it fails again check whether you have /dev/cdrom. If it does not exist, try
#dmesg | grep -i cdrom to find out the device file.

Now you can retry the command assuming that /dev/hdb is your CD ROM drive.
#mount -t auto /dev/hdb /mnt/cdrom.

Mounting a floppy, USB drive and windows partition
You can mount floppy as root user with following command.
#mount -t auto /dev/fd0 /mnt/floppy

If you get any error follow steps given earlier.
For USB drive, as root user
#mount -t vfat /dev/sda1 /mnt/usb

If you get any error follow steps given above. If you still get error saying that /dev/sda is not a valid block device then check whether the disk is partitioned. You can do this with fdisk command.
#fdisk -l /dev/sda

If you still find problems restart your hotplug sub system and remove and reinsert the device.
#/etc/init.d/hotplug restart

When mounting DOS/Windows partitions first make sure whether it is fat formated or ntfs the following commands can be used.
#mount -t vfat /dev/hda1 /mnt/windows
#mount -t ntfs /dev/hda5 /mntwinxp

If you want to mount so that all users can read and write, you may want to try:
#mount -t vfat -o user,rw,exec,umask=000 /dev/hda1 /mnt/c

“-o user,rw,exec,umask=000” gives every body all the permission to all the files on your partition.

Mounting a loopback device
Create a file containing all zeros. A 10MB file.
#dd if=/dev/zero of=myblock.img bs=1k count=1024

Now attach this to loop back device and format.
#losetup /dev/loop0 myblock.img
#mkfs -t vfat /dev/loop0

Now we can mount the device by using the file as the device.
#mount -o loop myblock.img /mnt/loop

How can you allow a normal user to mount a device?
All you have to do is adding an entry to the /etc/fstb file It has the following format.
<file> <mount> <type> <options> <dump> <pass>
/dev/sda1 /mnt/usb vfat user,rw 0 0

Sunday, July 20, 2008

A complete chat program

ChatClient.java

import java.net.*;
import java.io.*;

public class ChatClient implements Runnable
{
static String command;
Socket socket;
static final int portNumber=1666;
Thread commReader=null;

BufferedReader input;
PrintStream output;

String alias=null;
boolean logging=true;

public static void main(String[] argv) throws IOException
{
InetAddress clientAddr;
if(argv.length==0)
clientAddr=InetAddress.getLocalHost();
else
clientAddr=InetAddress.getByName(argv[0]);
System.out.println("Connecting to Chat Server at "+clientAddr);
ChatClient cc=new ChatClient(clientAddr);
Thread t=new Thread(cc);
t.start();
}

public ChatClient(InetAddress adx)
{
CommandReader cr=new CommandReader(this);
commReader=new Thread(cr);
command="xXx";
try
{
socket=new Socket(adx,portNumber);
input=new BufferedReader(new InputStreamReader(socket.getInputStream()));
output=new PrintStream(socket.getOutputStream());
commReader.start();
}
catch(IOException e)
{
System.out.println("Abnormal chat client socket condition:"+e);
}
}

public void run()
{
try
{
doLoop();
input.close();
output.close();
socket.close();
System.exit(0);
}
catch(IOException e)
{
System.out.println("Abnormal chat client socket condition:"+e);;
}

}

public void doLoop() throws IOException
{
String nullString=new String("xXx");
String data=nullString;
while(true)
{

synchronized(command)
{

if(!command.equals("xXx"))
{
data=command;
//reset
command="xXx";

}
} //end synch

if(!data.equals("xXx"))
{
if(logging)
{
//first msg
logging=false;
alias=data;
System.out.println(">>Logging as:"+alias);
output.println("S"+alias); //Starting new chat
}
else
{
if(data.equals("exit"))
{
System.out.println(">>Exiting Chat.");
output.println("X"+alias);
break;
}
else if(data.equals("/list"))
{
System.out.println(">>list of connected users:");
output.println("L"+alias);
break;
}
else if(data.equals("/help"))
{
System.out.println(">>Help on Chat commands:");
output.println("H"+alias);
break;
}
else
{
System.out.println(">>Sending msg:"+data);
output.println("D"+data); //sending data
}
}

}

data=input.readLine();
if(!data.equals("xXx"))
{
System.out.println("<<"+data);
}
data=nullString;
}
}

}


ChatDaemon.java

import java.net.*;
import java.io.*;

public class ChatDaemon implements Runnable
{
static final int maxClients=20;
static final int portNumber=1666;
static int numClients=0;
ChatServer[] chatters;
Thread me;

SharedMsg sharedMsg;

public static void main(String[] argv)
{
ChatDaemon cd=new ChatDaemon();
}

public ChatDaemon()
{
sharedMsg=new SharedMsg(this);
chatters=new ChatServer[maxClients];
//start sending
me=new Thread(this);
me.start();

try
{
listen();
}
catch(IOException e)
{
System.out.println("Abnormal socket condition:"+e);
}
}

public void listen() throws IOException
{
ServerSocket ss=null;
ss=new ServerSocket(portNumber);
Socket chatSocket=null;
System.out.println("...listening for connections..");
while(true)
{
chatSocket=ss.accept();
ChatServer ct=allocThread(chatSocket);
synchronized(System.out)
{
System.out.println("Allocated new chat server");
}
}

}

ChatServer allocThread(Socket s)
{
if(numClients<maxClients)
{
ChatServer ct=new ChatServer(s,sharedMsg,numClients);
chatters[numClients]=ct;
Thread t=new Thread(ct);
t.start();
numClients++;
return ct;
}
else
return null;
}

public void run()
{
char broad=(char)-1;
String dataNull=new String(broad+"xXx");
while(true)
{

for(int i=0;i<numClients;i++)
if(chatters[i].alive())
chatters[i].newMsg(dataNull);
}
}

public void refresh()
{
String data=sharedMsg.get();
synchronized(System.out)
{
System.out.println("RECEIVED:"+data);
}
for(int i=0;i<numClients;i++)
{
if(chatters[i].alive())
chatters[i].newMsg(data);
}
}
}


ChatServer.java

import java.net.*;
import java.io.*;

public class ChatServer implements Runnable
{
int index=-1;
SharedMsg sharedMsg;
Socket socket;

DataInputStream input;
PrintStream output;

String alias="";
boolean running=false;

boolean alive()
{
return running;
}

public ChatServer(Socket s,SharedMsg sm,int idx)
{
index=idx;
sharedMsg=sm;
socket=s;
try
{
input=new DataInputStream(socket.getInputStream());
output=new PrintStream(socket.getOutputStream(),true);

}
catch(IOException e)
{
System.out.println("Abnormal chat server socket condition 1:"+e);;
}
}

public void run()
{
try
{
doLoop();
input.close();
output.close();
socket.close();
}
catch(IOException e)
{
System.out.println("Abnormal chat server socket condition 2:"+e);;
}
}

public void doLoop() throws IOException
{
String line=null;
String data=null;
char command='W';
char ind=(char)index; //index of sender of msg
char broad=(char)-1; //goes to everybody

running=true;
while(true)
{
//loop: reads in msg, write it onto sharedmsg
line=input.readLine();
command=line.charAt(0);
data=line.substring(1);

if(command=='X')
{
sharedMsg.put(broad+"User: "+data+" Logged Out");
break;
}
else if(command=='S')
{
//first msg
alias=data;
sharedMsg.put(broad+"New User Logged: "+alias);
}
else
{
sharedMsg.put(ind+"From "+alias+": "+data);
}
}
//exiting
running=false;
}

//new message arrived, send it over the socket
public void newMsg(String msg)
{
char mitt=msg.charAt(0);
String data=msg.substring(1);

if(mitt!=(char)index)
{
//send
output.println(data);
output.flush();

synchronized(System.out)
{
System.out.print(".\b");
System.out.flush();
}
}
}
}


CommandReader.java

import java.io.*;

/**
* Reads from keyboard (STDIN)
*/
class CommandReader implements Runnable
{
ChatClient chatClient;
DataInputStream user;

public CommandReader(ChatClient cc)
{
chatClient=cc;
user=new DataInputStream(System.in);
}

public void run()
{
System.out.println("Waiting for client side commands...");

String com=null;
while(true)
{
//reads from keyboard
try
{
com=user.readLine();
}
catch(IOException e)
{
System.out.println("Abnormal reading from user:"+e);
}

synchronized(chatClient.command)
{
chatClient.command=com;
}
}
}
}


SharedMsg.java

public class SharedMsg
{
String data="";
ChatDaemon chatDaemon=null;

SharedMsg(ChatDaemon cd)
{
chatDaemon=cd;

}

synchronized String get()
{
return data;
}

synchronized void put(String s)
{
data=s;
chatDaemon.refresh();
}
}

Saturday, July 12, 2008

Creating 2D Shapes in Java

The Java2D API provides advanced two-dimensional graphics capabilities for programmers who require detailed and complex graphical manipulations. it includes features for processing line art, text and images in packages java.awt, java.awt.image, java.awt.color, java.awt.font, java.awt.geom, java.awt.print and java.awt.image.renderable.

The code shown below constructs a ring of five pointed stars constructed from straight lines and complex curves.

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.GeneralPath;

import javax.swing.JFrame;

public class shapes extends JFrame{

//set window's title bar string, background color and dimensions
public shapes(){

super("Drawing 2D shapes");

getContentPane().setBackground(Color.WHITE);
setSize(400,400);
setVisible(true);
}

//draw general paths
public void paint(Graphics g){
super.paint(g);
int xPoints[]={55,67,109,73,83,55,27,37,1,43};
int yPoints[]={0,36,36,54,96,72,96,54,36,36};

Graphics2D g2d = (Graphics2D)g;

//create a star from a series of points
GeneralPath star = new GeneralPath();

//set the initials coordinates of the General Path
star.moveTo(xPoints[0],yPoints[0]);

//create the star
for(int count =1; count<xPoints.length; count++)
star.lineTo(xPoints[count],yPoints[count]);

//close the shape
star.closePath();

//translate the origin to (200,200)
g2d.translate(200,200);

//rotate around origin and draw stars in random colors
for(int count =1; count<=20; count++){


//rotate coordinate system
g2d.rotate(Math.PI/10.0);

//set random drawing color
g2d.setColor(new Color(
(int)(Math.random()*256),
(int)(Math.random()*256),
(int)(Math.random()*256)));

//draw filled star
g2d.fill(star);
}
}

public static void main(String args[]){

shapes application = new shapes();
application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

}

}

Run the program and view the result!!!

Friday, July 11, 2008

Kerberos... providing strong cryptography

The Internet is an insecure place as we all know. Many of the protocols used in the Internet do not provide any security. Tools to identify passwords off of the network are in common use by malicious hackers. Thus, applications which send an unencrypted password over the network are extremely vulnerable. Some sites attempt to use firewalls to solve their network security problems. Unfortunately, firewalls assume that hackers are on the outside, which is often a very bad assumption. Most of the really damaging incidents of computer crime are carried out by insiders.Kerberos was created by MIT as a solution to these network security problems. The Kerberos protocol uses strong cryptography so that a client can prove its identity to a server (and vice versa) across an insecure network connection. After a client and server has used Kerberos to prove their identity, they can also encrypt all of their communications to assure privacy and data integrity as they go about their business.Lets see how it works.


Auth - Authenticator , SK1 - Session Key , TGT - Ticket

The client asks the authentication server for a ticket to the ticket-granting server(TGS). The authentication server looks up the client in its database, then generates a session key (SK1) for use between the client and the TGS. Kerberos encrypts the SK1 using the client’s secret key. The authentication server also uses the TGS’s secret key (known only to the authentication server and the TGS) to create and send the user a ticket-granting ticket (TGT).



The client decrypts the message and recovers the session key, then uses it to create an authenticator containing the user’s name, IP address and a time stamp. The client sends this authenticator, along with the TGT, to the TGS, requesting access to the target server. The TGS decrypts the TGT, then uses the SK1 inside the TGT to decrypt the authenticator. It verifies information in the authenticator, the ticket, the client’s network address and the time stamp. If everything matches, it lets the request proceed. Then the TGS creates a new session key (SK2) for the client and target server to use, encrypts it using SK1 and sends it to the client. The TGS also sends a new ticket containing the client’s name, network address, a time stamp and an expiration time for the ticket — all encrypted with the target server’s secret key — and the name of the server.



The client decrypts the message and gets the SK2. Finally ready to approach the target server, the client creates a new authenticator encrypted with SK2. The client sends the session ticket (already encrypted with the target server’s secret key) and the encrypted authenticator. Because the authenticator contains plaintext encrypted with SK2, it proves that the client knows the key. The encrypted time stamp prevents an eavesdropper from recording both the ticket and authenticator and replaying them later. The target server decrypts and checks the ticket, authenticator, client address and time stamp. For applications that require two-way authentication, the target server returns a message consisting of the time stamp plus 1, encrypted with SK2. This proves to the client that the server actually knew its own secret key and thus could decrypt the ticket and the authenticator.



The target server knows that the client is who he claims to be, and the two now share an encryption key for secure communications. Because only the client and target server share this key, they can assume that a recent message encrypted in that key originated with the other party.

Wednesday, July 9, 2008

Combination Generator program in java

This is a problem related to computability and complexity in computer science...Some problems in computer science cannot be resolved completely. Finding a correct solution might be impossible at some circumstances. Have you heard of these problems? Sorting, Partition problem, Halting problem. Here i present a case regarding partition problem.

The program takes numbers at run time and breaks it in to two sets where the sum of the elements in the two sets are equal. It should display the result, or it should say there are no such two sets in the given numbers. The time taken to get the solution against the numbers entered at run time is calculated. I started with 10 numbers and waited for the result. Then increased it to 14,16 and so on.. I hope you got a clear picture of what is happening now. Below is the program written in java. The timer runs in the program itself.

import java.math.BigInteger;
import java.io.*;
import java.awt.event.*;
import java.util.*;
import java.text.*;

public class CombinationGenerator {

private int[] a;
private int n;
private int r;
private BigInteger numLeft;
private BigInteger total;


// Constructor

public CombinationGenerator (int n, int r) {

if (r > n) {
throw new IllegalArgumentException ();
}
if (n < 1) {
throw new IllegalArgumentException ();
}
this.n = n;
this.r = r;
a = new int[r];
BigInteger nFact = getFactorial (n);
BigInteger rFact = getFactorial (r);
BigInteger nminusrFact = getFactorial (n - r);
total = nFact.divide (rFact.multiply (nminusrFact));
reset ();
}

// Reset

public void reset () {
for (int i = 0; i < a.length; i++) {
a[i] = i;
}
numLeft = new BigInteger (total.toString ());
}

// Return number of combinations not yet generated

public BigInteger getNumLeft () {
return numLeft;
}

// Are there more combinations?

public boolean hasMore () {
return numLeft.compareTo (BigInteger.ZERO) == 1;
}

// Return total number of combinations

public BigInteger getTotal () {
return total;
}
// Compute factorial

private static BigInteger getFactorial (int n) {
BigInteger fact = BigInteger.ONE;
for (int i = n; i > 1; i--) {
fact = fact.multiply (new BigInteger (Integer.toString (i)));
}
return fact;
}

// Generate next combination (algorithm from Rosen p. 286)

public int[] getNext () {

if (numLeft.equals (total)) {
numLeft = numLeft.subtract (BigInteger.ONE);
return a;
}

int i = r - 1;
while (a[i] == n - r + i) {
i--;
}
a[i] = a[i] + 1;
for (int j = i + 1; j < r; j++) {
a[j] = a[i] + j - i;
}

numLeft = numLeft.subtract (BigInteger.ONE);
return a;

}

public static void main(String d[]) throws IOException{

long startTime; // Starting time of program, in milliseconds.
long endTime; // Time when computations are done, in milliseconds.
double time; // Time difference, in seconds.


//get the number of numbers in set
InputStreamReader reader = new InputStreamReader (System.in);
BufferedReader input = new BufferedReader(reader);
System.out.print("Enter the numer of numbers in you set=");
String p = input.readLine();
int q =Integer.parseInt(p);
//put the elements to an array

int sum_of_array=0;
int[] indices;
int elements[]=new int[q];
int half_of_set=0;
int sum_of_elm=0;

for(int r=0; r<q; r++){

System.out.print("Enter the numbers of your set=");
String c = input.readLine();
int e =Integer.parseInt(c);
elements[r]= e;
}
//get the sum of array
for(int x=0; x<elements.length; x++){
sum_of_array=sum_of_array+elements[x];
}
int reminder=sum_of_array % 2;
half_of_set=sum_of_array/2;

//
if(reminder==0){
startTime = System.currentTimeMillis();
for(int len_of_array=1;len_of_array<=elements.length;len_of_array++ ){

CombinationGenerator x = new CombinationGenerator (elements.length, len_of_array);
StringBuffer combination;
while (x.hasMore ()) {

combination = new StringBuffer ();
indices = x.getNext ();
for (int i = 0; i < indices.length; i++) {

sum_of_elm=sum_of_elm+elements[indices[i]];

}

if(half_of_set==sum_of_elm){


//print the sub set element

for(int g=0; g<indices.length; g++){
System.out.println("numbers in your one sub set are ="+elements[indices[g]]+",");

}
endTime = System.currentTimeMillis();
time = (endTime - startTime) / 1000.0;
System.out.println(time);

return;
}

sum_of_elm=0;//set the sum of elm to 0
}
}
endTime = System.currentTimeMillis();
time = (endTime - startTime) / 1000.0;
System.out.println(time);

}else{
System.out.println("given number set can not divide to two equal sets:Sorry");

}
}

}

The maximum number of numbers i could enter was 36..i couldn't go beyond that..the program stopped running....it explains the complexity of the problem. Finally the output was shown in a graph as below..

Monday, July 7, 2008

ISD Models..Systematic Approach vs Evolutionary

Instructional Systems Design, the most widely used methodology for developing new training programs. Today most of the e-learning programs are designed based on ISD. It is also known as Instructional Systems Design & Development (ISDD), the Systems Approach to Training (SAT), or just Instructional Design (ID). There are many ISD models that are used widely, like ADDIE, ASSURE, Dick & Carey Model etc. These are based on a systematic approach to online training.

But what do you think is the most effective approach? Systematic approach or the Evolutionary one? Some of the benefits of a system approach are characteristic of all systematic approaches. The ISD model is a management tool that makes courseware production more efficient. Effective training programs are more likely because the ISD model increases the probability that the courseware will match the objectives and not veer off in a different direction. Approach is scientific as it is empirical and can be replicated. The courseware can be improved and strengthened through data collection and analysis.



The figure shows the ADDIE model used widely for the systematic ISD approach..
Even though it has so many advantages they say it’s too systematic. A frequent criticism is that it is too time-consuming to be practical in the real world. There are practical challenges with a purely systemic design approach in the management of resources. In most cases, training programs must be developed under a fixed -- and often limited -- budget and schedule. While it is very easy to allocate people and time to each step in the ISD model, it is harder to plan deliverables when there are no distinct steps in the process.

Introducing Evolutionary & Rapid Prototyping Approach

An evolutionary approach includes both deterministic and incremental systems, in contrast to the systems approach, which is entirely deterministic. This approach is particularly appropriate for situations where there is limited past experience from which to draw guidance. A major benefit is that it enables a designer to test new ideas without making a long term commitment. A major disadvantage is that it lacks a defined set of steps. Also, it is difficult to specify in advance the amount of time and money that will be needed to complete significant events and it is logically impossible to specify the outcome of an evolutionary process.

Rapid Prototyping Design (RPD) uses a more formative model that is based on usability testing of prototypes. Results of usability tests on the prototypes are used to modify and improve the product. This model shares many attributes in common with the ISD model, and stresses the importance of iterative analysis and evaluation.

The conclusion is, if you know exactly what you are doing and exactly what needs to be built, then you are using the ISD (static or waterfall) method (however, this rarely happens in the real training world). When the subject is new, controversial, etc., then more prototypes are going to be built, hence you are more into RPD.

Tuesday, July 1, 2008

Write exceptions into error log(C#.net)

Try this console application code to write exceptions in to a log file.

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace ConsoleApplication1
{
class errorlogs
{

String filepath = "C:/Documents and Settings/error/log.txt"; //path of errorlog file

static void Main(string[] args)
{
errorlogs er = new errorlogs();
object i = new IOException();
er.writelog(i); //passing the ioexception
}

public void writelog(object a){

try{
StreamWriter logWriter;
if(File.Exists(filepath)){
logWriter = File.AppendText(filepath);
}
else{
logWriter = File.CreateText(filepath);

}
logWriter.WriteLine();
logWriter.WriteLine("------"+ DateTime.Now +"--------");
logWriter.WriteLine();
logWriter.WriteLine(a);
logWriter.WriteLine();
logWriter.WriteLine("--------------------------------");
logWriter.Close();

}
catch(Exception e){
Console.Out.WriteLine("Error in writing errorlog:" +e.Message);
}
}

}
}

Monday, June 23, 2008

Sendmail

Sendmail is a mail transfer agent (MTA) that is a well-known project of the open source, free software and Unix communities, which is distributed both as free software and proprietary software. Its also called the mail server daemon. Other mail server daemons include qmail, postfix, exim, mmdf, smail etc. server daemons looks after the receiving incoming mail and delivers outgoing mail.

Sendmail configuration files
All sendmail related configuration files have to be put in /etc/mail directory.

1)/etc/mail/access

It specifies what hosts or IP addresses have access to the local mail server and what kind of access(OK, REJECT,RELAY) they have.
OK - allowed to send mail to the host as long as mail's final destination is the local machine.
REJECT - reject for all mail connections
RELAY - allowed to send mail for any destination through this server.
e.g.
cyberterror.com     550 we dont expect mail from you
a.source.of.spam     REJECT
cyberspammer.com     OK
128.32          RELAY

2)etc/mail/aliases
This database contains a list of virtual mailboxes that are expanded to other user(s), files, programs or other aliases.
e.g
root: ajantha
webmaster:kamal,lal
customers: :include: /etc/mail/lists/customer-list

The last alias causes how to keep a list of users for an aliases in an external file.

3)/etc/mail/local-host-names
Consist list of host names that sendmail is to accept as the local mail host. if the mail server was to accept mail for the domains cmb.ac.lk and ucsc.cmb.ac.lk the above file will contain:
cmb.ac.lk
ucsc.cmb.ac.lk

4)/etc/mail/sendmail.cf
It controls the overall behavior of sendmail. The master sendmail configuration file can be built from m4 macros.

5)/etc/mail/virtusertable
This maps email addressse for virtual domains and mailboxes to real mail boxes. The mail boxes can be local, remote, aliases defined.
e.g
info@msc.cmb.ac.lk ajantha
info@bit.cmb.ac.lk saman







Tuesday, June 17, 2008

Containers and Servlets

A Servlet container is a specialized web server that supports Servlet execution. They map the request URLs to specific servlets..but how? Containers know the interface between the servlets and the web server. no specific API is needed for this.


The container receives a HTTP request.


The container creates request and response objects.


It initiates a new thread to handle the request. Then passes the two objects in to the thread.


Container calls the service() method of the servlet which would call the doGet() or doPost() methods, based on the request type.


The doGet() method returns the result, writes the HTML and stuffs it into the response object.


The HTML page is sent back to the client, the response, request objects are deleted and the thread is killed.

Hope this would have given a clear picture on what happens to the request for a servlet. but still there is more. Here the business logic and presentation are tied together which is not a very good OO practice. you can separate them using JSPs.. MVC improves on it even more...We'll come back to that later..



Wednesday, June 11, 2008

ERP Systems Overview


The above figure shows an ERP model.

When we say ERP Systems it’s basically the integration of several data sources and processes of an organization in to a unified system with a unified database to store various system modules. Modular software design is the core concept of ERP systems which allows individual components/modules to be added to the system. These modular software designs link into the common database, so that all of the information between is accessible in real time. ERP systems integrated separate systems of an organization which led to minimization of specialties in an organization.

When most people refer to the “core” ERP applications or “modules,” they mean the back-office capabilities to manage human resources, accounting and finance, manufacturing, and project-management functions. However, major ERP suites from Oracle, PeopleSoft, and SAP now provide much more—including modules for sales force automation, business intelligence, customer relationship management, and supply chain management. We had a practical assignment at university where we had to plan an ERP system for the Sri Lankan Railways. The document is available here. It includes study of the existing system, the proposed system features, the risks and rewards in implementing it etc. I’m sure it will provide a practical view.

http://www.keepandshare.com/doc/view.php?id=622579&da=y

Characteristics of ERP systems

• In ERP systems, information is often recorded in a form that cannot be read without the use of a computer.

• Financial and business information is often generated automatically by ERP systems based on data previously entered, without further human instructions.

• Errors that might be observed in non-ERP systems may go undetected because of the reduced human involvement in computerized processing. There is a danger that errors in processing may be applied to a large number of transactions without being noticed.

• With proper controls, ERP systems can be more reliable than non-ERP systems. This is because ERP systems subject all data to the same procedures and controls. Non-ERP systems are subject to random human error. Although computer processing will usually be consistent, errors may still occur; for example, if the computer is incorrectly programmed.

• But still it is difficult to make changes after an ERP system has been implemented. Therefore, we should be aware of the organization’s plans to introduce significant new systems or to make major modifications to existing systems. It is advisable to review new systems or modifications before implementation so that a preliminary assessment can be made of the adequacy of control procedures, in order to ensure an adequate audit trail, and to plan any necessary changes in the audit approach.

Monday, June 9, 2008

Using SSH

SSH is a program to log into another computer over a network, to execute commands in a remote machine, and to move files from one machine to another. It provides strong authentication and secure communications over insecure channels. SSH is most useful when logging into a UNIX machine from another machine where the traditional telnet and rlogin programs would not provide password and session encryption.

Now we'll take a look at some basic SSH commands in networking.
To login to a remote machine running sshd server you can use the any of the following formats.

# ssh -l remote_user host_name_or_ip
# ssh remote_user@host_name_or_ip
e.g.
# ssh -l root 192.248.16.100
# ssh bud@server.cmb.ac.lk

To execute a command on the remote machine without logging in explicitly you can use,
# ssh -l remote_user host_name_or_ip remote_command
e.g.
# ssh -l bud@192.248.16.100 /usr/bin/x11/xclock
It starts the xclock application in the remote machine.

To ftp securely you can use sftp.
e.g
# sftp bud@192.248.16.100

sftp> cd downloads - Used to change directory
sftp>mput *.rpm - Used to upload multiple files
sftp>mget httpd* - Used to download multiple files
sftp>help - See a list of commands

To copy files from one host to another try
# scp [-r] source user@remote_host:target
e.g.
# scp bud@192.248.16.100:/etc/lilo.conf /tmp

Still there is SSH server and client configuration and do you knw how to configure passwordless SSH login?
http://www.keepandshare.com/doc/view.php?id=624904&da=y


AdventNet QEngine 6 - Web Performance Test Tool

Lets have some practical experience on a testing tool. AdventNet QEngine Web Performance Test tool is a powerful, easy-to-use and affordable web load testing tool to quickly test the performance of your web sites and web-based applications. Its automatic analysis enables you to accurately simulate the traffic of thousands of users to identify and isolate performance bottlenecks and optimize user experience within minutes.

Main Features of AdventNet QEngine 6
  • Test Scheduling and Command Line Toolkit
  • Web Performance Testing (Load Testing)
  • Web Services Testing (Functional & Performance)
  • QEngine Issue Tracker
  • QEngine Toolbar for remote record/playback of user actions
  • Browser-based Web testing
  • Jython Test Scripts
  • Environment Independent Tests
  • Powerful Script Editor
The basic steps involved in QEngine Load Testing testing are as follows:


The detail picture of testing with QEngine is provided here.
http://www.keepandshare.com/doc/view.php?id=622522&da=y

Now we'll take a look at some of the outputs of the load testing with QEngine.

Transaction Status Summary




The above figure shows a transaction status summary graph provides a snapshot of Requests pending, Response pending & Response status such as, download started and download completed. If pending Request / Response is too high then check the test duration in Summary Report and the error distribution graph in Error Report to identify the problem.

Hits Per Second



This graph shows the number of HTTP/S requests made by Virtual users to the server during each second of the run.

URL wise Response Time Report



More details about QEngine testing is available in the link provided above. The report also speaks of another load and stress testing tool called WAPT 5.0 that provides with an easy-to-use, consistent and cost-effective way of testing web sites, web servers, and intranet applications with web interfaces.



A Little Survey on Software QA Tools

Many modern software systems consist of large sets of heterogeneously developed components. Object-oriented design, component-based software engineering, components off-the-shelf (COTS), design patterns, and open source software facilitate the development tasks, but assuring the quality in scenarios that entail (combinations of) these concepts is problematic.

Basically so many categories of test tools are available in the industry today. Some of the most important categories of these test tools are listed below.

  • Application Test Tools
  • Web Test Tools
  • Test Management Tools
  • Bug Tracking Tools
  • API Test Tools
  • Communications Test Tools
  • Requirements Management Tools

Most of the test tools are available in open source too. These tools are free. There is no need to pay a vendor to use these tools, but they still have a cost of ownership through evaluation, implementation, training and maintenance costs, the same as any software does. But with a handful of commercial vendors dominating the proprietary software testing tools market, make no mistake about it.

The paradox of quality assurance is that, although it’s a key value for every organization, the actions taken to ensure it are often left until late in the lifecycle when budgets are scarce, time is short and there is high pressure to deliver to the market. As a result there are often challenges associated with improving the software development process, reducing costs, improving quality and increasing reliability of planning. But so far the efforts to overcome these challenges are being successfully handled by software QA professionals to best safeguard the quality of good software.

From my viewpoint I found that future of software testing and quality assurance will be doing more on the web. The evolution in web development over the past two to three years has ushered in a new set of challenges for software quality professionals across the board; specifically, the emergence of Web 2.0 and the introduction of Ajax and SaaS architectures as new approaches for building rich content applications for the web. Such shifts combined with the need for enterprises to be agile and deliver products to market in shorter product cycles, has dramatically challenged many of the existing testing tools and rendered many old record and replay approaches almost obsolete. A detail survey of mine on these QA tools is attached here. It also consists descriptions of various leading testing tools in market today.

http://www.keepandshare.com/doc/view.php?id=622520&da=y

Today it will be impractical to rely too much on human configurations, tests, debugging, and management because software systems today are of very large scale and contain numerous components and users. It is believed that, it is time to bring a new generation of cutting-edge technologies and innovative processes to software testing that will assist software quality professionals in building better software easier in the near future.



Sunday, June 8, 2008

HCI's role in e-learning


Today the eLearning environment is dramatically changing the way of students, employees and indeed all members of the general public learning new knowledge and performing learning activities. Effective learning occurs where students actively participate in the learning process and when they have ownership of what and how they learn, and are supported in appropriate ways. That is where e-learning has always been successful but still, making elearning sustainable in a traditional education environment involves many challenges.

A major challenge currently faced by e-learning systems’ designers is the development of improved tools better able to engage new learners and sustain their online learning activities any time and anywhere. E-learning systems should be designed in such a way so that its more usable and innovative, supporting creative learning, based on strategies which guides the learners to make the most effective use of the learning content. The approach to e-learning should be

  • learner centered
  • digitally minded
  • research based
  • focused on quality
  • innovative and
  • providing leadership.
Human- Computer Interaction (HCI) theories and methodologies can support the design of appropriate e-learning settings responding to the requirements of today’s e-learning environment which were shown above. It will make e-learning applications smart enough to adapt themselves to the students’ learning styles and to assure high standards of accessibility and usability, in order to make learners’ interaction with the systems as natural and intuitive as possible. In the context of Human-Computer Interaction it is important to consider a perspective that recognizes, respects, values and attempts to accommodate a wide range of human abilities, skills, requirements and preferences in the design of learning material. This automatically reduces the need for a lot of special features. It also encourages individualization, high quality of interaction and, ultimately, end-user acceptability. In short the focus here is always on the human user.

Analysis of learners’ preferred interactions with e-learning environment, and a learner-centered design perspective which takes into account also the typical learning styles shared within the different cultural contexts, are the key factors that would contribute to the successful integration of HCI in e-learning.



Datamining using RapidMiner 4.1

Data mining involves searching through databases for correlations and patterns that differ from results that would be anticipated to occur by chance or in random conditions. The practice of data mining in and of itself is neither good nor bad and the use of data mining has become common in many industries. I participated in a datamining assignment which analyzed the export patterns of Gems and Jewelry in Sri Lanka. the tool used was RapidMiner 4.1. Some most important facts were found out in the process.
The process of data mining consists of three stages:
(1) the initial exploration,
(2) model building or pattern identification with, and
(3) deployment

Stage 1: Exploration
This stage usually starts with data preparation which may involve cleaning data, data transformations, selecting subsets of records and - in case of data sets with large numbers of variables ("fields") - performing some preliminary feature selection operations to bring the number of variables to a manageable range


The figure shows a screenshot of a graph which was made on the gem exports using Rapid Miner.

Stage 2: Model building and validation

The dimensional model must suit the requirements of the users and support ease of use for direct access. The model must also be designed so that it is easy to maintain and can adapt to future changes.


The figure shows a 2D Model View of the data.

The model design must result in a relational database that supports OLAP cubes to provide instantaneous query results for analysts. a typical dimensional model uses a star or snowflake design that is easy to understand and relate to business needs, supports simplified business queries, and provides superior query performance by minimizing table joins.

Stage 3: Deployment
That final stage involves using the model selected as best in the previous stage and applying it to new data in order to generate predictions or estimates of the expected outcome.

I have attached my datamining asignment report here,

http://www.keepandshare.com/doc/view.php?id=622494&da=y