zoukankan      html  css  js  c++  java
  • NAT之stun确定nat类型

    NAT之确定nat类型

    下载安装twisted和zope
    http://twistedmatrix.com/trac/wiki/Downloads
    http://pypi.python.org/pypi/zope.interface/3.8.0#downloads

    下载stunclient
    http://code.google.com/p/stunclient/

    这里面有个stun子目录,说是用于发现NAT类型
    This code comes from Shtoom: http://divmod.org/projects/shtoom

    执行里面的stun.py,就会log一个文件,在我电脑上如下(很费解啊)

    01:23:30 [-] Log opened.
    01:23:30 [-] <class '__main__.TestStunDiscoveryProtocol'> starting on 5061
    01:23:30 [-] Starting protocol <__main__.TestStunDiscoveryProtocol object at 0x00EDB190>
    01:23:30 [-] startDiscover--localAddress is 0.0.0.0
    01:23:30 [-] localAddress is invalid!
    01:23:30 [-] resolving A.ROOT-SERVERS.NET
    01:23:30 [-] connecting UDP socket to 198.41.0.4
    01:23:30 [-] twisted.internet.protocol.DatagramProtocol starting on 57131
    01:23:30 [-] Starting protocol <twisted.internet.protocol.DatagramProtocol instance at 0x00EE3828>
    01:23:30 [-] connected UDP socket says 192.168.1.100
    01:23:30 [-] (Port 57131 Closed)
    01:23:30 [-] Stopping protocol <twisted.internet.protocol.DatagramProtocol instance at 0x00EE3828>
    01:23:30 [-] sending request 'bbf2c488eedcba1863238b76fbbdb1a' with 1 avpairs to ('216.146.35.99', 3478) (in state 1)
    01:23:30 [-] sending request 'bcffaf59142c3cf2575d2fb6f06424' with 1 avpairs to ('213.192.59.75', 3478) (in state 1)
    01:23:30 [-] sending request '26e9d0804bc12a4037aa59ccbd75e49' with 1 avpairs to ('192.98.81.87', 3478) (in state 1)
    01:23:30 [-] sending request 'bbf2c488eedcba1863238b76fbbdb1a' with 1 avpairs to ('216.146.35.99', 3478) (in state 1)
    01:23:30 [-] sending request 'bcffaf59142c3cf2575d2fb6f06424' with 1 avpairs to ('213.192.59.75', 3478) (in state 1)
    01:23:30 [-] sending request '26e9d0804bc12a4037aa59ccbd75e49' with 1 avpairs to ('192.98.81.87', 3478) (in state 1)
    01:23:30 [-] sending request 'bbf2c488eedcba1863238b76fbbdb1a' with 1 avpairs to ('216.146.35.99', 3478) (in state 1)
    01:23:30 [-] sending request 'bcffaf59142c3cf2575d2fb6f06424' with 1 avpairs to ('213.192.59.75', 3478) (in state 1)
    01:23:30 [-] sending request '26e9d0804bc12a4037aa59ccbd75e49' with 1 avpairs to ('192.98.81.87', 3478) (in state 1)
    01:23:30 [stun] got STUN response to None from ('213.192.59.75', 3478)
    01:23:30 [__main__.TestStunDiscoveryProtocol (UDP)] MAPPED-ADDRESS 116.48.48.225 14959
    01:23:30 [__main__.TestStunDiscoveryProtocol (UDP)] CHANGED-ADDRESS 213.192.59.93 3479
    01:23:30 [__main__.TestStunDiscoveryProtocol (UDP)] SOURCE-ADDRESS 213.192.59.75 3478
    01:23:30 [__main__.TestStunDiscoveryProtocol (UDP)] sending request '1fd789b6d02e4be456597e8be1df4a7a' with 1 avpairs to ('213.192.59.75', 3478) (in state 2b)
    01:23:30 [stun] ignoring belated STUN response to 'bcffaf59142c3cf2575d2fb6f06424' from ('213.192.59.75', 3478)
    01:23:30 [-] sending request '1fd789b6d02e4be456597e8be1df4a7a' with 1 avpairs to ('213.192.59.75', 3478) (in state 2b)
    01:23:30 [stun] ignoring belated STUN response to 'bcffaf59142c3cf2575d2fb6f06424' from ('213.192.59.75', 3478)
    01:23:30 [-] sending request '1fd789b6d02e4be456597e8be1df4a7a' with 1 avpairs to ('213.192.59.75', 3478) (in state 2b)
    01:23:30 [stun] got STUN response to '1fd789b6d02e4be456597e8be1df4a7a' from ('213.192.59.93', 3479)
    01:23:30 [__main__.TestStunDiscoveryProtocol (UDP)] MAPPED-ADDRESS 116.48.48.225 14959
    01:23:30 [__main__.TestStunDiscoveryProtocol (UDP)] CHANGED-ADDRESS 213.192.59.93 3479
    01:23:30 [__main__.TestStunDiscoveryProtocol (UDP)] SOURCE-ADDRESS 213.192.59.93 3479
    01:23:30 [__main__.TestStunDiscoveryProtocol (UDP)] calling handleStunState2b
    01:23:30 [__main__.TestStunDiscoveryProtocol (UDP)] 2b {'externalAddress': ('116.48.48.225', 14959), '_altStunAddress': ('213.192.59.93', 3479)}
    01:23:30 [__main__.TestStunDiscoveryProtocol (UDP)] STUN finished, results:
    01:23:30 [__main__.TestStunDiscoveryProtocol (UDP)] You're behind a <NatType FullCone>
    01:23:30 [__main__.TestStunDiscoveryProtocol (UDP)] and external address is ('116.48.48.225', 14959)
    01:23:30 [__main__.TestStunDiscoveryProtocol (UDP)] (Port 5061 Closed)
    01:23:30 [__main__.TestStunDiscoveryProtocol (UDP)] Stopping protocol <__main__.TestStunDiscoveryProtocol object at 0x00EDB190>
    01:23:30 [-] Main loop terminated.

  • 相关阅读:
    事务传播机制,搞懂。
    洛谷 P1553 数字反转(升级版) 题解
    洛谷 P1200 [USACO1.1]你的飞碟在这儿Your Ride Is Here 题解
    洛谷 P1055 ISBN号码 题解
    洛谷 P2141 珠心算测验 题解
    洛谷 P1047 校门外的树 题解
    洛谷 P1980 计数问题 题解
    洛谷 P1008 三连击 题解
    HDU 1013 题解
    HDU 1012 题解
  • 原文地址:https://www.cnblogs.com/cutepig/p/2185702.html
Copyright © 2011-2022 走看看