Monday, November 25, 2013

Missing something.h file while compling/installing a package in linux

This error can be remove just by installing development  package of that particular package.

Wednesday, November 20, 2013

What is REST

Dear All,

Here is a brief explanation about REST(REpresentational State Transfer) as per my understanding.

We have been using Web for years where we fetch/create/update some data using GET,POST or PUT methods. These methods are quite generals and can be applied on almost any resource available over Internet.The REST says that the same idea on which Web works cab be applied between machine to machine interaction. But REST is not limited to these operations only.

In other way, we can think of each Web applications as a state machine having some business logic to make state transitions of the resources. The idea of REST is to map each state transition onto some request to a resource and provide clients with links representing transitions available in the current state. Thus it models the state machine via representations and hyper links. In this way we can think of REST as replacement of RPC(remote procedure call). The advantage of REST over RPC is that REST provide loose coupling where as RPC is tightly coupled. In case of REST client just require a URL(i.e. location of resource) along with some arguments just to specify the next desired state  while in case of RPC, the client must have full domain knowledge of server side.

A good of example of REST is opening a bank account. For opening a bank account you usually go through following process,

1. Go to the bank fill a form and submit to clerk at counter no 1.
2. The clerk will check the form and give a slip back and instruct you to go counter no 2(may be the cashier)
3. Give money to the clerk and clerk will give a slip and instruct you to go the counter no 3
4. At counter 3 clerk sees your slip and give you a passbook.


Here if we replace bank clerk as servers,forms as request and slips as a states of a operations, we can think of a distributed application using REST principle.One more thing here which needs to be mentioned that servers may be in different management domain located far away from each other. In this way, we can have a distributed application involving computation among several heterogeneous machines.

A second example which is a hypothetical but more useful and practical.
Suppose you refrigerator is connected to Web and find that its Milk inventory is low. Now it can to a grocery server located somewhere end of the world. That grocery gives it the local grocery address in form a response containing local grocery store URL. The refrigerator now goes to local store and enquire about milk. The store gives it a number of options probably a list of different milk brands. Now refrigerator choose a milk brands and quantity, the store diverts refrigerator to go to a payment gateway and pay money. After paying money, the gateway may divert refrigerator to the store. Now store confirm order after which delivery may follow. Here a number of state of the same operation(ordering a milk) is involved. If you see closely no server has to remember the all the state. This in compliance with Web which is also stateless.


Here are quick summery of all the above discussion:

1. Web is already is using REST principle.
2. REST  eases communication among machines rather than between machine and human.
3. It is the success of Web that had led people think to extends Web principle and develop REST.
4. REST makes your client as well as server side development quick,easy,scalable,fast and reusable.
5. REST says nothing about technologies involved but since it is inspired by HTTP the obvious choice is HTTP.
6. REST models things as real worlds works in day to day life.


Ref:
1. http://www.looah.com/source/view/2284
2. http://www.quora.com/What-is-REST-in-laymans-terms
3. http://stackoverflow.com/questions/209905/representational-state-transfer-rest-and-simple-object-access-protocol-soap
4. http://www.sharedd.com/iamlayman/2012/10/29/when-should-i-rest/

Thanks and Regards
Lalit Patel

Tuesday, October 1, 2013

Sendto Failed Operation not permitted error

Usually this error happen when you firewall is blocking your application.

Wednesday, September 11, 2013

using iperf for monitoring end to end throughput

Dear All,

Sometime we need to monitor end to end throughput. Iperf utility comes very handy in these scenario. So how to use iperf. First install iperf  after downloading rpm from this link

http://pkgs.repoforge.org/iperf/

Just use the following command to installed

rpm -ivh iperf.rpm

Now you will get bin file iperf

use following command to check throughput

i) At server side

iperf -s   


ii) At client side

iperf -c 10.10.10.10

For increasing window size use following command

iperf -c 10.10.10.10 -w 40960

For finding throughput in both direction us following command

iperf -c 10.10.10.10 -r

