“Is it an animal? Is it an insect?” in Android

walker“Is it an animal? Is it an insect?”. The answer is neither. In fact it is my version of a ‘robot walker’ in android using Box2D & AndEngine. I got interested in this simulation after I saw the Theo Jansen walker in JBox2D (look under Joints) . I did take a look at the code for this but I found it difficult to follow so I made my own version of a robot walker.

With the above the robot walker is able to walk awkwardly as seen in the video clip on Youtube – Robot Walker in Android
The entire project can be cloned at GitHub at RobotWalker

In this connection I would like to point yot to an excellent and a fascinating TED talk by the creator Theo Jansen himself on “My creations, a new form of life”. His creations are really jaw- dropping.

Anyway getting back to my post I thought about what would make the insect walk? After some thought I realized that I had to create a swinging motion of the upper part of the leg combined with the lower leg motion which does not bend that much.

So I created a robot body which is a flat rectangular shape

Create the robot body
robot = new Sprite(100, 360, this.mRobotTextureRegion, this.getVertexBufferObjectManager());
robotBody = PhysicsFactory.createBoxBody(this.mPhysicsWorld, robot, BodyType.DynamicBody, BODY_FIXTURE_DEF);
this.mPhysicsWorld.registerPhysicsConnector(new PhysicsConnector(robot, robotBody, true, true));
this.mScene.attachChild(robot);
Creating legs
Then I create 6 different legs spaced apart
createLeg(100,360,1);
createLeg(120,360,1);
createLeg(140,360,1);
createLeg(160,360,1);
createLeg(180,360,1);
createLeg(200,360,1);
createLeg(220,360,1);
createLeg(240,360,1);
The createLeg() creates an upper and lower part of the leg. The upper part of the leg is connected to the body of the robot through a revoluteJoint as follows

Upper Leg
// Create upper leg
upperLeg = new Sprite(x, y, this.mLegTextureRegion, this.getVertexBufferObjectManager());
upperLegBody = PhysicsFactory.createBoxBody(this.mPhysicsWorld, upperLeg, BodyType.DynamicBody, LEG_FIXTURE_DEF);
this.mPhysicsWorld.registerPhysicsConnector(new PhysicsConnector(upperLeg, upperLegBody, true, true));
this.mScene.attachChild(upperLeg);
//Create an anchor/pivot at the body of the robot
Vector2 anchor1 = new Vector2(x/PIXEL_TO_METER_RATIO_DEFAULT,y/PIXEL_TO_METER_RATIO_DEFAULT);

//Attach upper leg to the body using a revolute joint with a motor
final RevoluteJointDef rJointDef = new RevoluteJointDef();
rJointDef.initialize(upperLegBody, robotBody, anchor1);
rJointDef.enableMotor = true;
rJointDef.enableLimit = true;
rJoint = (RevoluteJoint) this.mPhysicsWorld.createJoint(rJointDef);

Lower Leg
The lower leg is connected to upper leg through a distance joint
// Create lower leg
lowerLeg= new Sprite(x, (y+50), this.mLegTextureRegion, this.getVertexBufferObjectManager());
lowerLegBody = PhysicsFactory.createBoxBody(this.mPhysicsWorld, lowerLeg, BodyType.DynamicBody, LEG_FIXTURE_DEF);
this.mPhysicsWorld.registerPhysicsConnector(new PhysicsConnector(lowerLeg, lowerLegBody, true, true));
this.mScene.attachChild(lowerLeg);

// Connect the lower and upper leg with distance joint
Vector2 anchor2 = new Vector2(x/PIXEL_TO_METER_RATIO_DEFAULT, (y+50)/PIXEL_TO_METER_RATIO_DEFAULT);
//Create a distanceJoint between upper & lower leg
DistanceJointDef distanceJoint1 = new DistanceJointDef();
distanceJoint1.initialize(upperLegBody,lowerLegBody, anchor2,anchor2);
distanceJoint1.collideConnected = true;
distanceJoint1.dampingRatio = 0.5f;
distanceJoint1.frequencyHz = 10.0f;
this.mPhysicsWorld.createJoint(distanceJoint1);

 mqdefault

Creating a walking movement
To create a walking movement I create a timer task which triggers after a delay of 1 second periodically and makes the upper legs’s revoluteJoint swing between angles within an upper and lower limit.

new IntervalTimer(secs,rJoint);
The timer itself reverses the motor every time it fires
class RemindTask extends TimerTask {
RevoluteJoint rj1;;
RemindTask(RevoluteJoint rj){
rj1 = rj;
}
@Override
publicvoid run() {
reverseMotor();
}

publicvoid reverseMotor(){
rj1.setMotorSpeed(-(rj1.getMotorSpeed()));
rj1.setMaxMotorTorque(10);
}
}
With the above the robot walker is able to walk awkwardly as seen in the video Robot Walker in Android

The entire project can be cloned at GitHub at RobotWalker

I will probably be refining this sometime in the future. One good idea is to create a delay between the swings of different legs. Any thoughts suggestions on making the movement more fluid are more than welcome.

Take a look at some cool simulations using AndEngine & Box2D
1. Simulating the domino effect using Box2D and AndEngine
2. Bull in a china shop – Behind the scenes in android
3. Creating a blob in Android using  Box2D physics Engine & AndEngine
4. Blob with an attitude(stiffness) in Android
and a few more
Find me on Google+

