DIAMETER message format

A Diameter message consists of a fixed-length 20-octet header followed by a variable
number of AVPs (Attributed Value Pair). T

 The Version field indicates the Diameter protocol version and is set to 1 for now.
 The Command flags field specifies 4 flags for now:

  •  R flag (stands for Request) shows whether the message is a request or a response. 
  •  P flag (stands for Proxiable) shows if the message can be proxied, relayed or redirected or it must be locally processed. 
  •  E flag (stands for Error) to show if the message contains protocol or semantic errors. When a request message generates a protocol error an answer message is sent back with the ‘‘E’’ bit set in the Diameter header, indicating a protocol error. 
  • T flag to show that a message can potentially be a retransmitted message after a link fail-over or is used to aid removal of duplicate messages. 
  •  r : these flag bits are reserved for future use, and must be set to zero, and ignored by the receiver. 


 The command code value indicates the command associated with the message, such as “credit-control-request ” or “accounting-request”, and so on. Every Diameter message must contain a command code so that the receiver can determine what action it needs to take for each message. The command code is the same of the request and its corresponding answer.


  •  Application ID identifies the specific application the message is used for, such as S6a/S6d between MME and HSS, Gx between PCEF and PCR, etc. 
  • Hop-by-hop identifier field carries an identifier that is used to match request and responses over that hop. The sender of the request must ensure that the identifier is unique over the connection on that hop at any given time. The sender of a response must ensure that the identifier value is the same as that in the corresponding request. . The Hop-by-Hop identifier is normally a monotonically increasing number, whose start value was randomly generated. An answer message that is received with an unknown Hop-byHop Identifier must be discarded. Hop-by-Hop identifier allows a Diameter response to follow the same route as the corresponding Diameter request. 
  • End-to-end identifier is an identifier used to detect duplicate messages. The identifier in a response message must match the identifier in the corresponding request message. The identifier must remain locally unique for at least 4 minutes. This identifier and the OriginHost AVP are used together to detect message duplicates. Note duplicate request could cause duplicate responses but the duplications must not affect any states that were created by the original reques

What is diameter protocol? Explain

The RADIUS protocol (Remote Access Dial In User Services) has been widely and successfully deployed to provide authentication, authorization, and accounting (AAA) services for dial-up PPP/IP and Mobile IP access. However, inherent shortcomings of the RADIUS protocol have limited its ability to adapt to the ever-increasing capabilities of routers and network access servers, and the ever-expanding set of desired AAA services. A number of working groups have specified their requirements for AAA protocols, and these requirements drove the design of the Diameter protocol. The Roaming Operations (ROAMOPS) Working Group of the IETF published a set of requirements for roaming networks. The NAS Requirements (NASREQ) Working Group of the IETF documented the next generation NAS AAA requirements. The Mobile IP Working Group of the IETF documented AAA requirements that would help Mobile IP scale for Inter-Domain mobility. The Telecommunication Industry Association (TIA) TR-45.6 Adjunct Wireless Packet Data Technology working group documented the CDMA2000 Wireless Data Requirements for AAA. Based on the work of TR-45.6, 3GPP2 has specified a two phased architecture for supporting Wireless IP networking based on IETF protocols;the second phase requiring AAA functionality not supportable in RADIUS. Diameter was specifically designed to meet the requirements indicated by these various groups.Diameter is currently focused on, and limited to, supporting access to IP networks. The Diameter protocol was designed as an improved version of the RADIUS protocol. A goal was to maximize compatibility and ease migration from RADIUS to Diameter.For example, a Diameter message, like a RADIUS message, conveys a collection of attribute value pairs. Diameter is defined in terms of a base protocol and a set of applications. This design allows the protocol to be extended to new access technologies. The base protocol provides basic mechanisms for reliable transport, message delivery, and error handling.

DIAMETER ADVANTAGES OVER RADIUS

