Tuesday, 14 May 2013

External Linkage

Here let us discuss about  what is external linkage ? .

In global scope, identifiers for the following kinds of entities declared without the static storage class specifier have external linkage:
  • Anobject --- variable
  • A function -- always external, there is no function can be defined within another function 
External linkage is just a linkage for the function declared in another file, means references to the same name..


We can do consider soft links - can say symbolic soft link

ln -s dest src file

here we create symbolic link for the file exists. it just a replicate of existing file, for convenient and version library changes we create symbolic links .. however the reference to the library is same ...

I think this would be best example for the external linkage ..

External linkage - is a linkage to the global scope identities declared on different files.

Ex:  extern int sum(int); extern int number;

 

Sunday, 20 January 2013

Gratuitous ARP (GARP)

I just come across new type in ARP, i.e GARP -> ARP Announcement .

This is very interesting message type,

Here i am assuming that person reading this article knowing about ARP and uses of ARP.

I am discussing about GARP called as ARP announcement.


Gratuitous ARPs (GARP) are useful for four reasons:
  • They can help detect IP conflicts. When a machine receives an ARP request containing a source IP that matches its own, then it knows there is an IP conflict.
  • They assist in the updating of other machines' ARP tables. Clustering solutions utilize this when they move an IP from one NIC to another, or from one machine to another. Other machines maintain an ARP table that contains the MAC associated with an IP. When the cluster needs to move the IP to a different NIC, be it on the same machine or a different one, it reconfigures the NICs appropriately then broadcasts a gratuitous ARP reply to inform the neighboring machines about the change in MAC for the IP. Machines receiving the ARP packet then update their ARP tables with the new MAC.
  • They inform switches of the MAC address of the machine on a given switch port, so that the switch knows that it should transmit packets sent to that MAC address on that switch port.
  • Every time an IP interface or link goes up, the driver for that interface will typically send a gratuitous ARP to preload the ARP tables of all other local hosts. Thus, a gratuitous ARP will tell us that that host just has had a link up event, such as a link bounce, a machine just being rebooted or the user/sysadmin on that host just configuring the interface up. If we see multiple gratuitous ARPs from the same host frequently, it can be an indication of bad Ethernet hardware/cabling resulting in frequent link bounces. 

Example with Traffic Flow Following as,

  • Two nodes in a cluster are configured to share a common IP address 192.168.1.1. Node A has a hardware address of 01:01:01:01:01:01 and node B has a hardware address of 02:02:02:02:02:02.
  • Assume that node A currently has IP address 192.168.1.1 already configured on its NIC. At this point, neighboring devices know to contact 192.168.1.1 using the MAC 01:01:01:01:01:01.
  • Using the heartbeat protocol, node B determines that node A has died.
  • Node B configures a secondary IP on an interface with ifconfig eth0:1 192.168.1.1.
  • Node B issues a gratuitous ARP with send_arp eth0 192.168.1.1 02:02:02:02:02:02 192.168.1.255. All devices receiving this ARP update their table to point to 02:02:02:02:02:02 for the IP address 192.168.1.1.

As a conclusion, GARP is mainly used for avoid IP Conflict, maintaining ARP cache entries with proper mac address applying ARP announcement, whenever interface/server/port got replied with new hardware assigning same IP Address.


Thanks.

Let me know for any clarification required.

Thursday, 17 January 2013

IPv4 Multicast Valid Range Addressing

IPv4 Multicast Group Address should be belongs to any of the range between,

starting from 224 to 239 , rest of ranges can't be accepted as IPv4 Multicast Group Valid Addressses

Ex: 224.0.0.0/24 to 239.0.0.0/24


By the what is multicast means

A Simple Real time example:
---------------------------

Multicast can describe follows, Being member of mailing group, whenever some one post message to that group, the person part of the group too receives mail. 

Ex: group name: xyz
members:
 john
arun
rahul
ram
..etc

here members are physically present, they have their own characteristics, whereas group name: xyz, no one present, it means that its a logical address, mapped with subscribed members.

therefore whenever there is a message post to a group xyz all the members would be getting a message.

Thanks.

let me know for any clarifications.

Tuesday, 8 January 2013

IPv6 Multicast Group Addressing

Following are the learning from RFC about IPv6 Multicast Group Addressing

Learning IPv6

rfc4291:
=======