Simulating an oscillating revoluteJoint in Android

DSC00074In this post I simulate an oscillating revoluteJoint in Android using Box2D physics engine & AndEngine. While I was attempting this in the context of something larger I found this fairly challenging so I decided to write a separate post on this.  Creating a revoluteJoint was rather trivial.  This was done as follows

Initially I created a static point to act as pivot.  I then used a rectangular shape joined at the pivot. I wanted this to oscillate about the pivot. So the pivot & the rectangular shape were created as follows
circle = new Sprite(100, 320, this.mBallTextureRegion, this.getVertexBufferObjectManager());

circleBody = PhysicsFactory.createCircleBody(this.mPhysicsWorld, circle, BodyType.StaticBody, FIXTURE_DEF);

this.mScene.attachChild(circle);

// Create leg

leg = new Sprite(110, 325, this.mLegTextureRegion, this.getVertexBufferObjectManager());

legBody = PhysicsFactory.createBoxBody(this.mPhysicsWorld, leg, BodyType.DynamicBody, gameFixtureDef);

this.mPhysicsWorld.registerPhysicsConnector(new PhysicsConnector(leg, legBody, true, true));

this.mScene.attachChild(leg);

Then I created a revoluteJoint between the leg and the circleBody as follows

final RevoluteJointDef rJointDef = new RevoluteJointDef();

rJointDef.initialize(legBody, circleBody, circleBody.getWorldCenter());

rJointDef.enableMotor = true;

rJointDef.enableLimit = true;

rJoint = (RevoluteJoint) this.mPhysicsWorld.createJoint(rJointDef);

rJoint.setMotorSpeed(2);

rJoint.setMaxMotorTorque(100);

rJoint.setLimits((float)(30 * (Math.PI)/180), (float)(270 * (Math.PI)/180));

The revoluteJoint has a lower limit of 30 degrees and an upper limit of 270 degrees.

To make it oscillate I created a Timer task which I fire every second. Every time the timer fires I reverse the motor speed as follows

class IntervalTimer {

Timer timer;

public IntervalTimer(int seconds, RevoluteJoint rj) {

Log.d(“Inside”,“in”);

timer = new Timer(); //At this line a new Thread will be created

timer.scheduleAtFixedRate(new RemindTask(rj), seconds*1000, 1000);

}

class RemindTask extends TimerTask {

RevoluteJoint rj1;;

RemindTask(RevoluteJoint rj){

rj1 = rj;

}

@Override

publicvoid run() {

Log.d(“x”,“x” +“Reversing motor”);

reverseMotor();

}

publicvoid reverseMotor(){

rj1.setMotorSpeed(-(rj1.getMotorSpeed()));

rj1.setMaxMotorTorque(100);

Log.d(“aa”,“speed:”+rj1.getMotorSpeed() + “torque:” + rj1.getMotorTorque());

}

}

}

I then instantiate the timer

new IntervalTimer(5,rJoint);

I now have an oscillating revoluteJoint which can be used in any number of ways.

The video clip is at “Simulating an oscillating revoluteJoint in Android

You can clone the project from GitHub at “oscillatingRevoluteJoint

Find me on Google+

Fun simulation of a Chain in Android

DSC00071In this post I simulate a Chain in Android using AndEngine & Box2D physics. Simulating a Chain is fairly straightforward. Initially I create a static point as an anchor point to suspend the Chain from

You can see the video at Fun simulation of a Chain in Android – I on Youtube

The project can be cloned from GitHib at Chain

 

link[0] = new Sprite((float) 360, (float) 20, this.mLinkTextureRegion, this.getVertexBufferObjectManager());

linkBody[0] = PhysicsFactory.createBoxBody(this.mPhysicsWorld, link[0], BodyType.DynamicBody, FIXTURE_DEF);

this.mPhysicsWorld.registerPhysicsConnector(new PhysicsConnector(link[0], linkBody[0], true, true));

this.mScene.attachChild(link[0]);

Then I create succeeding links to the initial link with revolute joints between them as follows

// Add links to chain with revolute joint between each link