Better Transport Diameter runs over a reliable transport, TCP or SCTP. Lost packets are retransmitted at each hop. A persistent connection with an application-level heartbeat message (called a Watchdog message) supports timely failover. TCP and SCTP adapt to network congestion. Better Proxying Hop-by-hop transport failure detection allows failover to occur at the appropriate place — proxies can locally failover to an alternate next-hop peer. The proxy automatically does retransmission of pending request messages following a failover. An AVP that identifies the ultimate destination allows multiple transactions for a given session to be routed to the same home server. Better Session Control Session management is independent of accounting. Accounting information can be routed to a different server than authentication/authorization messages. Session termination is conveyed by a specific Session-Termination message rather than an Accounting Stop message. The server may initiate a message to request session termination. The server may initiate a message to request re-authentication and/or reauthorization of a user. Better Security Hop-by-hop security is provided using IPsec or TLS. End-to-end security protects the integrity and/or confidentiality of sensitive AVPs through intermediate proxies. OVER

CANADA - PERMANENT RESIDENCE - PROVINCIAL NOMINEE CLASS AND QUEBEC SKILLED WORKERS (Document Required) -2016

                                                                             
1
Generic Application Form to Canada
(IMM 0008)
Completed and signed by the principal applicant.
2
Schedule A: Background/Declaration
(IMM 5669)
Completed, dated and signed by
everyone
in the following list:
• the principal applicant
• spouse or common-law partner (whether they are accompanying or not)
• each dependent child over the age of 18 years (whether they are accompanying or not)
Provide your detailed personal history from the last 10 years or since the age of 18, if you are less than 28 years of
age. Do not leave any sections blank, or gaps in time. You must write "n/a" in any sections that are not applicable
to your situation. Include all:
• jobs,
• periods of unemployment,
• study,
• vacations, or
• being a homemaker.
Do not use abbreviations. Do not use general words such as "employee", "working", "manager." Specify your
activity such as retail salesperson, architect, financial manager, etc.
Note:
If this section is not accurately completed, it will cause delays in the processing of your application.
3
Additional Dependants/Declaration
(IMM 0008DEP) (if applicable)
Completed, dated and signed by the principal applicant if the applicant has more than five dependants (whether they are accompanying or not).
4
Supplementary Information - Your Travels
(IMM 5562)
Completed by the principal applicant.
5
Schedule 4: Economic Classes -
Provincial Nominees
completed and signed by the principal applicant.
AND
(if applicable)
Schedule 4A: Economic Classes - Provincial Nominees - Business Nominees
completed and signed by the
principal applicant if you have been nominated under a business stream.
6
Schedule 5: Declaration of Intent to Reside in Quebec: Economic Classes
completed by principle applicants
destined to Quebec.
7
Additional Family Information
(IMM 5406)
Completed, dated and signed by
everyone
in the following list:
• the principal applicant
• spouse or common-law partner (whether they are accompanying or not)
• each dependent child over the age of 18 years (whether they are accompanying or not)
8
Use of a Representative
(IMM 5476)
Complete, date, sign and include this form in your application if you have a paid or unpaid representative.
9
Travel documents and passports
Copy of the pages of your passport or travel documents for you, your spouse or common-law partner and your
dependent children, showing:
• the passport number,
• date of issue and expiry,
• the photo, name, date and place of birth,
• pages showing any amendments in name, date of birth, expiration, etc.
You must hold a valid regular passport. Diplomatic, official, service or public affairs passports
are not valid for immigration to Canada.
If you live in a country other than your country of nationality, include a photocopy of your visa for the country in which you currently live.