The type of an IPv6 address is identified by the high-order bits of
   the address, as follows:

      Address type         Binary prefix        IPv6 notation   Section
      ------------         -------------        -------------   -------
      Unspecified          00...0  (128 bits)   ::/128          2.5.2
      Loopback             00...1  (128 bits)   ::1/128         2.5.3
      Multicast            11111111             FF00::/8        2.7
      Link-Local unicast   1111111010           FE80::/10       2.5.6
      Global Unicast       (everything else)

       An IPv6 multicast address is an identifier for a group of interfaces
   (typically on different nodes).  An interface may belong to any
   number of multicast groups.  Multicast addresses have the following
   format:

   |   8    |  4 |  4 |                  112 bits                   |
   +------ -+----+----+---------------------------------------------+
   |11111111|flgs|scop|                  group ID                   |
   +--------+----+----+---------------------------------------------+

      binary 11111111 at the start of the address identifies the address
      as being a multicast address.

                                    +-+-+-+-+
      flgs is a set of 4 flags:     |0|R|P|T|
                                    +-+-+-+-+

         The high-order flag is reserved, and must be initialized to 0.

         T = 0 indicates a permanently-assigned ("well-known") multicast
         address, assigned by the Internet Assigned Numbers Authority
         (IANA).

         T = 1 indicates a non-permanently-assigned ("transient" or
         "dynamically" assigned) multicast address.
       
       
         out of 112 bits - 80 bits unused must be "zeros"
         rest 32 bits - used for group id



Unicast-Prefix-based IPv6 Multicast Addresses
===============================================
 
   |   8    |  4 |  4 |   8    |    8   |       64       |    32    |
      +--------+----+----+--------+--------+----------------+----------+
      |11111111|flgs|scop|reserved|  plen  | network prefix | group ID |
      +--------+----+----+--------+--------+----------------+----------+

                                   +-+-+-+-+
   flgs is a set of 4 flags:       |0|0|P|T|
                                   +-+-+-+-+

         o  P = 0 indicates a multicast address that is not assigned
            based on the network prefix.

         o  P = 1 indicates a multicast address that is assigned based
            on the network prefix.

         o  If P = 1, T MUST be set to 1
          plen indicates the actual number of bits in the network prefix field
          that identify the subnet when P = 1.
         
          network prefix identifies the network prefix of the unicast subnet
            owning the multicast address.  If P = 1, this field contains the
            unicast network prefix assigned to the domain owning, or allocating,
            the multicast address.  All non-significant bits of the network
            prefix field SHOULD be zero.
           
   It should be noted that the Interface Identifier requirements in
   Section 2.5.1 of [ADDRARCH] effectively restrict the length of the
   unicast prefix to 64 bits, hence the network prefix portion of the
   multicast address will be at most 64 bits.

   Group ID is set based on the guidelines outlined in [IPV6 GID].

   The scope of the unicast-prefix based multicast address MUST NOT
   exceed the scope of the unicast prefix embedded in the multicast
   address.
  
  
Embedding the Rendezvous Point (RP) Address                  
in an IPv6 Multicast Address


FF01 to FF0F are well defined multicast ipv6 address family
first 8 bit always should be '1' - for multicast addressing
next 4 bit - 0
next 4 bit  follows notation defined scope

-  0  reserved
            1  interface-local scope
            2  link-local scope
            3  reserved
            4  admin-local scope
            5  site-local scope
            6  (unassigned)
            7  (unassigned)
            8  organization-local scope
            9  (unassigned)
            A  (unassigned)
            B  (unassigned)
            C  (unassigned)
            D  (unassigned)
            E  global scope
            F  reserved


1'st 16bits
===========
FF - 8bit

4it flag
0,1,2,3,5,7 - allowed
4 - can't be

4it - scope
0 to F out of which 0,3,f are reserved

2nd 16bits
==========

8 bit reserved case of unicase prefix based/ rvcd,RRId in case of ext embedding RP
8 bit pem  - used for subnet

3,4,5,6th 16bits
===================
In case unicast prefix based  used as - Network Prefix
All bits are zeros - normally

specially 6th 16bit - can be value as '1' for defined IANA addresses

7,8th 16bits
============
Group ID - can be 32bit mac address based EUI format how system create link local ip address based on mac

8th 16bit - can't be zero - which is reserved
             and can't be 100 to 12A
             7,8th 16 bits can't be 2:7ffd/e/f, 8000,ffff
           
           




Tuesday, 27 November 2012

How To Tag Source

The following are the steps which will be useful to tag the source,

1. Go to your root directory of source bed
  Ex: cd /app/src/main_src/

 2. execute ctags -R
  if it is not working
 do which ctags , get the path of it and then execute by following ,
ex:
/usr/bin/ctags -R

3. now you could see  file "tags" created in your root src dir
4. now set tags for your vim

 open your vimrc file

vi ~/.vimrc
set tags=/app/src/main_src/tags

:wq

5. from now where ever your are in your src, you can get the func definition by "ctrl + ]" to get back "ctrl + t"

Enjoy the tagging ..!!

Let me know in case of  help required ..



Thursday, 18 October 2012