Sunday, September 8, 2013

Auto-negotiation fails between links having Fiber SFP connector interface

Dear All,

Last day I had a big headache because of the above mentioned problem. So always try to avoid putting the interface in auto-negotiation mode.

Monday, August 26, 2013

Lets use Python or Ruby

Hi All,

I suggest everybody to use Python or Ruby for programming everything because python/ruby require less code which in turn means less chances of bug. Yes Python is little bit slower than C but that can be compensated by using a high end server class machine.

Wednesday, August 21, 2013

Where to put index in a database

Hi All,
Index are used for faster searching. Just as in Books, index helps us to find a topic fast. Similarly we use index on a database table to make our query fast. Now the question is on which column we should put index. Answer is quite obvious from book example. We should put out index on the column which is used for searching. Suppose you have a employee table with  columns as employee_id,name,email,salary,address,last_updated etc. Now if you frequently query employee table as "select * from employee where name='x'" then you should be put index on column "name".

Tuesday, July 30, 2013

Difference between MPLS VRF and MPLS VPN

Dear All,
Please do not confuse with MPLS terminology. MPLS VRF(Virtual Router Forwarding Instance) is just a virtual router  consisting of one or more number of interfaces. When two or more VRF joins then a VPN is formed. Here joins means sharing the route tables so that they can communicate with each other.
VRF is distinguished by RD(Router Distinguisher). When a VRF import and export routes from another VRF, the virtual router's routing table get exchanged. After that two VRF can communicate with each other. In this case we can say that above two VRF are part of same VPN.



What do SNMP MIB table indexes stands for ?

Dear All,
I just came across a problem where I need to access MIB tables. For accessing any table in SNMP at least one index is there. So what is this index?
Here meaning of index is same as book index you find at the end of the books.
So every table leafs has a OID(Object Identifier which gives the location of managed object data in the MIB tree data structure) and all index must be appended in sequential order to the get the actual row data in the table. For example take interface table with entry OID(.1.3.6.1.2.1.2.2.1) in standard MIB-II. To access a row in the interface table you need to append interface number to the leaf OID. Like you want to access interface description of second interface then you need query OID (.1.3.6.1.2.1.2.2.1.2.2) using GET SNMP commands. Other way to fetch entire MIB table is to use GetTable command. Although GetTable command is not a standard command but many SNMP implementation like(NetSNMP, SNMP4J etc) support it.

Sunday, July 28, 2013

Difference between Switch and Bridge

Switch is just multi-port bridge

Wednesday, July 24, 2013

What is Multiprotocol Label Switching (MPLS)

MPLS (Multiprotocol Label Switching) is a new TCP/IP protocol which forward packets based on a 32 bit-labels inserted between Layer 2 and Layer 3 header. The basic idea behind MPLS is based on two paradigm:-

1. Layer 2 Switching is faster than Layer 3 Routing i.e. Switching is faster than Routing:-
The reason behind this is that in case routing the router has to read all routing table to route any packet excluding broadcast and multicast packets. So the complexity level will be O(n). While in case of Layer 2 switching any first match is sufficient to forward the packet. So in case of switching the complexity will be of order O(n/2).

2. Circuit switching is more reliable and faster that packet switching:-
There is most obvious thing. When Internet was designed,the existing network links were unreliable. So it was thought that each packet may traverse through different path. Keeping in view of that all mandatory information for routing(Source and Destination address) was kept with every packet. But now-a-days links are becoming more and more reliable with each passing years. So Circuit Switching concept was brought back in Internet in the form of MPLS. Circuit switching involve less overhead of routing and therefore faster than packet switching.

How MPLS works:-  MPLS forward the packet based on label only. It like the shopping of food items. When you go shopping for food item you see the label for identifying whether this item is made of VEG stuffs or NON-VEG stuffs. So in this process you may skip reading of contents of that food. This makes you life easier. Recently, SEBI has mandated mutual fund  houses to put label on their mutual fund products based on risk involved so that by merely looking at you will come to know whether this mutual fund is suitable for you or not.

