我自己的热点

时间:2015-05-09 16:48:32

标签: android networking wifi personal-hotspot

为了进行网络分析和测试,我试图设置一种方法来处理我自己手机的wifi热点AP。

我已经彻底研究过它,但我已经进入了圈子。到目前为止,我一直专注于各种ping和数据包泛滥。但似乎没有任何东西会降低连接设备的流量。以下是我尝试过的一些事情:

ping方法:

public class PacketFlood extends Thread {

 public void run() { 

  Runtime runtime = Runtime.getRuntime();

      Process proc;

    try { 

        proc = runtime.exec("ping -i 0.2 -l 3 -c 1 " + "192.168.43.1"); // <--- ip of the hotspot AP

        proc.waitFor(); 

         int exit = proc.exitValue();

            proc.destroy();
            proc = null; 

    } 

        catch (IOException e){ 
            e.printStackTrace();
         }
    catch (InterruptedException e) {
        e.printStackTrace(); 
         }

    PacketFlood tpint = new PacketFlood(); ////// , ppppsub[1]);
    /////// 5-6-15-am tworig: 
tpint.start(); 


}//////run

套接字方法:

class ClientThread implements Runnable {

    @Override
    public void run() { 

         Socket socket = null;

            try {

                socket = new Socket("192.168.43.1", 5555); // <-- ip of AP on arbitrary port  

            if (socket.isConnected()) {

                      PrintWriter out = new PrintWriter(new BufferedWriter(
                              new OutputStreamWriter(socket.getOutputStream())), true);

                      out.println(....a very long string here.....);

                       socket.close();

                } else {
                    Log.e("nnnnnnnooooooo", "Socket is NOT connected");
                }

            } catch (UnknownHostException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }

            new Thread(new ClientThread()).start();

    }//////run

0 个答案:

没有答案