10
Certificat de Sélection du Québec (CSQ)
11
Confirmation of Nomination
from the Province that nominated you. Depending on which Province has nominated
you, confirmation of nomination could be a nomination approval letter or other confirmation of nomination from the province.
12
Proof of Language Proficiency
Since July 1, 2012, most applicants to Provincial/Territorial Nominee classes in semi or low-skilled professions
that fall under National Occupation Classification (NOC) skill level C and D are required to complete a language
proficiency test from one of the following designated agencies:
• IELTS (General Training test only),
• CELPIP (General test only), and/or
• TEF.
You must include a copy of your language test results with your application to CIC.
13
Identity and Civil Status Documents
You must provide the following documents for you and your spouse or common-law partner:
• Birth certificates;
• Legal documents showing name or date of birth changes (if applicable);
• Marriage certificate(s), final divorce or annulment certificate(s). If married more than once, include certificates from each marriage and divorce or annulment you, your spouse or common-law partner have had;
• Death certificate for former spouse(s) or common-law partner(s) (if applicable);
• National IDs, family/household registry/book (if applicable);
• If you have a common-law partner, complete and include the
Statutory Declaration of Common-Law Union

14
Children's Information (if applicable)
• Children's birth certificates (which name their parents);
• Adoption papers issued by recognized national authorities showing the legal, approved adoption of adopted
dependent children;
• Proof of full custody for children under the age of 18 and proof that the children may be removed from the
jurisdiction of the court;
If the other parent of your children is not accompanying you to Canada, you must submit a signed
Statutory Declaration from Non-Accompanying Parent/Guardian for Minors Immigrating to Canada
(IMM 5604 - original). You must submit one form for each child and a copy of the non-accompanying parent's photo ID showing their signature;
Definition of dependent children before August 1, 2014
• Proof of continuous full-time studies of all dependent children aged 22 or over, including:
• complete school records/transcripts since attaining age 22;
• letters from the schools indicating the number of hours of classes attended per day, and the number of
days attended per week;
• proof of full financial support by parents since reaching age 22.
15
Police Certificates and Clearances
You must get a police certificate from each country or territory where you have lived for six or more months in a row since the age of 18. You are strongly encouraged to submit your police certificates with your application to the CIO. If you are unable to obtain all the necessary police certificates, you may still send your application to the CIO without them. However, we strongly recommend that you take steps to obtain your police certificates now to avoid future delays. You must be ready to submit them when requested by an officer.
Note:
Police certificates are generally considered to be valid for one year from date of issue; therefore depending on the processing time of your application, you may be requested to submit new certificates.
16
Photo Requirements
Include two (2) photos
for each member of your family, whether accompanying or not, and yourself. Follow the
instructions provided in the section  How to Complete the Forms of the application guide and in
Appendix A:
Photo Specifications
. Photos must have been taken within six (6) months before application submission.
On the back of one (1) of the photographs, write the name and date of birth of the person who appears in the photo as well as the date the photo was taken. Leave the other photograph blank.
17
Fee payment in an acceptable format
If we are unable to process your payment, your application will be returned to you.
Do not enclose cash. Consult "Step 3, Pay the Fee" section of the instruction guide for more information about fee payment.
18
Mailing Your Application
Mail to the CIO in Sydney, Nova Scotia:
• this document checklist,
• your complete application,
• supporting documents required in this checklist, and
• include 2 self-addressed mailing labels:
• one in English or French and
• one in the official language of your country of residence.
Please consult " Step 4, Mail the application" section of the instruction guide for the CIO address and specific instructions on mailing your application


How to apply for permanent residency in Australia for citizens of New Zealand?

 On arrival in Australia, the New Zealand citizens are automatically granted a special Category visa (SCV). It’s a temporary visa, but it permits the holders to remain and work in Australia. And if you were present in Australia after February 2001 as the holder of an SCV you are eligible to apply for the Australian citizenship.

Who can sponsor for permanent residency in Australia?

Anyone can sponsor for the permanent residence in Australia. They can be friends, relatives, and spouse.

What are the requirements for being granted permanent residency in Australia?

The requirements for permanent residency in Australia are calculated according to these basic fundamental factors:

  • Age, 
  • Qualification, 
  • English Language Proficiency,
  •  Experience of Work, 
  • Adaptability.

What is the age limit for permanent residency in Australia?