for(int i =1; i < nBodies ; i++){

x[i] = x[i-1] + 8 * Math.cos(PI/4);

y[i] = y[i-1] + 8 * Math.sin(PI/4);

link[i] = new Sprite((float) x[i], (float) y[i], this.mLinkTextureRegion, this.getVertexBufferObjectManager());

linkBody[i] = PhysicsFactory.createBoxBody(this.mPhysicsWorld, link[i], BodyType.DynamicBody, FIXTURE_DEF);

this.mPhysicsWorld.registerPhysicsConnector(new PhysicsConnector(link[i], linkBody[i], true, true));

this.mScene.attachChild(link[i]);

revoluteJointDef = new RevoluteJointDef();

revoluteJointDef.initialize(linkBody[i], linkBody[i-1], linkBody[i-1].getWorldCenter());

revoluteJointDef.enableMotor = false;

revoluteJointDef.motorSpeed = 0;

revoluteJointDef.maxMotorTorque = 0;

this.mPhysicsWorld.createJoint(revoluteJointDef);

Finally I suspend a monkey as the last body to the Chain.

I have added plated for the 2 walls (right & left) and also the floor as collisions can be detected between bodies.

@Override

protectedvoid onManagedUpdate(finalfloat pSecondsElapsed) {

// Check collisions

if(rWall.collidesWith(this) ){

x = this.getX();

y = this.getY();

bText.setPosition(x-40,y – 20);

bText.setText(“Bonk!”);

}

if(lWall.collidesWith(this)){

x = this.getX();

y = this.getY();

bText.setPosition(x + 20,y – 20);

bText.setText(“Thump!”);

}

if(floor.collidesWith(this)){

x = this.getX();

y = this.getY();

bText.setPosition(x – 20,y – 20);

bText.setText(“Thud!”);

}

With all these under gravity we have a nice Chain effect!

You see the video at Fun simulation of a Chain in Android – I

The project can be cloned from GitHib at Chain

Take a look at some cool simulations using AndEngine & Box2D
1. The making of Total Control Android game
2. Simulating an Edge Shape in Android
3. Simulating a Web Joint in Android
4. Modeling a Car in Android
5. A closer look at “Robot horse on a Trot! in Android”
and a couple more
Find me on Google+

Modeling a Car in Android

DSC00065

In this post I give the details of how I modeled a ‘running car’ in Android using AndEngine & Box2D physics.  This post is based on a great blog post by Emanuele Feronato on “Step by step creation of a Box2D car/truck with motors and shocks”.

You can check the video of this simulation at “Modeling a Car using AndEngine & Box2D physics
You can clone the entire project from GitHub at Wheels

So getting down to the “nuts & bolts” of  creating a car we need to create 3 components of the car

1)Car body

2)Axles (left & right)

3)Wheels (left & right)

The car body is connected to the axles through a prismatic joint. Prismatic joint, also known as ‘slider joint’, allows 2 bodies to move relative to each on a single axis of motion. Hence this joint simulates a ‘shock absorber’ effect very nicely. In fact, in the 3rd lap of my video from right to left when the car collides with the left wall you can see the car rocking on its axles. This is done as below

/* Connect the front axle to car using a prismaticJoint */

PrismaticJointDef front = new PrismaticJointDef();

front.initialize(carBody, frontAxle, frontAxle.getWorldCenter(),new Vector2(0f,1f));

front.collideConnected=false;

front.enableMotor=false;

front.enableLimit=true;

front.upperTranslation=0.5f;

front.lowerTranslation=-0.2f;

PrismaticJoint mFront = (PrismaticJoint) mPhysicsWorld.createJoint(front);

The wheels are connected to the axles through a revolute joint. A revolute joint rotates around an anchor point based on a specified motor speed and motor torque as shown below

//Connect rear wheel to rear axle using revoluteJoint
final RevoluteJointDef revoluteJointDef2 =new RevoluteJointDef();
revoluteJointDef2.initialize(wheelBody2, rearAxle, wheelBody2.getWorldCenter());
revoluteJointDef2.enableMotor =true;
revoluteJointDef2.motorSpeed =-50;
revoluteJointDef1.maxMotorTorque = 10;
rj2 =(RevoluteJoint)this.mPhysicsWorld.createJoint(revoluteJointDef2);

I wanted the car to reverse direction when it collided with either the left wall or right wall. In my original code, the car body and the walls were made of rectangle shapes and I was not able to detect the collisions. So I changed the car body and add a left wall and a right wall with sprites and checked for the collisions between these bodies. Fortunately I had done this collision detection in my app “The making of the Dino Pong Android Game”. I was able to check for collisions as shown below .

@Override
protectedvoidonManagedUpdate(finalfloat pSecondsElapsed){
// Check collisions
if(rWall.collidesWith(this)|| lWall.collidesWith(this)){

// On collision reverse speed
rj1.setMotorSpeed(-(rj1.getMotorSpeed()));
rj2.setMotorSpeed(-(rj2.getMotorSpeed()));
}

If you have done all of the above and also managed to utter the magic incantation (which I will not divulge ;-)) you should have a cute running car!  

You can check the video of this simulation at “Modeling a Car using AndEngine & Box2D physics

You can clone the entire project from GitHub at Wheels

   


Take a look at some cool simulations using AndEngine & Box2D
1. Simulating the domino effect using Box2D and AndEngine
2. Bull in a china shop – Behind the scenes in android
3. Simulating an Edge Shape in Android
4. Fun simulation of a Chain in Android
5. “Is it animal? Is it an insect?” in Android
and many more …

Find me on Google+

Simulating a Web Joint in Android

a (1) I got interested in this demo after I saw the Java demo of Box2D physics in Jbox (look in Joints). Moreover my interest in this demo was heightened as the Disney game ‘Cut the rope’ possibly uses some elements of a web joint.

Take a look at the simulation Simulating a Web Joint in Android on Youtube
You can clone the entire project from GitHub at WebJoint

The first task was to create & place Animated Sprites(face) at the corners of a rectangle. I also added distance Joints between them.

Vector2 v1 = new Vector2(p1[0]/PIXEL_TO_METER_RATIO_DEFAULT,p1[1]/PIXEL_TO_METER_RATIO_DEFAULT);

Vector2 v2 = new Vector2(p2[0]/PIXEL_TO_METER_RATIO_DEFAULT,p2[1]/PIXEL_TO_METER_RATIO_DEFAULT);

distanceJoint.initialize(body1, body2, v1, v2);

distanceJoint.collideConnected = true;

