CS2307 – Network Lab

Exp# 5D

Socket Programming

RARP Client/Server

Aim To know the logical address of a host when its physical address is known using RARP protocol.

Algorithm Target/Server 1. 2. 3. 4. 5. 6.

Create a server socket. Accept client connection. Read MAC address from the client request Check its configuration file and compare with its physical address. If there is a match, send the host logical address. Stop

Client 1. 2. 3. 4. 5. 6.

Create a socket. Send physical address to the target machine Receive target's response If it is a IP address then display it and go to step 6 Display "Host not found" Stop

Result Thus using RARP protocol, IP address is obtained.

http://cseannauniv.blogspot.com

Vijai Anand

CS2307 – Network Lab

Socket Programming

Program //RARP Server -- rarpserver.java import java.io.*; import java.net.*; class rarpserver { public static void main(String args[])throws IOException { try { ServerSocket soc = new ServerSocket(2500); System.out.println("Server started"); Socket client = null; client = soc.accept(); String str; PrintStream ps = new PrintStream(client.getOutputStream()); BufferedReader br = new BufferedReader(new InputStreamReader(client.getInputStream())); Runtime r = Runtime.getRuntime(); Process p = r.exec("ifconfig eth0"); BufferedReader pin = new BufferedReader(new InputStreamReader(p.getInputStream())); String ipaddr = ""; String haddr = br.readLine(); int flag = 0; while((str = pin.readLine())!=null) { System.out.println(str); if ((str.indexOf(haddr)) != -1) { flag = 1; } else if((str.indexOf("inet addr")) != -1) { int pos = str.indexOf("inet addr:") + 10; int offset = pos + 13; ipaddr = str.substring(pos,offset); } } if (flag == 1) ps.println(ipaddr); ps.close(); br.close(); pin.close(); client.close(); soc.close();

http://cseannauniv.blogspot.com

Vijai Anand

CS2307 – Network Lab

Socket Programming

} catch(IOException io) { System.err.println("Exception : " + io.toString()); } } }

// RARP Client -- rarpclient.java import java.io.*; import java.net.*; class rarpclient { public static void main(String args[]) { try { Socket client = new Socket("localhost", 2500); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintStream ps = new PrintStream(client.getOutputStream()); String haddr,ipaddr = null; BufferedReader sin = new BufferedReader(new InputStreamReader(client.getInputStream())); System.out.print("Enter the physical address : "); haddr = br.readLine(); ps.println(haddr); ipaddr = sin.readLine(); if (ipaddr == null) System.out.println("Host does not exist"); else System.out.println("Logical Address " + ipaddr); ps.close(); br.close(); client.close(); } catch(IOException io) { System.err.println(io.toString()); } } }

http://cseannauniv.blogspot.com

Vijai Anand

CS2307 – Network Lab

Socket Programming

Output

Server $ javac rarpserver.java $ java rarpserver Server started eth0

Link encap:Ethernet HWaddr B8:AC:6F:1B:AB:06 inet addr:172.16.6.21 Bcast:172.255.255.255 Mask:255.0.0.0 inet6 addr: fe80::baac:6fff:fe1b:ab06/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:450 errors:0 dropped:0 overruns:0 frame:0 TX packets:127 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:48118 (46.9 KiB) TX bytes:21025 (20.5 KiB) Interrupt:16

Client $ javac rarpclient.java $ java rarpclient Enter the physical address : B8:AC:6F:1B:AB:06 Logical Address 172.16.6.21

http://cseannauniv.blogspot.com

Vijai Anand

http://cseannauniv.blogspot.com Vijai Anand Exp# 5D RARP Client ...

6. Stop. Client. 1. Create a socket. 2. Send physical address to the target machine. 3. Receive target's response. 4. If it is a IP address then display it and go to step 6 ... Program. //RARP Server -- rarpserver.java import java.io.*; import java.net.*; class rarpserver. { public static void main(String args[])throws IOException. { try.

11KB Sizes 0 Downloads 219 Views

Recommend Documents

http://cseannauniv.blogspot.com Vijai Anand Exp# 2B UDP Chat ...
http://cseannauniv.blogspot.com. Vijai Anand. Exp# 2B. UDP Chat Server/Client. Aim. To implement a chat server and client in java using UDP sockets.

IT2042–Information Security 1.1 Vijai Anand ...
Security Model, Components of an Information System, Securing the ... Information security is to protect the confidentiality, integrity and availability of information ...