To apply for the permanent residence in Australia one should be not more than 45 years of age.

What documents do I need for Australian permanent residency?

 The document for Australian permanent residency includes the reports of Vetassess skill assessment, qualification certificates, documents from the relevant registration and licensing if required. The Documents to show your level of English language proficiency are asked to submit. In the personal documents you need to submit the copies of biographical pages of present passports, travel documents of the main applicant and dependent applicants. The documents regarding health and character certificates are also considered at the time of filling the Australian permanent residency.

What is the difference between permanent residency and citizenship in Australia?

 The permanent residents in Australia & the citizenship have a mighty difference between both: A citizen has an automatic right to enter in to Australia, and if a permanent resident travels out of Australia, they need to ensure about the permanent visa with a valid travel authority if they wish to return to Australia as a permanent resident. A citizen can vote in Australian Government elections and in most cases permanent residents cannot, however if a permanent resident was enrolled to vote (as a British subject) prior to 1984, they may remain eligible to vote.

What are the benefits of Australian permanent residency?

 The benefits of Australian permanent residents:

  • Travel Opportunities: to travel from Australia to any part of the world. The PR holders of Australia are granted the permission to travel to New Zealand and also work over there. 
  • The Freedom of Education: It has world class Universities; the education in Australia offers best opportunities to avail immediate employment and career. 
  • Liberty of working in any desired field, the environment is friendly and motivating.
  •  Child benefits and Medicare insurance are the highlights of the benefit provided to the Permanent Residents of Australia. 
  • The child born to the parents in Australia are deemed citizens of Australia since birth

What to do after getting permanent residency in Australia?

 After getting permanent residency in Australia you can live, work and study without any constraint limitations like a citizen of Australia is living since birth. A permanent resident has rights over most of the entitlements of a native citizen of Australia enjoys.

What does permanent residency mean in Australia?

Permanent residence means you have a visa that permits you to live in Australia indefinitely. Australian Permanent Resident (PR) is an epithet to an intruder who is a bearer of a Permanent Visa. There are various visas that entail permanent residence for citizenship purposes.

How to get permanent residency in Australia after study?

 To get permanent residency in Australia after study has numerous options, The 487 visa provides a pathway for the students after their studies to work for 3 years as a permanent residence. The 887 visa awards the student’s Australia permanent residency, with this you can live and work after studies in Australia permanently; you must have already lived in Australia for two years.

How to apply for permanent residency in Australia for student?

 The most common method used by the students to apply for the Australia permanent residency is through the General Skilled Migration after completing their studies.

How much permanent residency cost in Australia?

The permanent residence visa for Australia cost varies but in general it costs 500 AUS $ to 1000 AUS $ for skill assessment. The skill assessment bodies vary according to the different credential assessment bodies. The Landing charges are 3520 AUS $ for a Single applicant and 1760 AUS $ for the spouse and 880 AUS $ for per child if any.

How to extend permanent residency Australia?

 To extend the Australia permanent residency you can also file a resident return visa, have the evidence of current or former permanent residence visa.

How to change from 457 visas to permanent residence Australia?

 You can easily go for the Australia permanent residence with the 457 visa. If you have worked in Australia for two years, you are firmly eligible to apply for the permanent residence through the Employer Nomination Scheme (ENS). You can also apply through the Regional Skilled Migration Scheme (RSMS); and with the Skilled Migration one can go for the permanent residence Australia from the 457 visa.

How long does it take to get a permanent residence visa for Australia?

It takes approx seven- eight months for the intact procedure of getting the permanent residence visa. The time may vary from country to country.

How to apply for permanent residency in Australia from 457 visas?

 The Australia Visa 457 is the most supported programs among Australian employers who are looking for the distant potential talent, and for those individuals who are moving up to work temporarily in Australia. To apply for this visa you should be:-

  • Get the nomination for working in an approved employment on the Skilled Occupation Lists,
  •  One has to Fulfill the listings of talent for their nominated occupation, 
  •  Have to find a solution regarding the registration and license process, 
  • Should be able to speak vocational English