distanceJoint.dampingRatio = 1.0f;

distanceJoint.frequencyHz = 10.0f;

this.mPhysicsWorld.createJoint(distanceJoint);

}

I also had to draw connecting lines to represent the joints between the faces The challenge is to update these lines in real time as the bodies oscillate about their mean based on the damping constant. Fortunately I had done this in of my earlier demos “Creating a blob with an attitude”. The key to this is to update the connecting line to the attached bodies through the onUpdate method

@Override

publicvoid onUpdate(finalfloat pSecondsElapsed) {

super.onUpdate(pSecondsElapsed);

if(connectionLine != null)

connectionLine.setPosition(faceA.getX(),faceA.getY(),faceB.getX(),faceB.getY());

}

}

While the Animated Sprites are dynamic bodies I also created 4 pegs (static bodies) that attach to these 4 animated sprites which are suspended in a rectangle formation.

I also added a onAreaTouch listener to enable me to remove bodies interactively. This is a deviation from the demo where the user has to press a key which will remove the bodies in a pre-determined fashin.

To remove the bodies using onAreaTouch was a challenge. So when I remove an Animated Sprite I have to

  1. Remove all connecting lines to the body

  2. Destroy all the joints between the body and other bodies

TO remove the connecting lines I first tried the following

private void removeFace(AnimatedSprite face) {

if(connectionLine1 != null && connectionLine1.collidesWith(face)){

this.mScene.detachChild(connectionLine1);

connectionLine1.dispose();

connectionLine1 = null;

}

if(connectionLine2 != null && connectionLine2.collidesWith(face)){

..

But this did not quite work and it would remove only some of the lines. Then I changed it as follows based on the animated sprite that is being removed in which I specifically remove the connecting lines

if(face.equals(face1)){

Log.d(“Yes”,“Yes”);

destroyLine(connectionLine1);

destroyLine(connectionLine4);

destroyLine(connectionLine5);

}

where destroyLine() is as follow

if(line.isDisposed() == true)

return;

this.mScene.detachChild(line);

final PhysicsConnector linePhysicsConnector= this.mPhysicsWorld.getPhysicsConnectorManager().findPhysicsConnectorByShape(line);

this.mPhysicsWorld.unregisterPhysicsConnector(linePhysicsConnector);

line.dispose();

line = null;

}

To destroy all the distance joints which the bodies has we have to iterate through all of the joints as follows

// Determine all joints connected to Animated Sprite & destroy

ArrayList<JointEdge> jointsEdge = facePhysicsConnector.getBody().getJointList();

for(int i=0; i < jointsEdge.size(); i++){

Joint j = jointsEdge.get(i).joint;

this.mPhysicsWorld.destroyJoint(j);

j=null;

}

Finally the face is removed as follows

this.mPhysicsWorld.unregisterPhysicsConnector(facePhysicsConnector);

this.mPhysicsWorld.destroyBody(facePhysicsConnector.getBody());

this.mScene.unregisterTouchArea(face);

this.mScene.detachChild(face);

Anyway occasionally I do get a SIGSEGV in update thread if I remove face as follows lower right, lower left, upper left. Some orders work well for e.g. Upper left, lower left, lower right etc.

If you figure out what I am missing do let me know.

Take a look at the simulation Simulating a Web Joint in Android

You can clone the entire project from GitHub at WebJoint

Find me on Google+

Simulating an Edge Shape in Android

Here is a small post on how I managed to simulate an Edge Shape in Android. I wanted to do this after I saw the Java demo of Box2D in JBox2D(see RayCast). For the Edge Shape I chose a cosine curve. I used the same method I used, mentioned in my earlier post “Making of the Total Control Android Game

The simulation can be seen at Simulating an Edge Shape on YouTube
You can clone the entire project from Github at EdgeShape.

Since it is a cosine curve I place a ball shape for every point on a cosine function, close to each other to seem continuous and create a body from the Sprite with physical properties.

for (int i = 0; i < nBodies; ++i)

{

float angle = (float) ((10.0 * PI * i)/180.0);

float y1 = 300 + (float)Math.cos(angle/20) * 120;

//Log.d(“Test”,”Test” + “x:” + x1 +”y:”+ y1);

circles[i] = new Sprite(x1, y1, this.mBallTextureRegion, this.getVertexBufferObjectManager());

circlesBody[i] = PhysicsFactory.createCircleBody(this.mPhysicsWorld, circles[i], BodyType.StaticBody, FIXTURE_DEF);

this.mScene.attachChild(circles[i]);

x1 = (float) (x1 + 0.5);

}

So this can be done for every mathematical curve. I also intended to create other curves like the Archimedes Spiral and the Lemniscate. Maybe I will leave that for a rainy day!! 🙂

However, I am not sure how to create a irregular edge shape. I will probably figure that out.

The egde shape is made to be a STATIC_BODY. I then took code of creating Animated Sprites at the point where I touch from AndEngine examples (PhysicsExample.java). To make the simulation more fun I also added a Linear Impulse to the Animated Sprite.

face = new AnimatedSprite(pX, pY, this.mCircleFaceTextureRegion, this.getVertexBufferObjectManager());

body = PhysicsFactory.createCircleBody(this.mPhysicsWorld, face, BodyType.DynamicBody, gameFixtureDef);

face.animate(200);

body.applyLinearImpulse(-200,200,pX,pY);

The effect is better if the phone is horizontal to the ground and not so great if the phone is kept vertical and the bodies do not seem to shoot off.

The simulation can be seen at Simulating an Edge Shape

You can clone the entire project from Github at EdgeShape.


Take a look at some cool simulations using AndEngine & Box2D
1. Simulating the domino effect using Box2D and AndEngine
2. Blob with an attitude(stiffness) in Android
3. The making of Total Control Android game
4. Simulating a Web Joint in Android
20. A closer look at “Robot horse on a Trot! in Android”
and many more …
Find me on Google+

Maximizing enterprise bandwidth by sharing global enterprise-wide network resources

Here is a slightly wild idea of mine

Introduction

Generally in enterprises the network bandwidth available to employees is greatest at the start of the working day and progressively becomes bad as the day progresses. The bandwidth available improves again later in the day. The reason is that the bandwidth demand is highest during the middle portions of the day usually between 10 am – 5pm when the number of employees are the highest. The poor response times during the day are common to many enterprises as the network infrastructure is stretched beyond its designed capacity

Description

This post looks at a novel technique where the increasing bandwidth is ‘outsourced’ to other geographical regions. In other words the increasing bandwidth requirement is ‘borrowed’ from the network infrastructure from other regions.

This idea visualizes the user of a network devoice (Time Zone –Traffic Director Switch) that borrows bandwidth based on the time-of-day and the bandwidth shortage in a particular region. This device effectively borrows the idle network resources (routers, hubs, switches) from other geographical regions thus resolving the bandwidth issue.

In large global organizations, office are spread throughout the world. There will be typical daytimes and night times.  Night time usages will be minimal unless the office works on shifts

Large enterprises typically use leased lines between their various offices spread across the globe. Each of the regional offices will have its own set of routers, Ethernet switches, hubs etc.

 1

The leased lines and the network infrastructure will experience peak usage during the daytime which will subside during the region’s night times. This idea looks at a scheme in which the leased line and the network infrastructure at region B are utilized during the regions’ night times to supplement the bandwidth crunch in region A’s day time

In a typical situation we can view that the enterprise’s region as the center of the network resources (hubs, routers, switches) in its own region. Simplistically we can represent this as shown in Fig 1

 2

This post visualizes the realization of a network device namely the Time Zone-Traffic Director Switch which effectively borrows bandwidth based on the time-of-day and the bandwidth shortage in a particular region.,

This device effectively borrows the idle network resources (routes, hubs switches) from other geographical regions this resolving the bandwidth issue. Such a network device can be implemented using the Open Flow Protocol which can virtualize the network resources

In large cloud computing systems like Facebook, Google, Amazon, which have data centers spread throughout the world, traffic is directed to a data center closest to the user to minimize latency, In this scheme the use of the network resources in other geographical regions may introduce network latencies but will be economically efficient for the enterprises.

In fact this Time Zone-Traffic Director can be realized through the use of the Open Flow Protocol and Software Defined Networks (SDNs)

Detailed Description

This post utilizes a scheme in which the network resources from another are used to supplement the network resources at region during its daytimes. The leased lines and the network resources in other regions during their nights will typically experience low utilization of both the leased line capacity and the network infrastructure capacity. So in this method the bandwidth resources are borrowed from another region where the utilization of the network resources is low. This supplements the bandwidth in the region which is experiencing a bandwidth shortage. This scheme can be realized by the utilization of the Software Defined Network using the Open Flow protocol.

The Open Flow protocol has a Flow Controller which can virtualizes the network resources. This method visualizes virtualizing the network resources of a corporate office that is spread geographically around the world to optimize the corporate’s resources

This is how the scheme will have to be realized

  1. Over dimension the leased line capacity to be at least 30%-40% more than the total capacity of it Ethernet switches gigabit routers etc.  So if the network resource at a region is 16Gbps then the leased line capacity should be of the order of 20Gpbs
  2. When an external site is to be accessed for high speed connection,  after the DNS resolution the packets must be sent to the Time Zone –  Traffic Director Switch
  3. The Time Zone – Traffic Director Switch will determine the bandwidth availability at that time.  Let us assume that the regional network resources are experiencing peak usage It will not decide to use the network resources of another region
  4. The Time Zone – Traffic Director Switch will now check the time of the day.  If it is the ‘regional day’ (e.g. 10 am – 5pm, when the usages is highest) it will hard code the next hop to be a router in another geographical region. SO if the traffic is to originate in Bangalore, the next hop, if there is bandwidth crunch will be in another a router in Europe, or in the US.
  5. The Time Zone – Traffic Director Switch can be realized through th e use of the Open Flow protocol
  6. By artificially redirecting the traffic to another region all packets will be re-routed to use the leased lines & network resources from the other region thus giving the region, Bangalore, in this case, more bandwidth

This can be represented in the following diagram

 3

In the figure below The Time Zone – Traffic Director Switch uses the regions ‘internal’ network resources since it does not face a bandwidth crunch

 3

In the next figure the Time Zone – Traffic Director Switch borrows the network resource from Region B

5

This scheme will introduce additional latency as opposed to the Shorted Path First (SPF) or the Distance Vector Algorithm (DVA) However the enterprise gets to use its network infrastructure more effectively. This will result in the enterprise’s network infrastructure to be used more efficiently and effectively reducing the CAPEX and OPEX for the entire organization.

The entire scheme can be represented by the flow chart below

 6

Conclusion

The tradeoff in this scheme is between the economics of reusing the network and the leased line infrastructure of the enterprise versus the additional latency introduced

However the delay will be more than compensated by the increase in the bandwidth available to the end user. This idea will simultaneously solve the problem of the bandwidth crunch while efficiently and effectively utilizing the network resources across the entire enterprise. This scheme will also reduce the organization CAPEX and OPEX as resources are used more efficiently.

Thoughts?

Find me on Google+

The making of Total Control Android game

tc-1This game of Total Control was one of those games I played when I was a kid when there were no Smartphone or iPods. It was a simple, circular toy with small balls which you had to slowly nudge to the innermost circle. I have been wanting to replicate this game on Android for some time.

The game can be  downloaded from Google Play at Total Control
The Total Control project can be cloned from Git Hub at Total Control

I had decided to use AndEngine & Box2D physics for this. I was under the assumption that creating those concentric circles would be a breeze with AndEngine and Box2D physics. However it took me some time to figure out how to create these circles. Eventually I realized that each circle could be created by computing the circumference of the concentric circle and placing tiny circle bodies. Each of these tiny circles are of type BodyType.StaticBody. So they have physical properties of a ring on which other bodies can roll. With this solved the rest of the implementation was quite straight forward.
– Small colored balls were placed in different spots in the concentric circles.
– Small gaps were created like the real game to move to an inner circle

Finally the whole game uses the Accelaration Sensor and uses Gravity for movement of the balls much like the real game.

tc-2

I also wanted to include AdMob into the game. Here is a good link at WikiHow with all the steps for adding AdMob to your app.

However the above link provides a method of placing the Ad in your desired layout’s XML file. Since my game was based on AndEngine the method to place an Ad in the game uses the FrameLayout. The complete code is given here the AndEngine Forum. To test the working of the Ads make sure you add the code

// REQUEST an ad (Test ad) //
AdRequest adRequest = new AdRequest();
adRequest.addTestDevice(“<Your device Id from the Console”); //Comment this line when publishing
adView.loadAd(adRequest);

You should get your device id when your run your application in Eclipse in the Console tab. When you run the app you should see the Ad. You may have to adjust your app to allow for teh Ad. I had to move and shrink my Game to allow for the Ad display at the bottom.

You can download the game from Google Play at Total Control
The Total Control project can be cloned from Git Hub at Total Control

Find me on Google+

Architecting a cloud based IP Multimedia System (IMS)

Here is an idea of mine that has been slow cooking in my head for more than 1 and a 1/2 year. Finally managed to work its way to IP.com. See link below

Architecting a cloud based IP Multimedia System (IMS) 

The full article is included below

Abstract

This article describes an innovative technique of “cloudifying” the network elements of the IP Multimedia (IMS) framework in order to take advantage of keys benefits of the cloud like elasticity and the utility style pricing. This approach will provide numerous advantages to the Service Provider like better Return-on-Investment(ROI), reduction in capital expenditure and quicker deployment times,  besides offering the end customer benefits like the availability of high speed and imaginative IP multimedia services

Introduction

IP Multimedia Systems (IMS) is the architectural framework proposed by 3GPP body to establish and maintain multimedia sessions using an all IP network. IMS is a grand vision that is access network agnostic, uses an all IP backbone to begin, manage and release multimedia sessions. This is done through network elements called Call Session Control Function (CSCFs), Home Subscriber Systems (HSS) and Application Servers (AS). The CSCFs use SDP over SIP protocol to communicate with other CSCFs and the Application Servers (AS’es). The CSCFs also use DIAMETER to talk to the Home Subscriber System (HSS’es).

Session Initiation Protocol (SIP) is used for signaling between the CSCFs to begin, control and release multi-media sessions and Session Description Protocol (SDP) is used to describe the type of media (voice, video or data). DIAMETER is used by the CSCFs to access the HSS. All these protocols work over IP. The use of an all IP core network for both signaling and transmitting bearer media makes the IMS a very prospective candidate for the cloud system.

This article  proposes a novel technique of “cloudifying” the network elements of the IMS framework (CSCFs) in order to take advantage of the cloud technology for an all IP network. Essentially this idea proposes deploying the CSCFs (P-CSCF, I-CSCF, S-CSCF, BGCF) over a public cloud. The HSS and AS’es can be deployed over a private cloud for security reasons. The above network elements either use SIP/SDP over IP or DIAMETER over IP. Hence these network elements can be deployed as instances on the servers in the cloud with NIC cards. Note: This does not include the Media Gateway Control Function (MGCF) and the Media Gate Way (MGW) as they require SS7 interfaces. Since IP is used between the servers in the cloud the network elements can setup, maintain and release SIP calls over the servers of the cloud. Hence the IMS framework can be effectively “cloudified” by adopting a hybrid solution of public cloud for the CSCF entities and the private cloud for the HSS’es and AS’es.

This idea enables the deployment of IMS and the ability for the Operator, Equipment Manufacturer and the customer to quickly reap the benefits of the IMS vision while minimizing the risk of such a deployment.

Summary

IP Multimedia Systems (IMS) has been in the wings for some time. There have been several deployments by the major equipment manufacturers, but IMS is simply not happening. The vision of IMS is truly grandiose. IMS envisages an all-IP core with several servers known as Call Session Control Function (CSCF) participating to setup, maintain and release of multi-media call sessions. The multi-media sessions can be any combination of voice, data and video.

In the 3GPP Release 5 Architecture IMS draws an architecture of Proxy CSCF (P-CSCF), Serving CSCF(S-CSCF), Interrogating CSCF(I-CSCF), and Breakout CSCF(BGCF), Media Gateway Control Function (MGCF), Home Subscriber Server(HSS) and Application Servers (AS) acting in concert in setting up, maintaining and release media sessions. The main protocols used in IMS are SIP/SDP for managing media sessions which could be voice, data or video and DIAMETER to the HSS.

IMS is also access agnostic and is capable of handling landline or wireless calls over multiple devices from the mobile, laptop, PDA, smartphones or tablet PCs. The application possibilities of IMS are endless from video calling, live multi-player games to video chatting and mobile handoffs of calls from mobile phones to laptop. Despite the numerous possibilities IMS has not made prime time.

The technology has not turned into a money spinner for Operators. One of the reasons may be that Operators are averse to investing enormous amounts into new technology and turning their network upside down.

The IMS framework uses CSCFs which work in concert to setup, manage and release multi media sessions. This is done by using SDP over SIP for signaling and media description. Another very prevalent protocol used in IMS is DIAMETER.  DIAMETER is the protocol that is used for authorizing, authenticating and accounting of subscribers which are maintained in the Home Subscriber System (HSS). All the above protocols namely SDP/SIP and DIAMETER protocols work over IP which makes the entire IMS framework an excellent candidate for deploying on the cloud.

Benefits

There are 6 key benefits that will accrue directly from the above cloud deployment for the IMS. Such a cloud deployment will

i.    Obviate the need for upfront costs for the Operator

ii.    The elasticity and utility style pricing of the cloud will have multiple benefits for the Service Provider and customer

iii.   Provider quicker ROI for the Service Provider by utilizing a innovative business model of revenue-sharing for the Operator and the equipment manufacturer

iv.   Make headway in IP Multimedia Systems

v.   Enable users of the IMS to avail of high speed and imaginative new services combining voice, data, video and mobility.

vi.   The Service Provider can start with a small deployment and grow as the subscriber base and traffic grows in his network

Also, a cloud deployment of the IMS solution has multiple advantages to all the parties involved namely

a)   The Equipment manufacturer