Anand Balakrishnan - GitHub
Relevent Coursework Algorithm Analysis and Design, Operating Systems, Microprocessors, Real-time and Embedded Systems,. Data Structures, Signals and ...

Prof. Anand Kumar.pdf
students about various aspects of power, culture, poverty, society, media and social change,. including globalization. His current research work includes political ...

Exp III.pdf
Spatial Filters. • Implement and analyse the following Spatial filters. ... Note: Do not use of built in matlab functions for filter implementation. 1. Page 1. Exp III.pdf.

R. Sai Anand
M.Eng. IISc Bangalore born on 26. May 1976, in India the title ... The Chairman of the Department of. Information Technology and Electrical Engineering. Prof.

teaching-exp-certificate.pdf
Whoops! There was a problem loading more pages. Retrying... teaching-exp-certificate.pdf. teaching-exp-certificate.pdf. Open. Extract. Open with. Sign In.Missing:

exp-monitoramento - Web.pdf
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. exp-monitoramento - Web.pdf. exp-monitoramento - Web.pdf. Open. Extract. Open with. Sign In. Main menu.

5b109-2018-MINEDU%5d-%5b09-03-2018 12_03_55%5d-RM N ...
Page 1 of 11. Page 1 of 11. Page 2 of 11. Page 2 of 11. Page 3 of 11. Page 3 of 11. %5b109-2018-MINEDU%5d-%5b09-03-2018 12_03_55%5d-RM N° 109-2018-MINEDU.pdf. %5b109-2018-MINEDU%5d-%5b09-03-2018 12_03_55%5d-RM N° 109-2018-MINEDU.pdf. Open. Extract.

Gautam Buddha University Electrical Exp. -
It has a big knob on top that allows you to dial in whatever output voltage you want. Working of transformer: The principle of the transformer is illustrated by ...

Gautam Buddha University Electrical Exp. -
Connect terminal S6 to terminal Re1 and terminal Re2 to terminal R1. 6. .... I6. I0ut. Deptt. Of electrical engineering, SOE, GBU, Greater Noida (U.P.) 201308 ..... 10. Switch off the mains supply. Observation Table: Transformer. Vp. Vs. K ...

4.B.5D Localisation Volcans.pdf
Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. 4.B.5D Localisation Volcans.pdf. 4.B.5D Localisation Volcans.pdf.

(www.entrance-exam.net)-Institute of Rural Management Anand ...
11. The Ministerial Conference of the world Trade. Organization was held at Cancun, Cancun is located in ____. (1) Uruguay (2) Venezuela (3) Mexico. (4) Honduras (5) Bahrain. Page 3 of 14. Main menu. Displaying (www.entrance-exam.net)-Institute of Ru

untouchable mulk raj anand pdf
Page 1. Whoops! There was a problem loading more pages. untouchable mulk raj anand pdf. untouchable mulk raj anand pdf. Open. Extract. Open with. Sign In.

Exp 4.pdf
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. Exp 4.pdf. Exp 4.

ciencia exp 2014_esa.pdf
Loading… Whoops! There was a problem loading more pages. Whoops! There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. ciencia exp 2014_esa.pdf. ciencia exp 201

MKB Tour 5D - 4N.pdf
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. MKB Tour 5D ...Missing:

anand kumar digital electronics pdf
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. anand kumar digital electronics pdf. anand kumar digital electronics pdf. Open. Extract. Open with. Sign In.

work exp updated ksta.pdf
Page 2 of 2. Scanned by CamScanner. KSTA ATTINGAL. www.kpsta.in. Powered by TCPDF (www.tcpdf.org) Powered by TCPDF (www.tcpdf.org) Powered by ...

ZENMUSE Z15 5D CALIBRATION PROBLEM.pdf
There was a problem previewing this document. Retrying... Download. Connect more ... ZENMUSE Z15 5D CALIBRATION PROBLEM.pdf. ZENMUSE Z15 5D ...

(www.entrance-exam.net)-Institute of Rural Management Anand ...
(www.entrance-exam.net)-Institute of Rural Management Anand (IRMA) Sample Paper 2.pdf. (www.entrance-exam.net)-Institute of Rural Management Anand ...

Copy of exp Match_Game_context .pdf
Page 1 of 1. Page 1. A tree frog population doubles every. week. Suppose that currently, there. are 10 tree frogs in your back yard. Currently, 80,000 bacteria are.