How to install Klocwork in linux


*****************How to Install Klocwork in Local Server?*********************************

1) Create a user and group (klocwork/klocwork123)
2) Login into the machine using above user and password.
3) create a directory klocwork_9.2 (mkdir klocwork_9.2)
4) Copy kw-server-installer.9.2.1.7276.linux.sh to klocwork_9.2 folder.
5) chmod 755 *.sh
6) Create kwtables, kw92 and kwdata directory in klocwork_9.2 folder(eg : mkdir kw82 kwdata)
7) Run kw-server-installer.9.2.1.7276.linux.sh
(eg: ./kw-server-installer.9.2.1.7276.linux.sh -a -i /home/klocwork/klocwork_9.2/kw92/ -p /home/klocwork/klocwork_9.2/kwdata/
8) open bashrc and export klocwork binary paths.
(eg: export PATH=$PATH:/home/klocwork/klocwork_9.2/kw92/bin/)
9) save bashrc file and run it( source ~/.bashrc)
10) kwservice set-service-property <path to kwdata> license host <license machine ip address>
(eg: ./kwservice set-service-property /home/klocwork/klocwork_9.2/kwdata/ license host 172.16.1.151
11) cd ..
12)chmod 755 *.sh
13) Install kw-user-installer.9.2.1.7276.linux.sh
(eg:./kw-user-installer.9.2.1.7276.linux.sh /home/klocwork/klocwork_9.2_Client/)
14) Enter then type Yes again Enter
15) After Installation is over open .bashrc and add client bin path
(eg:/home/klocwork/klocwork_9.2_Client_New/bin/)
****now your export path is :export PATH=$PATH:/home/klocwork/Klocwork9.2/kw92/bin/:/home/klocwork/klocwork_9.2_Client_New/bin/
16) save bashrc and run (source .bashrc)
17) Go to kwdata/config folder (eg :/home/klocwork/Klocwork9.2/kwdata/config)
18) Open admin.conf file
19) Change project.host , project.java.rmi.server.hostname , web.host, database.host as Ip address of Klockwork installing machine.
20) If project.java.rmi.server.hostname is not present in admin.conf add it ( *its not mandatory)
21) Change license.host = IP Address of License Server.(172.16.1.151)
22) If Required change web port .
23) Save the admin.conf
24) kwservice start <path to kwdata>
(eg: kwservice start /home/klocwork/klocwork_9.2/kwdata/ )
25) Now License Server, Database Server , Project Server and Web Server should start.
    Change the port-adress of database.port to some other port if  default 3306 is used by default mysql already installed in the system.
    Webserver is the klocserver.
    project server is the project_root installed in the machine.
   
26) If databse /project/web server is not starting check these ports are already using or not ?
****if is its using change the port and start again.
27) if any problem for starting License server contact klocwork admin
28) open gui http://ipaddressof klocwork installed machine:webport
(eg:http://172.19.1.61:8072)
29) open gui in another way also go to <path of kw92/bin> ./kmc
(eg:/home/klocwork/klocwork_9.2/kw92/bin)
****before starting kmc install cigwin or any other tool

*****************To work with KlocWork*********************


Once the installation is done now to work with the code fallow the fallowing procedure.


1)Go to the sourcecode folder, here we need to generate build specification file. Use the fallowing command
to generate build.spec file
    kwinject -o build.spec make
    The above command uses make file in the source code folder and complies and generates specification file.
    Dont forget to do make clean before to do make.
2)Run KMC in command window using command kmc. This will invoke a GUI tool where we can create project and build it.
3)To create project, go to file->New project, Name the project and select the language  click next.

4) In the next window select Build From Build Specification files click add, browse for the build specification file that you have done in step 1.

5)Click Next.
6)Select the options in the next window and click finish.
7)On the left side of the UI you will project list, right click on your project click on build. This step intiates building of recent build version.

8)UI will asks for KlocWorks Tables Directory, Select  Reuse Tables Directory and browse for the tables directory path /home/klocwork/klocwork_9.2/kwtables/ and click build.

9)Your code starts building and the process will take some time. After completion of successful build you can see the reports on the browser.

10)Open the browser with klocServer ip addess (ex: http://172.19.3.178:8080) and select Klocwork Review. UI asks username and password. username is admin and no password.

11)UI will load the complete list of projects, select your coressponding project to view reports.






How To Configure Yum in Linux

cat /etc/yum.repos.d/local.repo
[localrepos]
name=Local Repository
baseurl=file://///mnt/disk
enabled=1
gpgcheck=0

#Here consider that RHEL ISO file being mounted in /mnt/disk directory

#Either we can mount using NFS too to configure Yum Path

Command to mount ISO file in linux

mount -o loop file.iso /mnt/disk