b)   The Service Provider

c)   The customer

A cloud deployment of IMS will serve to break the inertia that Operators have for deploying new architectures in the network.

a)   The Equipment manufactures for e.g. the telecommunication organizations that create the software for the CSCFs can license the applications to the Operators based on innovative business model of revenue sharing with the Operator based on usage

b)   The Service Provider or the Operator does away with the Capital Expenditure (CAPEX) involved in buying CSCFs along with the hardware.  The cost savings can be passed on to the consumers whose video, data or voice calls will be cheaper. Besides, the absence of CAPEX will provide better margins to the operator. A cloud based IMS will also greatly reduce the complexity of dimensioning a core network. Inaccurate dimensioning can result in either over-provisioning or under-provisioning of the network.  Utilizing a cloud for deploying the CSCFs, HSS and AS can obviate the need upfront infrastructure expenses for the Operator. As mentioned above the Service Provider can pay the equipment manufactured based on the number of calls or traffic through the system

c)   Lastly the customer stands to gain as the IMS vision truly allows for high speed multimedia sessions with complex interactions like multi-party video conferencing, handoffs from mobile to laptop or vice versa. Besides IMS also allows for whiteboarding and multi-player gaming sessions.

Also the elasticity of the cloud can be taken advantage of by the Operator who can start small and automatically scale as the user base grows.

