简体   繁体   中英

How to know that a device on the a network is offering a service without being connected to the network

I wish to know how an app on a device knows the neighbouring network which have a device offering a particular service without even being connected to the network. I will take for example the case of the mobile app called Xender . When you launch this app and Click on"Create a group", it create a hotspot with the default device hotspot name as the SSID of the network, when another device launch the app and click on "Join group", this device is able to see the available device around by sensing the networks around. The second device is able to receive the a name of the first device, without even being connected to the network created by the fist device. How is it possible? Especially in android.

What Xender do when you create a group, is creating an hotspot, like your home router.

What routers do when they are on, is broadcast their name (SSID) so other devices (like your phone or laptop) will be able to "se" them and connect to them.

So basically, when one Xender app joins to another Xender app group, it first connects to the hotspot that the phone creates, and then start sharing data on that connection.

Xender just encodes the SSID like if you set name "xx" then the SSID will be ADYXeHg or ADYYeHg or something else but ADY_eHg letters remain same in different device at same name "xx" so we have to just decode that method of Xender.

I guess they use cipher encryption to convert profile name into SSID.

This is how xender code would be look like in encryption (Hotspot side).

code : not this is not xender's code it is coded by me.

public String Encry(String sc) {
    int i;
    String data = sc;
    StringBuffer pas = new StringBuffer(data);
    for (i = 0; i < pas.length(); i++) {

        int temp = 0;
        temp = (int) pas.charAt(i);
        temp = temp - 10;
        pas.setCharAt(i, (char) temp);
    }
    String data1 = "robo" + pas;
    String[] one = data1.split("robo");
    String s = Arrays.toString(one);
    s = s.substring(1, s.length()-1).replaceAll(",", "");
    StringBuffer tu = new StringBuffer(s);

    for (i = 0; i < tu.length(); i++) {
        int da = 0;
        da = (int) tu.charAt(i);
        da = da + 10;
        tu.setCharAt(i, (char) da);
    }
    System.out.println("\n");
    String star = tu.toString();
    star = star.substring(1, star.length() - 1).replaceAll(",", ""); // remove " * " from String.
    return data1;
}

and this is how dicryption works ( Join network side ) : note : this is not xender's code it is coded by me.

public String Dicry(String SSID) {

    int i;
    String data1 = SSID;
    String[] one = data1.split("robo");
    String s = Arrays.toString(one);
    s = s.substring(1, s.length()).replaceAll(",", "");
    StringBuffer tu = new StringBuffer(s);
    for (i = 0; i < tu.length(); i++) {
        int da = 0;
        da = (int) tu.charAt(i);
        da = da + 10;
        tu.setCharAt(i, (char) da);
    }
    String star = tu.toString();
    star = star.substring(1, star.length()).replaceAll(",", ""); // remove " * " from String.
    return star;
 } // scanner

Note : this code is coded by me . its not a xender's original code. please keep in mind this.

this is how cipher encryption works.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM