| 将IP地址通过16进制转化为10进制后能访问吗?? | 作者:lizhanglical | 时间:2005/03/31 22:20:35 | ||||
感觉上好象是一回事,但我把ip转化为10进制显示后,访问另一台电脑没有成功。 有成功过的朋友吗??如果成功能说说是怎么做的吗??谢谢。 |
||||||
| Re:将IP地址通过16进制转化为10进制后能访问吗?? | 作者:fatalerr | 时间:2005/03/31 23:13:41 | ||||
要想得到别人的帮助,麻烦您把你的问题描述的清楚一点。就这么一句话,让人摸不着头脑! |
||||||
| Re:将IP地址通过16进制转化为10进制后能访问吗?? | 作者:peak8212 | 时间:2005/04/01 08:48:23 | ||||
| Re:将IP地址通过16进制转化为10进制后能访问吗?? | 作者:lizhanglical | 时间:2005/04/01 10:47:29 | ||||
我的意思就是有没有哪位兄弟将IP地址通过16进制转化10进制后,并成功的访问过局域网内的别的电脑的。如果有做成功了的,请说说是怎么做的。 |
||||||
| Re:将IP地址通过16进制转化为10进制后能访问吗?? | 作者:superlee | 时间:2005/04/01 12:37:36 | ||||
IP地址什么时候有过16进制的?? MAC地址否? |
||||||
| Re:将IP地址通过16进制转化为10进制后能访问吗?? | 作者:lizhanglical | 时间:2005/04/01 14:36:57 | ||||
没有用过16进制呀, 我的意思是,比如IP地址218.22.123.26转换为16进制就是DA.16.7B.1A,去掉小数点后再转为10进制就是3658906394,以这样的形式能不能在局域网中访问别的电脑?? |
||||||
| Re:将IP地址通过16进制转化为10进制后能访问吗?? | 作者:xxbin | 时间:2005/04/01 14:42:11 | ||||
ping 3658906394 ??? 太有想象力了 楼主强人 |
||||||
| Re:将IP地址通过16进制转化为10进制后能访问吗?? | 作者:麦子 | 时间:2005/04/01 16:39:38 | ||||
微软的XP下是可以这样操作的: Microsoft Windows XP [版本 5.1.2600] © 版权所有 1985-2001 Microsoft Corp. C:\WINDOWS>ping 3330661145 Pinging 198.133.219.25 with 32 bytes of data: Reply from 198.133.219.25: bytes=32 time=863ms TTL=112 Reply from 198.133.219.25: bytes=32 time=928ms TTL=112 Reply from 198.133.219.25: bytes=32 time=898ms TTL=112 Reply from 198.133.219.25: bytes=32 time=858ms TTL=112 Ping statistics for 198.133.219.25: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 858ms, Maximum = 928ms, Average = 886ms C:\WINDOWS>tracert -d 3330661145 Tracing route to 198.133.219.25 over a maximum of 30 hops 1 3 ms 3 ms 3 ms xxx.xxx.xxx.xxx 2 3 ms 3 ms 9 ms xxx.xxx.xxx.xxx 3 37 ms 31 ms 31 ms xxx.xxx.xxx.xxx ... 3330661145=198*256*256*256+133*256*256+219*256+25 ------------------- 由此可见MS的内核是十进制的。 |
||||||
| Re:将IP地址通过16进制转化为10进制后能访问吗?? | 作者:xxbin | 时间:2005/04/01 17:11:01 | ||||
今天4.1哈 |
||||||
| Re:将IP地址通过16进制转化为10进制后能访问吗?? | 作者:happydj | 时间:2005/04/01 17:15:15 | ||||
经过测试,2K也是可以这样操作的,HOHO! Microsoft Windows 2000 [Version 5.00.2195] © 版权所有 1985-2000 Microsoft Corp. C:\Documents and Settings\Administrator>ping 3330661145 Pinging 198.133.219.25 with 32 bytes of data: Request timed out. Request timed out. Request timed out. Request timed out. Ping statistics for 198.133.219.25: Packets: Sent = 4, Received = 0, Lost = 4 (100% loss), Approximate round trip times in milli-seconds: Minimum = 0ms, Maximum = 0ms, Average = 0ms |
||||||
| RE: 将IP地址通过16进制转化为10进制后能访问吗?? | 作者:麦子 | 时间:2005/04/01 17:15:39 | ||||
假中有真那才叫强。 你倒是试试? |
||||||
| Re:将IP地址通过16进制转化为10进制后能访问吗?? | 作者:peak8212 | 时间:2005/04/01 17:25:01 | ||||
真的可以! 太强了。 |
||||||
| RE: 将IP地址通过16进制转化为10进制后能访问吗?? | 作者:xxbin | 时间:2005/04/01 17:28:34 | ||||
EN UNIX下也是的 |
||||||
| Re:将IP地址通过16进制转化为10进制后能访问吗?? | 作者:麦子 | 时间:2005/04/01 17:29:27 | ||||
同学们都试试吧? |
||||||
| Re:将IP地址通过16进制转化为10进制后能访问吗?? | 作者:bug | 时间:2005/04/01 17:32:56 | ||||
今天算是开眼界了。 |
||||||
| Re:将IP地址通过16进制转化为10进制后能访问吗?? | 作者:麦子 | 时间:2005/04/01 17:33:17 | ||||
Cisco 路由器: router#ping 3330661145 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 198.133.219.25, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 4/6/12 ms wiscom-outside#show ver Cisco Internetwork Operating System Software IOS ™ 3600 Software (C3620-IO3-M), Version 12.2(15)T9, RELEASE SOFTWARE (fc2) TAC Support: http://www.cisco.com/tac Copyright © 1986-2003 by cisco Systems, Inc. Compiled Sat 01-Nov-03 07:25 by ccai Image text-base: 0x60008950, data-base: 0x60CAC000 ROM: System Bootstrap, Version 11.1(20)AA2, EARLY DEPLOYMENT RELEASE SOFTWARE (fc1) wiscom-outside uptime is 3 weeks, 2 days, 4 hours, 9 minutes System returned to ROM by power-on System restarted at 13:16:54 BeiJing Wed Mar 9 2005 System image file is "flash:c3620-io3-mz.122-15.T9.bin" cisco 3620 (R4700) processor (revision 0x81) with 39936K/9216K bytes of memory. Processor board ID 19220164 R4700 CPU at 80Mhz, Implementation 33, Rev 1.0 Bridging software. X.25 software, Version 3.0.0. 2 FastEthernet/IEEE 802.3 interface(s) DRAM configuration is 32 bits wide with parity disabled. 29K bytes of non-volatile configuration memory. 8192K bytes of processor board System flash (Read/Write) Configuration register is 0x2102 |
||||||
| Re:将IP地址通过16进制转化为10进制后能访问吗?? | 作者:麦子 | 时间:2005/04/01 17:39:48 | ||||
| Re:将IP地址通过16进制转化为10进制后能访问吗?? | 作者:xxbin | 时间:2005/04/01 17:43:25 | ||||
en 还以为TCP/IP堆栈只会把 dot 分割的IPV4地址以转化后的形式保存在内存中,哪知道居然会认识这样的地址。 |
||||||
| IP地址的4种写法 | 作者:xxbin | 时间:2005/04/01 19:15:40 | ||||
The IP address 203.154.87.15 is the 32-bit integer: (hex) CB9A570F. How would this be stored in computer memory (or a CPU register)? Representation byte 0 byte 1 byte 2 byte 3 x86 byte order: 0F 57 9A CB SPARC byte order: CB 9A 57 0F Network byte order: CB 9A 57 0F 在网络上传输的时候,IP地址采用Network byte order编码,在主机上的内存中,IP地址是按照Host byte order来存储的,Network byte order是一致的,Host byte order是根据机器的CPU类型来决定的(主要是高低位的问题) 造成偶最初的错误认识的原因是偶以前在写代码的时候不太规范,经常用gethostbyname()来得到network byte order的IP地址,所以才认为类似3415889679等东东是不可能ping得通的。 其实正规的代码是应该先用inet_addr函数来判断一个字符串是否是规范的IP地址,如果不是再使用gethostbyname来获取IP。 in_addr_t inet_addr(const char *cp); 输入参数是一个字符串,如果这个字符串是规范的IP地址,那么将会把这个IP地址转换成network byte order的IP地址并返回,其实类似inet_addr这样的函数,不仅仅可以认识dot分割的IP地址,也可以认识3415889679这样的十进制的IP地址,另外像类似0xCB9A570F的十六进制也是认识的,不过要注意,前面要加上0x的十六进制的前缀,否则就会当作一个hostname来解释了,第4种表示方法就是用八进制来当作参数了,前缀加上个0就OK了。 花了点时间写了段代码,也许更能说明这个问题:
看看测试结果: # addr 203.154.87.15 input "203.154.87.15" is a vaild ip address dot ip address: 203.154.87.15 ip address(network byte order): 257399499 ip address(network byte order)(hex): 0xF579ACB ip address(host byte order): 3415889679 ip address(host byte order)(oct): 031346453417 ip address(host byte order)(hex): 0xCB9A570F # addr 3415889679 input "3415889679" is a vaild ip address dot ip address: 203.154.87.15 ip address(network byte order): 257399499 ip address(network byte order)(hex): 0xF579ACB ip address(host byte order): 3415889679 ip address(host byte order)(oct): 031346453417 ip address(host byte order)(hex): 0xCB9A570F # addr 031346453417 input "031346453417" is a vaild ip address dot ip address: 203.154.87.15 ip address(network byte order): 257399499 ip address(network byte order)(hex): 0xF579ACB ip address(host byte order): 3415889679 ip address(host byte order)(oct): 031346453417 ip address(host byte order)(hex): 0xCB9A570F # addr 0xCB9A570F input "0xCB9A570F" is a vaild ip address dot ip address: 203.154.87.15 ip address(network byte order): 257399499 ip address(network byte order)(hex): 0xF579ACB ip address(host byte order): 3415889679 ip address(host byte order)(oct): 031346453417 ip address(host byte order)(hex): 0xCB9A570F 所以偶们通常认识的203.154.87.15这个IP,其实有4中写法: 203.154.87.15 3415889679 031346453417 0xCB9A570F 注意,这个是在偶们通常用的x86芯片的结果,在某些CPU中,host byte order是和x86不一样的 签名 ------------------------------- C:\Documents and Settings\root>ping 0xCB9A570F Pinging 203.154.87.15 with 32 bytes of data: Request timed out. Request timed out. |
||||||
| Re:将IP地址通过16进制转化为10进制后能访问吗?? | 作者:麦子 | 时间:2005/04/01 20:33:01 | ||||
各位同学注意了,由于今天是4.1,所以以上有关帖子有真有假: MS可以ping 或trace 203.154.87.15 或 3415889679(十进制)、031346453417(八进制)、0xCB9A570F(十六进制)是真的。 Cisco 只支持203.154.87.15格式。 以上表现在RFC 1166中没有说明。 ---------------------- |
||||||
Powered by Phoenix Portal v0.0.2 Powered by Zero Framework v0.0.1 2003-2004 ZERO NS |