Description

This article describes a method in which the Call Session Control Function (CSCFs) namely the P-CSCF, S-CSCF,I-CSCF and BGCF can be deployed on a public cloud.  This is possible because there are no security risks associated with deploying the CSCFs on the public cloud. Moreover the elasticity and the pay per use of the public cloud are excellent attributes for such a cloudifying process. Similarly the HSS’es and AS’es can be deployed on a private cloud.  This is required because the HSS and the AS do have security considerations as they hold important subscriber data like the IMS Public User Identity (IMPU) and the IMS Private User Identity (IMPI).  However, the Media Gateway Control Function (MGCF) and Media Gateway (MGW) are not included this architecture as these 2 elements require SS7 interfaces

Using the cloud for deployment can bring in the benefits of zero upfront costs, utility style charging based on usage and the ability to grow or shrink elastically as the call traffic expands or shrinks.

This is shown diagrammatically below where all the IMS network elements are deployed on a cloud.

In Fig 1., all the network elements are shown as being part of a cloud.

1

Fig 1. Cloudifying the IMS architecture.

Detailed description

This idea requires that the IMS solution be “cloudified “i.e. the P-CSCF, I-CSCF, S-CSCF and the BGCF should be deployed on a public cloud. These CSCFs are used to setup, manage and release calls and the information that is used for the call does not pose any security risk. These network elements use SIP for signaling and SDP over SIP for describing the media sessions. The media sessions can be voice, video or data.

