Monday, September 5, 2016

IPv6 Notes


Type if IPv6 Addressing modes:
1) Unicast addresses
2) Multicast addresses
3) Anycast addresses

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes

ff02::2 ip6-allrouters

Special Address in IPv6:
  1. Global addresses
  2. Link-local addresses
  3. Site-local addresses
  4. Unique local addresses (ULA’s)
  5. IPv4 mapped IPv6 addresses
  6. IPv4 compatible IPv6 addresses
  7. Special unicast addresses
  8. Multicast addresses
Reference: Please see RFC 1884 - IP Version 6 Addressing Architecture for more information. 

1.Global unicast addresses:
Address scope is the whole IPv6 Internet, Equivalent to public IPv4 addresses
Defined in RFC 3587:
2001:DB8::/32 – documentation-only prefix

2.Link-local addresses:


fe80::/10 This is a link-local prefix offered by IPv6. This address prefix signifies that the address is valid only in the local physical link.
Automatically configured on an interface using MAC address , Address scope is limited to the local link and shall used to send neighbor solicit messages

Eg: if MAC Address(48bits):                                                 00:90:27:17:FC:0F 
MAC Convert to colon hexadecimal notation :            ::0290:27FF:FE17:FC0F
The link-local address for the host is:                 FE80::0290:27FF:FE17:FC0F

3. Site-local addresses : Depricated and replaced by Unique local addresses

4. Unique local addresses(ULA):

fc00::/7 This is called the Unique Local Address (ULA). These addresses are routed only within a set of cooperating sites. These were introduced in the IPv6 to replace the site-local addresses. These addresses also provide a 40-bit pseudorandom number that reduces the risk of address conflicts.
Globally unique and are intended for local communications
Not routable on global Internet, routable within organization
Replaced the site-local addresses
Global scope, no zone ID required 

Defined in RFC 4193

5. IPv4 mapped IPv6 address:
Used by IPv6 only application to be able to deal with IPv4
requests.  Requires dual stack configured on the host. Defined in RFC 4291

Example:  IPv4-mapped IPv6 address for the IPv4 address 192.168.0.189 is:

0:0:0:0:0:FFFF:192.168.0.189 = ::FFFF:c0a8:bd

6. IPv4 Compatible IPv6 Address:
::/96 The zero prefix denotes addresses that are compatible with the previously used IPv4 protocol.

Used by IPv6 only application to be able to deal with IPv4 requests. Requires dual stack configured on the host

Example:  IPv4-comaptible IPv6 address for the IPv4 address 192.168.0.189 is: 
0:0:0:0:0:0:192.168.0.189  = ::C0A8:BD

7.Special unicast addresses:


::1/128 This is called the loop back address and is used to refer to the local host. An application sending a packet to this address will get the packet back after it is looped back by the IPv6 stack. The local host address in the IPv4 was 127.0.0.1 . 
Loopback unicast address – 0:0:0:0:0:0:0:1 = ::1
Similar to IPv4 address 127.0.0.1
Used by a node to send an IPv6 packet to itself
Should not be assigned to any physical interface


::/128 An IPv6 address with all zeroes in it is referred to as an unspecified address and is used for addressing purposes within a software. 
Unspecified unicast address – 0:0:0:0:0:0:0:0 = ::
Similar to the IPv4 address 0.0.0.0
Indicates the absence of an address


2001:db8::/32 This is a documentation prefix allowed in the IPv6. All the examples of IPv6 addresses should ideally use this prefix to indicate that it is an example.

8.Multicast IPv6 addresses:


ff00::/8 This prefix is offered by IPv6 to denote the multicast addresses. Any address carrying this prefix is automatically understood to be a multicast address. 

An identifier for a set of interfaces (typically on different nodes). Defined in RFC 4291.
Some reserved multicast addresses:

FF02::1 (link-local scope, all nodes on the link)
FF02::2 (link-local scope, all routers on the link)
FF05::2 (site-local scope, all routers in the site)

FF02:0:0:0:0:1:FFXX:XXXX (Solicited-node multicast address)

Tunneling:
Encapsulating IPV6 packets into IPV4 packets.IPV6 packets becomes the payload part of the IPV4 packets. It is called 6-to-4 tunnelling.

