You are on page 1of 5

Experiment No.

7
(PART B: TO BE COMPLETED BY STUDENTS)

(Students must submit the soft copy as per following segments within two hours of the
practical. The soft copy must be uploaded on the Blackboard or emailed to the concerned
lab in charge faculties at the end of the practical in case the there is no Black board access
available)

Roll No. E059 Name: Shubham Gupta


Class: BTech Comps Batch : E3
Date of Experiment: Date of Submission:
Grade :

B.1 Code:

/*

* To change this license header, choose License Headers in Project Properties.

* To change this template file, choose Tools | Templates

* and open the template in the editor.

*/

package ipinip;

/**

* @author mpstme.student

*/

class Source {

public String packet;


public String sourceIP;

public String destinationIP;

public Source(String x,String y, String z) {

sourceIP = x;

destinationIP = y;

packet = z;

System.out.println(x + " " + y + " " + z);

};

String send() {

String xx = sourceIP + " " + destinationIP + " " + packet;

return xx;

class Router {

public String packet;

public String sourceIP;

public String destinationIP;

public Router(String x,String y, String z) {

sourceIP = x;

destinationIP = y;

packet = z;

System.out.println(x + " " + y + " " + z);

};

String send() {

String xx = sourceIP + " " + destinationIP + " " + packet;


return xx;

void printer() {

System.out.print(packet);

String remove() {

String[] splited = packet.split(" ");

return (splited[2] + " " + splited[3] + " " + splited[4]);

class Destination {

public String packet;

public String sourceIP;

public String destinationIP;

public Destination(String z) {

String[] splited = z.split(" ");

sourceIP = splited[0];

destinationIP = splited[1];

packet = splited[2];

};

public class IPinIP {

/**

* @param args the command line arguments


*/

public static void main(String[] args) {

// TODO code application logic here

System.out.println("Source: ");

Source source = new Source("192.168.0.11", "192.168.0.21", "hello");

System.out.println("Router 1: ");

Router router1 = new Router("192.168.0.12", "192.168.0.22", source.send());

System.out.println("Router 2: ");

Router router2 = new Router("192.168.0.22", "192.168.0.21", router1.send());

System.out.println("Packet recieved at destination: ");

Destination destination = new Destination(router2.remove());

System.out.println(destination.packet);

System.out.println(destination.sourceIP);

System.out.println(destination.destinationIP);

B.2 Input/Output:
run:

Source:

192.168.0.11 192.168.0.21 hello

Router 1:

192.168.0.12 192.168.0.22 192.168.0.11 192.168.0.21 hello


Router 2:

192.168.0.22 192.168.0.21 192.168.0.12 192.168.0.22 192.168.0.11 192.168.0.21 hello

Packet recieved at destination:

hello

192.168.0.11

192.168.0.21

BUILD SUCCESSFUL (total time: 0 seconds)

B.3 Conclusion:
We have successfully implemented IP-in-IP protocol.

You might also like