However the HSS and AS which contain the Public User Identity (IMPU) and Private User Identity (IMPI)  and other important data  can be deployed in a private cloud. Hence the IMS solution needs a hybrid solution that uses both the public and private cloud. Besides the proxy SIP servers, Registrars and redirect SIP servers also can be deployed on the public cloud.

The figure Fig 2. below shows how a hybrid cloud solution can be employed for deploying the IMS framework

2

Fig 2: Utilizing a hybrid cloud solution for deploying the IMS architecture

The call from a user typically originated from a SIP phone and will initially reach the P-CSCF. After passing through several SIP servers it will reach a I-CSCF. The I-CSCF will use DIAMETER to query the HSS for the correct S-CSCF to handle the call. Once the S-CSCF is identified the I-CSCF then signals the S-CSCF to reach a terminating a P-CSCF and finally the end user on his SIP phone.  Since the call uses SDP over SIP we can imagine that the call is handled by P-CSCF, I-CSCF, S-CSCF and BGCF instances on the cloud. Each of the CSCFs will have the necessary stacks for communicating to the next CSCF. The CSCF typically use SIP/SDP over TCP or UDP and finally over IP. Moreover query from the I-CSCF or S-CSCF to the HSS will use DIAMTER over UDP/IP.  Since IP is the prevalent technology between servers in the cloud communication between CSCFs is possible.