Neighbor Discovery Replaces ARP (Address Resolution Protocol):
Refs: http://ipv6.com/articles/general/Stateless-Auto-Configuration.htm

Example: TP link configuration of DHCP http://www.tplink.com/be/article/?faqid=855

a) Router Solicitation (request something): 
Send by host to routers with src address is the link-local address of the host and destination address is FF02::2

b) Router Advertisement: 
Send by routers periodically or in response to a Router Solicitation message, Source address is the link-local address of the sending router and Destination address is the unicast address of a node that sent a Router Solicitation or FF02::1

Stateless Address  Auto congiuration (SLAAC):
https://supportforums.cisco.com/document/97586/dynamic-address-assignment-ipv6-using-slaac-and-dhcp
http://www.ciscopress.com/articles/article.asp?p=2154680

Lets Hands on:
  • On Windows client:
    • netsh interface ipv6 install/uninstall
      • IPv6 is installed and enabled by default on Windows Vista and Windows 2008 Server
    • netsh interface ipv6 add address "Local Area Connection" fd00::c0a8:64
  • On Linux client:
    • ifconfig  eth0 inet6 add fd00::c0a8:c7/64
  • On Solaris client:
    • ifconfig e1000g0 inet6 addif  fd00:1:11:5a:214:4fff:fe86:1111/64 up

Experiences:
$ ping6 -I wlan0 fe80::3602:86ff:fe63:3b0c      == My link-local ip
PING fe80::3602:86ff:fe63:3b0c(fe80::3602:86ff:fe63:3b0c) from fe80::3602:86ff:fe63:3b0c wlan0: 56 data bytes

64 bytes from fe80::3602:86ff:fe63:3b0c: icmp_seq=1 ttl=64 time=0.038 ms

$ping6 -I wlan0 ip6-allrouters -n   
Routers responded back

Monday, May 23, 2016

XAMPP PHP errors


Sample : info.php to test PHP version <!--php // Show all information, defaults to INFO_ALL phpinfo(); // Show just the module information. // phpinfo(8) yields identical results. phpinfo(INFO_MODULES); ?--> Enable error on html Error #1: File not fount error <br/> <b>Warning</b>: simplexml_load_file(): I/O warning : failed to load external entity "../data/asset.xml" in <b>E:\xampp\htdocs\NFPDL\live\php\getAssetMenuListJson.php</b> on line <b>78</b><br /> <br/>

Tuesday, March 1, 2016

JavaScript: Quick reference



function logt(msg)
{
  if(navigator.appName == "Netscape")
    console.log("[DBG]: " + msg);
  else
    alert("[DBG]: " + msg);
}
------------Method to convert secs to HH MM SS --------------------------------
function getSecsInHHMMSS(secs){
    var hh = ("0" + Math.floor(secs/3600)).slice(-2);
    var mm = ("0" + Math.floor((secs%3600)/60)).slice(-2);
    var ss = ("0" + Math.floor((secs%3600)%60)).slice(-2);
    var hhmmss=hh+":"+mm+":"+ss;
    return hhmmss.toString();
}
//getSecsInHHMMSS(100) will returns  00:01:40

-------------Method to parse the query string --------------------------------------
function getQueryValue(variable) {
    var query = window.location.search.substring(1);
    var vars = query.split('&');
    for (var i = 0; i < vars.length; i++) {
        var pair = vars[i].split('=');
        if (decodeURIComponent(pair[0]) == variable) {
            return decodeURIComponent(pair[1]);
        }
    }
    logt('Query not found :'+variable);
    return "";
}

//Now make a request to index.html?mins=120
durr=getQueryValue('mins') * 60;
document.getElementById("endtime").innerHTML = getSecsInHHMMSS(durr);

-------------Method to print Key name of JSON obj using values -----------

//This defines a method called getKeyByValue() to any object which
// returns the Key name using value of JSON format
Object.prototype.getKeyByValue = function( value ) {
    for( var prop in this ) {
        if( this.hasOwnProperty( prop ) ) {
             if( this[ prop ] === value )
                 return prop;
        }
    }
}

var test = { Key1:11, Key2:22, Key3:33 }
alert(test.getKeyByValue (33))   # This will print "Key3"