How to renew Australia permanent residency visa?

 For renewing the Australia permanent residency visa one has to get the RRV, the Resident Return Visa (RRV) it simplifies the re-entry into Australia of permanent residents.

How to get Australia permanent residency?

 There are various point based visas under which one can go forward for the skilled independent and nominated subclasses; some are permanent and temporary too. The other visas are for business visa, working holiday visas and the student visas, which give a magnificent opportunity to the candidate to complete the education and settle down in Australia as immigrants and play a vital role in the emerging economy of the country. Australian Permanent Residence is the status given to an individual, under which you are allowed to stay and work for endless time duration.

Interview Questions and answer for 3-5 Years Exp

Write a program:
1: To create deadlock between two threads.
2: Find out duplicate number between 1 to N numbers.
3. Write a program to find maximum repeated words from a file.
4. To remove duplicates from sorted array.
5. Simple generics class example with two type parameters.
6. Write SQL Query to find second highest salary of Employee





Program: Write a program to create deadlock between two threads.

Description:
Deadlock describes a situation where two or more threads are blocked forever, waiting for each other. Deadlocks can occur in Java when the synchronized keyword causes the executing thread to block while waiting to get the lock, associated with the specified object. Since the thread might already hold locks associated with other objects, two threads could each be waiting for the other to release a lock. In such case, they will end up waiting forever.

Code:
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package com.java2novice.algos;

public class MyDeadlock {

    String str1 = "Java";
    String str2 = "UNIX";
     
    Thread trd1 = new Thread("My Thread 1"){
        public void run(){
            while(true){
                synchronized(str1){
                    synchronized(str2){
                        System.out.println(str1 + str2);
                    }
                }
            }
        }
    };
     
    Thread trd2 = new Thread("My Thread 2"){
        public void run(){
            while(true){
                synchronized(str2){
                    synchronized(str1){
                        System.out.println(str2 + str1);
                    }
                }
            }
        }
    };
     
    public static void main(String a[]){
        MyDeadlock mdl = new MyDeadlock();
        mdl.trd1.start();
        mdl.trd2.start();
    }
}
Program: Find out duplicate number between 1 to N numbers.

Description:
You have got a range of numbers between 1 to N, where one of the number is
repeated. You need to write a program to find out the duplicate number.

Code:
package com.java2novice.algos;

import java.util.ArrayList;
import java.util.List;

public class DuplicateNumber {

        public int findDuplicateNumber(List numbers){
              
               int highestNumber = numbers.size() - 1;
               int total = getSum(numbers);
               int duplicate = total - (highestNumber*(highestNumber+1)/2);
               return duplicate;
        }
       
        public int getSum(List numbers){
              
               int sum = 0;
               for(int num:numbers){
                       sum += num;
               }
               return sum;
        }
       
        public static void main(String a[]){
               List numbers = new ArrayList();
               for(int i=1;i<30 i="" o:p="">
                       numbers.add(i);
               }
               //add duplicate number into the list
               numbers.add(22);
               DuplicateNumber dn = new DuplicateNumber();
               System.out.println("Duplicate Number: "+dn.findDuplicateNumber(numbers));
        }
}

Output:
Duplicate Number: 22

Program: Write a program to find maximum repeated words from a file.

Description:
Write a program to read words from a file. Count the
repeated or duplicated words. Sort it by maximum repeated or
duplicated word count.

Code:
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package com.java2novice.algos;

import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.Map.Entry;

public class MaxDuplicateWordCount {
     