Methodology

The Call Session Control Functions (CSCFs P-CSCF, I-CSCF, S-CSCF, BGCF) typically handle the setup, maintenance and release of SIP sessions. These CSCFs use either SIP/SDP to communicate to other CSCFs, AS’es or SIP proxies or they use DIAMETER to talk to the HSS. SIP/SDP is used over either the TCP or the UDP protocol.

We can view each of the CSCF, HSS or AS as an application capable of managing SIP or DIAMETER sessions. For this these CSCFs need to maintain different protocol stacks towards other network elements. Since these CSCFs are primarily applications which communicate over IP using protocols over it, it makes eminent sense for deploying these CSCFs over the cloud.

The public cloud contains servers in which instances of applications can run in virtual machines (VMs). These instances can communicate to other instances on other servers using IP. In essence the entire IMS framework can be viewed as CSCF instances which communicate to other CSCF instances, HSS or AS over IP. Hence to setup, maintain and release SIP sessions we can view that instances of P-CSCF, I-CSCF, S-CSCF and B-CSCF executed as separate instances on the servers of a public cloud and communicated using the protocol stacks required for the next network element. The protocol stacks for the different network elements is shown below

The CSCF’s namely the P-CSCF, I-CSCF, S-CSCF & the BGCF all have protocol interfaces that use IP. The detailed protocol stacks for each of these network elements are shown below. Since they communicate over IP the servers need to support 100 Base T Network Interface Cards (NIC) and can typically use RJ-45 connector cables, Hence it is obvious that high performance servers which have 100 Base T NIC cards can be used for hosting the instances of the CSCFs (P-CSCF, I-CSCF, S-CSCF and BGCF). Similarly the private cloud can host the HSS which uses DIAMETER/TCP-SCTP/IP and AS uses SDP/SIP/UDP/IP. Hence these can be deployed on the private cloud.

Network Elements on the Public Cloud

The following network elements will be on the public cloud

a) P-CSCF b) I-CSCF c) S-CSCF d) BGCF

The interfaces of each of the above CSCFs are shown below

a)   Proxy CSCF (P-CSCF) interface

 p

 

As can be seen from above all the interfaces (Gm, Gq, Go and Mw) of the P-CSCF are either UDP/IP or SCTP/TCP/IP.

b)   Interrogating CSCF(I- CSCF) interface

 i

 

As can be seen from above all the interfaces (Cx, Mm and Mw) of the I-CSCF are either UDP/IP or SCTP/TCP/IP.

c)   Serving CSCF (S-CSCF) interfaces

The interfaces of the S-CSCF (Mw, Mg, Mi, Mm, ISC and Cx) are all either UDP/IP or SCTP/TCP/IP

s

d)   Breakout CSCF (BGCF) interface

The interfaces of the BGCF (Mi, Mj, Mk) are all UDP/IP.

bg

Network elements on the private cloud

The following network elements will be on the private cloud

a)   HSS b) AS

a)   Home Subscriber Service (HSS) interface

The HSS interface (Cx) is DIAMETER/SCTP/TCP over IP.

h

b)   Application Server (AS) Interface

a 

The AS interface ISC is SDP/SIP/UDP over IP.

As can be seen the interfaces the different network elements have towards other elements are over either UDP/IP or TCP/IP.

Hence we can readily see that a cloud deployment of the IMS framework is feasible.

Conclusion

claimtoken-515bdc0894cdb

Thus it can be seen that a cloud based IMS deployment is feasible given the IP interface of the CSCFs, HSS and AS. Key features of the cloud like elasticity and utility style charging will be make the service attractive to the Service providers. A cloud based IMS deployment is truly a great combination for all parties involved namely the subscriber, the Operator and the equipment manufactures. A cloud based deployment will allow the Operator to start with a small customer base and grow as the service becomes popular. Besides the irresistibility of IMS’ high speed data and video applications are bound to capture the subscribers imagination while proving a lot cheaper.

Also see my post on “Envisioning a Software Defined Ip Multimedia System (SD-IMS)

Find me on Google+