A MPLS Router can assume three role
1. Provider Edge(PE) Router:- This router reads the packet and determine its forward equivalence class,put a label and forward it other MPLS router. It also remove label and forward the normal IP packets.
2. Provider (P) Router:- These are backbone router and forwards packets based on labels only.

In simple word, MPLS first identify a flow(most probably based on destination address) insert a tag or label and forward the packet in MPLS network. In between MPLS network packet forwarding takes place based on label only. At exit end of the network the router removes the label and send the plain IP packet to the user.

Now the question arises how the label switching works. MPLS first forms Label Switched Path(quite similar to Circuit switching path) using an underlying routing protocol OSPF or BGP. In principle, OSPF/BGP helps a MPLS router to calculate a Forward Equivalence Class(FEC) which in turn is used to classify the packets for labels to inserted. Label has only local significance to a link i.e. same label may reused at others link also.


Out of 32 bit of label, only 20 bit is used for actual label. 3 bit is used for Experimental purpose. It will further used for importing differentiated service field of IP packet. This field can be used later on to provide QoS. S bit indicate end of stack label. The idea here is that there may be multiple label inserted in between in order to have higher level of aggregation of traffic in the MPLS network.When a packet comes to a MPLS enabled router, it can either PUSH,POP or swap a label. The S bit show the lowest label. The last 8 bit is used for TTL field. This TTL field is same as IP packet. The purpose for TTL bit is same as in IP packet to drop a packet from traversing infinitely in the network in case of looping.

Importance of Loopback address in network management using SNMP protocol

One of my colleague asked why do we require Loopback IP address for managing a network device(Router,Switch Modem etc) using SNMP protocol. There are several reasons for that:-
1. Since loopback is software based address, it will be always up. Therefore as long as device is up and reachable through any of its interface, we will get SNMP response by polling the Loopback address.
2. If you choose any other interface IP other than Loopback and if that interface goes down, the SNMP query will fail. In this scenario, even though your device/machine is up, you will get wrong information that machine is down.
3. In case of Desktop, you do not require a separate Loopback because usually desktop has only one cable connecting it network.
4. Loopback address provides unique identity to the network device which can be used as primary key in management database.
5. So if a device has multiple connectivity it is always better to use Loopback address as management address for all management purpose including TELNET and SSH.

Thursday, July 18, 2013

How to clone a table row dynamically in HTML

Hi All,

Recently I got into a problem where I had to clone the first row of a table. So I used jquery to get the html code of first row and append it to desired location
Here is code snippt:

$line = $('table tbody tr:first').html();
$(table).find("tbody tr:first").after($line);

While cloning tr tag is not cloned so you need to append it before final appending of code to the desired location. Also you may put these code in some function which needs to be called every time you need to add row.

regards
lalit

Friday, March 8, 2013

OpenBSD bridge port

To make a bridge port in OpenBSD. You have to do the following things

1. Create a file called /etc/hostname.bridge0,  and add the following line:
            add [interface name1]
            add [interface name2]
            up
2. In indiual interface files /etc/hostname.[interface name] either put IP or following line
        up media autoselect
   for IP write following line
        inet [ip address] [netmask] [broadcast address]

Source:
http://www.cyberciti.biz/faq/setting-up-a-network-bridge-in-openbsd/
   
       

Wednesday, March 6, 2013

openBSD firewall NAT rules

1. Source NAT rule:

pass out on [external interface name] from [internal interface name]:network to any nat-to [external interface name]

2. Destination NAT rule:

pass in on [external interface name] proto tcp from [external source ip] to any port 80  rdr-to [internal dst interface]

Also you need to add alias IP at external interface to take care of arp request. The sample config(/etc/hostname.[interface name] for interface is as following

 inet [ipaddress] [mask ] [broadcast address]
 for alias ip add the following line
inet alias  [ipaddress] [mask] [broadcast address]