    public Map getWordCount(String fileName){

        FileInputStream fis = null;
        DataInputStream dis = null;
        BufferedReader br = null;
        Map wordMap = new HashMap();
        try {
            fis = new FileInputStream(fileName);
            dis = new DataInputStream(fis);
            br = new BufferedReader(new InputStreamReader(dis));
            String line = null;
            while((line = br.readLine()) != null){
                StringTokenizer st = new StringTokenizer(line, " ");
                while(st.hasMoreTokens()){
                    String tmp = st.nextToken().toLowerCase();
                    if(wordMap.containsKey(tmp)){
                        wordMap.put(tmp, wordMap.get(tmp)+1);
                    } else {
                        wordMap.put(tmp, 1);
                    }
                }
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally{
            try{if(br != null) br.close();}catch(Exception ex){}
        }
        return wordMap;
    }
     
    public List> sortByValue(Map wordMap){
         
        Set> set = wordMap.entrySet();
        List> list = new ArrayList>(set);
        Collections.sort( list, new Comparator>()
        {
            public int compare( Map.Entry o1, Map.Entry o2 )
            {
                return (o2.getValue()).compareTo( o1.getValue() );
            }
        } );
        return list;
    }
     
    public static void main(String a[]){
        MaxDuplicateWordCount mdc = new MaxDuplicateWordCount();
        Map wordMap = mdc.getWordCount("C:/MyTestFile.txt");
        List> list = mdc.sortByValue(wordMap);
        for(Map.Entry entry:list){
            System.out.println(entry.getKey()+" ==== "+entry.getValue());
        }
    }
}

Output:
one ==== 3
the ==== 3
that ==== 3
of ==== 2
in ==== 2
some ==== 2
to ==== 1
summary ==== 1
but ==== 1
have ==== 1
common ==== 1
least ==== 1
simplest ==== 1
Program: Write a program to remove duplicates from sorted array.

Description:
Given array is already sorted, and it has duplicate elements. Write a program to remove duplicate elements and return new array without any duplicate elements. The array should contain only unique elements.

Code:
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package com.java2novice.algos;

public class MyDuplicateElements {

    public static int[] removeDuplicates(int[] input){
         
        int j = 0;
        int i = 1;
        //return if the array length is less than 2
        if(input.length < 2){
            return input;
        }
        while(i < input.length){
            if(input[i] == input[j]){
                i++;
            }else{
                input[++j] = input[i++];
            }   
        }
        int[] output = new int[j+1];
        for(int k=0; k
            output[k] = input[k];
        }
         
        return output;
    }
     
    public static void main(String a[]){
        int[] input1 = {2,3,6,6,8,9,10,10,10,12,12};
        int[] output = removeDuplicates(input1);
        for(int i:output){
            System.out.print(i+" ");
        }
    }
}

Output:
2 3 6 8 9 10 12
Program: Write a simple generics class example with two type parameters.

Below example shows how to create a simple generics class with two type parameters. Look at the class definition, we defined two types of parameters called U & V, seperated by ",". You can define multiple type parameters seperated by ",". Look at sample code for more comments.

package com.java2novice.generics;

public class MySimpleTwoGenerics {

        public static void main(String a[]){
              
               SimpleGen sample
                                      = new SimpleGen("JAVA2NOVICE", 100);
               sample.printTypes();
        }
}

/**
 * Simple generics class with two type parameters U, V.
 */
class SimpleGen{
       
        //type U object reference
        private U objUreff;
        //type V object reference
        private V objVreff;
       
        //constructor to accept object type U and object type V
        public SimpleGen(U objU, V objV){
               this.objUreff = objU;
               this.objVreff = objV;
        }
       
        public void printTypes(){
               System.out.println("U Type: "+this.objUreff.getClass().getName());
               System.out.println("V Type: "+this.objVreff.getClass().getName());
        }
}

Output:
U Type: java.lang.String
V Type: java.lang.Integer

SQL Query to find second highest salary of Employee

Answer : There are many ways to find second highest salary of Employee in SQL, you can either use SQL Join or Subquery to solve this problem. Here is SQL query using Subquery :

 select MAX(Salary) from Employee WHERE Salary NOT IN (select MAX(Salary) from Employee );