﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-ivy-jie-文章分类-network</title><link>http://www.cppblog.com/ivy-jie/category/10663.html</link><description>progress ...</description><language>zh-cn</language><lastBuildDate>Sun, 24 May 2009 09:06:44 GMT</lastBuildDate><pubDate>Sun, 24 May 2009 09:06:44 GMT</pubDate><ttl>60</ttl><item><title>Windows网络命令行程序</title><link>http://www.cppblog.com/ivy-jie/articles/85571.html</link><dc:creator>ivy-jie</dc:creator><author>ivy-jie</author><pubDate>Sun, 24 May 2009 01:24:00 GMT</pubDate><guid>http://www.cppblog.com/ivy-jie/articles/85571.html</guid><wfw:comment>http://www.cppblog.com/ivy-jie/comments/85571.html</wfw:comment><comments>http://www.cppblog.com/ivy-jie/articles/85571.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/ivy-jie/comments/commentRss/85571.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ivy-jie/services/trackbacks/85571.html</trackback:ping><description><![CDATA[<div>
<p>Windows网络命令行程序 <br>这部分包括：</p>
<p>使用 ipconfig /all 查看配置 <br>使用 ipconfig /renew 刷新配置 <br>使用 ipconfig 管理 DNS 和 DHCP 类别 ID <br>使用 Ping 测试连接 <br>使用 Arp 解决硬件地址问题 <br>使用 nbtstat 解决 NetBIOS 名称问题 <br>使用 netstat 显示连接统计 <br>使用 tracert 跟踪网络连接 <br>使用 pathping 测试路由器 <br>使用 ipconfig /all 查看配置 <br>发现和解决 TCP/IP 网络问题时，先检查出现问题的计算机上的 TCP/IP 配置。可以 <br>使用 ipconfig 命令获得主机配置信息，包括 IP 地址、子网掩码和默认网关。
<p>注意
<p>对于 Windows 95 和 Windows 98 的客户机，请使用 winipcfg 命令而不是 ipconfi <br>g 命令。 <br>使用带 /all 选项的 ipconfig 命令时，将给出所有接口的详细配置报告，包括任何 <br>已配置的串行端口。使用 ipconfig /all，可以将命令输出重定向到某个文件，并将 <br>输出粘贴到其他文档中。也可以用该输出确认网络上每台计算机的 TCP/IP 配置，或 <br>者进一步调查 TCP/IP 网络问题。
<p>例如，如果计算机配置的 IP 地址与现有的 IP 地址重复，则子网掩码显示为 0.0.0 <br>.0。
<p>下面的范例是 ipconfig /all 命令输出，该计算机配置成使用 DHCP 服务器动态配置 <br>TCP/IP，并使用 WINS 和 DNS 服务器解析名称。
<p>Windows 2000 IP Configuration
<p>Node Type.. . . . . . . . : Hybrid <br>IP Routing Enabled.. . . . : No <br>WINS Proxy Enabled.. . . . : No
<p>Ethernet adapter Local Area Connection:
<p>Host Name.. . . . . . . . : corp1.microsoft.com <br>DNS Servers . . . . . . . : 10.1.0.200 <br>Description. . . . . . . : 3Com 3C90x Ethernet Adapter <br>Physical Address. . . . . : 00-60-08-3E-46-07 <br>DHCP Enabled.. . . . . . . : Yes <br>Autoconfiguration Enabled.: Yes <br>IP Address. . . . . . . . . : 192.168.0.112 <br>Subnet Mask. . . . . . . . : 255.255.0.0 <br>Default Gateway. . . . . . : 192.168.0.1 <br>DHCP Server. . . . . . . . : 10.1.0.50 <br>Primary WINS Server. . . . : 10.1.0.101 <br>Secondary WINS Server. . . : 10.1.0.102 <br>Lease Obtained.. . . . . . : Wednesday, September 02, 1998 10:32:13 AM <br>Lease Expires.. . . . . . : Friday, September 18, 1998 10:32:13 AM
<p><br>如果 TCP/IP 配置没有问题，下一步测试能够连接到 TCP/IP 网络上的其他主机。
<p>使用 ipconfig /renew 刷新配置 <br>解决 TCP/IP 网络问题时，先检查遇到问题的计算机上的 TCP/IP 配置。如果计算机 <br>启用 DHCP 并使用 DHCP 服务器获得配置，请使用 ipconfig /renew 命令开始刷新租 <br>约。
<p>使用 ipconfig /renew 时，使用 DHCP 的计算机上的所有网卡（除了那些手动配置的 <br>适配器）都尽量连接到 DHCP 服务器，更新现有配置或者获得新配置。
<p>也可以使用带 /release 选项的 ipconfig 命令立即释放主机的当前 DHCP 配置。有 <br>关 DHCP 和租用过程的详细信息，请参阅客户机如何获得配置。
<p>注意
<p>对于启用 DHCP 的 Windows 95 和 Windows 98 客户，请使用 winipcfg 命令的 rel <br>ease 和 renew 选项，而不是 ipconfig /release 和 ipconfig /renew 命令，手动 <br>释放或更新客户的 IP 配置租约。 <br>使用 ipconfig 管理 DNS 和 DHCP 类别 ID <br>也可以使用 ipconfig 命令：
<p>显示或重置 DNS 缓存。 <br>详细信息，请参阅使用 ipconfig 查看或重置客户解析程序缓存。
<p>刷新已注册的 DNS 名称。 <br>详细信息，请参阅使用 ipconfig 更新 DNS 客户注册。
<p>显示适配器的 DHCP 类别 ID。 <br>详细信息，请参阅显示客户机上的 DHCP 类别 ID 信息。
<p>设置适配器的 DHCP 类别 ID。 <br>详细信息，请参阅设置客户机上的 DHCP 类别 ID 信息。
<p>使用 Ping 测试连接 <br>Ping 命令有助于验证 IP 级的连通性。发现和解决问题时，可以使用 Ping 向目标主 <br>机名或 IP 地址发送 ICMP 回应请求。需要验证主机能否连接到 TCP/IP 网络和网络 <br>资源时，请使用 Ping。也可以使用 Ping 隔离网络硬件问题和不兼容配置。
<p>通常最好先用 Ping 命令验证本地计算机和网络主机之间的路由是否存在，以及要连 <br>接的网络主机的 IP 地址。Ping 目标主机的 IP 地址看它是否响应，如下：
<p>ping IP_address
<p>使用 Ping 时应该执行以下步骤：
<p>Ping 环回地址验证是否在本地计算机上安装 TCP/IP 以及配置是否正确。 <br>ping 127.0.0.1
<p>Ping 本地计算机的 IP 地址验证是否正确地添加到网络。 <br>ping IP_address_of_local_host
<p>Ping 默认网关的 IP 地址验证默认网关是否运行以及能否与本地网络上的本地主机通 <br>讯。 <br>ping IP_address_of_default_gateway
<p>Ping 远程主机的 IP 地址验证能否通过路由器通讯。 <br>ping IP_address_of_remote_host
<p>Ping 命令用 Windows 套接字样式的名称解析将计算机名解析成 IP 地址，所以如果 <br>用地址成功，但是用名称 Ping 失败，则问题出在地址或名称解析上，而不是网络连 <br>通性的问题。详细信息，请参阅使用 Arp 解决硬件地址问题。
<p>如果在任何点上都无法成功地使用 Ping，请确认：
<p>安装和配置 TCP/IP 之后重新启动计算机。 <br>&#8220;Internet 协议 (TCP/IP) 属性&#8221;对话框&#8220;常规&#8221;选项卡上的本地计算机的 IP 地址 <br>有效而且正确。 <br>启用 IP 路由，并且路由器之间的链路是可用的。 <br>您可以使用 Ping 命令的不同选项来指定要使用的数据包大小、要发送多少数据包、 <br>是否记录用过的路由、要使用的生存时间 (TTL) 值以及是否设置&#8220;不分段&#8221;标志。可 <br>以键入 ping -? 查看这些选项。
<p>下例说明如何向 IP 地址 172.16.48.10 发送两个 Ping，每个都是 1,450 字节：
<p>C:\&gt;ping -n 2 -l 1450 172.16.48.10 <br>Pinging 172.16.48.10 with 1450 bytes of data:
<p>Reply from 172.16.48.10:bytes=1450 time&lt;10ms TTL=32 <br>Reply from 172.16.48.10:bytes=1450 time&lt;10ms TTL=32
<p>Ping statistics for 157.59.8.1: <br>Packets:Sent = 2, Received = 2, Lost = 0 (0% loss), <br>Approximate roundtrip times in milli-seconds: <br>Minimum = 0ms, Maximum = 10ms, Average = 2ms <br>默认情况下，在显示&#8220;请求超时&#8221;之前，Ping 等待 1,000 毫秒（1 秒）的时间让每 <br>个响应返回。如果通过 Ping 探测的远程系统经过长时间延迟的链路，如卫星链路， <br>则响应可能会花更长的时间才能返回。可以使用 -w （等待）选项指定更长时间的超 <br>时。
<p>使用 Arp 解决硬件地址问题 <br>&#8220;地址解析协议 (ARP)&#8221;允许主机查找同一物理网络上的主机的媒体访问控制地址， <br>如果给出后者的 IP 地址。为使 ARP 更加有效，每个计算机缓存 IP 到媒体访问控制 <br>地址映射消除重复的 ARP 广播请求。
<p>可以使用 arp 命令查看和修改本地计算机上的 ARP 表项。arp 命令对于查看 ARP 缓 <br>存和解决地址解析问题非常有用。
<p>详细信息，请参阅查看&#8220;地址解析协议 (ARP)&#8221;缓存和添加静态 ARP 缓存项目。
<p>使用 nbtstat 解决 NetBIOS 名称问题 <br>TCP/IP 上的 NetBIOS (NetBT) 将 NetBIOS 名称解析成 IP 地址。TCP/IP 为 NetBI <br>OS 名称解析提供了很多选项，包括本地缓存搜索、WINS 服务器查询、广播、DNS 服 <br>务器查询以及 Lmhosts 和主机文件搜索。
<p style="COLOR: red">Nbtstat 是解决 NetBIOS 名称解析问题的有用工具。可以使用 nbtstat 命令删除或 <br>更正预加载的项目：
<p style="COLOR: red">nbtstat -n 显示由服务器或重定向器之类的程序在系统上本地注册的名称。 <br>nbtstat -c 显示 NetBIOS 名称缓存，包含其他计算机的名称对地址映射。 <br>nbtstat -R 清除名称缓存，然后从 Lmhosts 文件重新加载。 <br>nbtstat -RR 释放在 WINS 服务器上注册的 NetBIOS 名称，然后刷新它们的注册。 <br>nbtstat -a name 对 name 指定的计算机执行 NetBIOS 适配器状态命令。适配器状态 <br>命令将返回计算机的本地 NetBIOS 名称表，以及适配器的媒体访问控制地址。 <br>nbtstat -S 列出当前的 NetBIOS 会话及其状态（包括统计），如下例所示： <br>NetBIOS connection table
<p>Local name State &nbsp; In/out Remote Host &nbsp;Input &nbsp;Output <br>------------------------------------------------------------------ <br>CORP1 &lt;00&gt; Connected Out &nbsp;CORPSUP1&lt;20&gt; &nbsp;6MB &nbsp; 5MB <br>CORP1 &lt;00&gt; Connected Out &nbsp;CORPPRINT&lt;20&gt; 108KB &nbsp;116KB <br>CORP1 &lt;00&gt; Connected Out &nbsp;CORPSRC1&lt;20&gt; &nbsp;299KB &nbsp;19KB <br>CORP1 &lt;00&gt; Connected Out &nbsp;CORPEMAIL1&lt;20&gt; 324KB &nbsp;19KB <br>CORP1 &lt;03&gt; Listening <br>使用 netstat 显示连接统计 <br>可以使用 netstat 命令显示协议统计信息和当前的 TCP/IP 连接。netstat -a 命令 <br>将显示所有连接，而 netstat -r 显示路由表和活动连接。netstat -e 命令将显示 <br>Ethernet 统计信息，而 netstat -s 显示每个协议的统计信息。如果使用 netstat <br>-n，则不能将地址和端口号转换成名称。下面是 netstat 的输出示例：
<p>C:\&gt;netstat -e <br>Interface Statistics
<p>Received &nbsp; Sent <br>Bytes &nbsp; &nbsp; &nbsp; &nbsp; 3995837940 &nbsp;47224622 <br>Unicast packets &nbsp; &nbsp;120099 &nbsp; &nbsp;131015 <br>Non-unicast packets &nbsp;7579544 &nbsp; &nbsp;3823 <br>Discards &nbsp; &nbsp; &nbsp; &nbsp;0 &nbsp; &nbsp; &nbsp; 0 <br>Errors &nbsp; &nbsp; &nbsp; &nbsp; 0 &nbsp; &nbsp; &nbsp; 0 <br>Unknown protocols &nbsp; 363054211
<p>C:\&gt;netstat -a
<p>Active Connections
<p>Proto Local Address &nbsp; Foreign Address &nbsp; &nbsp;State <br>TCP CORP1:1572 &nbsp; &nbsp;172.16.48.10:nbsession &nbsp;ESTABLISHED <br>TCP CORP1:1589 &nbsp; &nbsp;172.16.48.10:nbsession &nbsp;ESTABLISHED <br>TCP CORP1:1606 &nbsp; &nbsp;172.16.105.245:nbsession ESTABLISHED <br>TCP CORP1:1632 &nbsp; &nbsp;172.16.48.213:nbsession ESTABLISHED <br>TCP CORP1:1659 &nbsp; &nbsp;172.16.48.169:nbsession ESTABLISHED <br>TCP CORP1:1714 &nbsp; &nbsp;172.16.48.203:nbsession ESTABLISHED <br>TCP CORP1:1719 &nbsp; &nbsp;172.16.48.36:nbsession &nbsp;ESTABLISHED <br>TCP CORP1:1241 &nbsp; &nbsp;172.16.48.101:nbsession ESTABLISHED <br>UDP CORP1:1025 &nbsp; &nbsp;*:* <br>UDP CORP1:snmp &nbsp; &nbsp;*:* <br>UDP CORP1:nbname &nbsp; *:* <br>UDP CORP1:nbdatagram *:* <br>UDP CORP1:nbname &nbsp; *:* <br>UDP CORP1:nbdatagram *:*
<p>C:\&gt;netstat -s <br>IP Statistics
<p>Packets Received &nbsp; &nbsp; &nbsp; = 5378528 <br>Received Header Errors &nbsp; &nbsp;= 738854 <br>Received Address Errors &nbsp; = 23150 <br>Datagrams Forwarded &nbsp; &nbsp; = 0 <br>Unknown Protocols Received &nbsp;= 0 <br>Received Packets Discarded &nbsp;= 0 <br>Received Packets Delivered &nbsp;= 4616524 <br>Output Requests &nbsp; &nbsp; &nbsp; = 132702 <br>Routing Discards &nbsp; &nbsp; &nbsp; = 157 <br>Discarded Output Packets &nbsp; = 0 <br>Output Packet No Route &nbsp; &nbsp;= 0 <br>Reassembly Required &nbsp; &nbsp; = 0 <br>Reassembly Successful &nbsp; &nbsp; &nbsp; = 0 <br>Reassembly Failures &nbsp; &nbsp; &nbsp; &nbsp;= <br>Datagrams Successfully Fragmented = 0 <br>Datagrams Failing Fragmentation &nbsp;= 0 <br>Fragments Created &nbsp; &nbsp; &nbsp; &nbsp; = 0
<p>ICMP Statistics <br>Received Sent <br>Messages &nbsp; &nbsp; &nbsp; &nbsp; 693 &nbsp; &nbsp;4 <br>Errors &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0 &nbsp; &nbsp; 0 <br>Destination Unreachable 685 &nbsp; &nbsp;0 <br>Time Exceeded &nbsp; &nbsp; &nbsp;0 &nbsp; &nbsp; 0 <br>Parameter Problems &nbsp; &nbsp;0 &nbsp; &nbsp; 0 <br>Source Quenches &nbsp; &nbsp; 0 &nbsp; &nbsp; 0 <br>Redirects &nbsp; &nbsp; &nbsp; &nbsp;0 &nbsp; &nbsp; 0 <br>Echoes &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;4 &nbsp; &nbsp; 0 <br>Echo Replies &nbsp; &nbsp; &nbsp; 0 &nbsp; &nbsp; 4 <br>Timestamps &nbsp; &nbsp; &nbsp; &nbsp;0 &nbsp; &nbsp; 0 <br>Timestamp Replies &nbsp; &nbsp;0 &nbsp; &nbsp; 0 <br>Address Masks &nbsp; &nbsp; &nbsp;0 &nbsp; &nbsp; 0 <br>Address Mask Replies &nbsp; 0 &nbsp; &nbsp; 0
<p>TCP Statistics
<p>Active Opens &nbsp; &nbsp; &nbsp; &nbsp; = 597 <br>Passive Opens &nbsp; &nbsp; &nbsp; &nbsp;= 135 <br>Failed Connection Attempts &nbsp;= 107 <br>Reset Connections &nbsp; &nbsp; &nbsp;= 91 <br>Current Connections &nbsp; &nbsp; = 8 <br>Segments Received &nbsp; &nbsp; &nbsp;= 106770 <br>Segments Sent &nbsp; &nbsp; &nbsp; &nbsp;= 118431 <br>Segments Retransmitted &nbsp; &nbsp;= 461
<p>UDP Statistics
<p>Datagrams Received &nbsp;= 4157136 <br>No Ports &nbsp; &nbsp; &nbsp; = 351928 <br>Receive Errors &nbsp; &nbsp;= 2 <br>Datagrams Sent &nbsp; &nbsp;= 13809
<p>使用 tracert 跟踪网络连接 <br>Tracert（跟踪路由）是路由跟踪实用程序，用于确定 IP 数据报访问目标所采取的路 <br>径。Tracert 命令用 IP 生存时间 (TTL) 字段和 ICMP 错误消息来确定从一个主机到 <br>网络上其他主机的路由。
<p>Tracert 工作原理 <br>通过向目标发送不同 IP 生存时间 (TTL) 值的&#8220;Internet 控制消息协议 (ICMP)&#8221;回 <br>应数据包，Tracert 诊断程序确定到目标所采取的路由。要求路径上的每个路由器在 <br>转发数据包之前至少将数据包上的 TTL 递减 1。数据包上的 TTL 减为 0 时，路由器 <br>应该将&#8220;ICMP 已超时&#8221;的消息发回源系统。
<p>Tracert 先发送 TTL 为 1 的回应数据包，并在随后的每次发送过程将 TTL 递增 1， <br>直到目标响应或 TTL 达到最大值，从而确定路由。通过检查中间路由器发回的&#8220;ICM <br>P 已超时&#8221;的消息确定路由。某些路由器不经询问直接丢弃 TTL 过期的数据包，这在 <br>Tracert 实用程序中看不到。
<p>Tracert 命令按顺序打印出返回&#8220;ICMP 已超时&#8221;消息的路径中的近端路由器接口列表 <br>。如果使用 -d 选项，则 Tracert 实用程序不在每个 IP 地址上查询 DNS。
<p>在下例中，数据包必须通过两个路由器（10.0.0.1 和 192.168.0.1）才能到达主机 <br>172.16.0.99。主机的默认网关是 10.0.0.1，192.168.0.0 网络上的路由器的 IP 地 <br>址是 192.168.0.1。
<p>C:\&gt;tracert 172.16.0.99 -d <br>Tracing route to 172.16.0.99 over a maximum of 30 hops <br>1 &nbsp;2s &nbsp;3s &nbsp;2s 10,0.0,1 <br>2 &nbsp;75 ms &nbsp;83 ms &nbsp;88 ms 192.168.0.1 <br>3 &nbsp;73 ms &nbsp;79 ms &nbsp;93 ms 172.16.0.99 <br>Trace complete. <br>用 tracert 解决问题 <br>可以使用 tracert 命令确定数据包在网络上的停止位置。下例中，默认网关确定 19 <br>2.168.10.99 主机没有有效路径。这可能是路由器配置的问题，或者是 192.168.10. <br>0 网络不存在（错误的 IP 地址）。
<p>C:\&gt;tracert 192.168.10.99
<p>Tracing route to 192.168.10.99 over a maximum of 30 hops
<p>1 10.0.0.1 reports:Destination net unreachable.
<p>Trace complete.
<p>Tracert 实用程序对于解决大网络问题非常有用，此时可以采取几条路径到达同一个 <br>点。
<p>Tracert 命令行选项 <br>Tracert 命令支持多种选项，如下表所示。
<p>tracert [-d] [-h maximum_hops] [-j host-list] [-w timeout] target_name
<p>选项 描述 &nbsp;<br>-d 指定不将 IP 地址解析到主机名称。 <br>-h maximum_hops 指定跃点数以跟踪到称为 target_name 的主机的路由。 <br>-j host-list 指定 Tracert 实用程序数据包所采用路径中的路由器接口列表。 <br>-w timeout 等待 timeout 为每次回复所指定的毫秒数。 <br>target_name 目标主机的名称或 IP 地址。
<p>详细信息，请参阅使用 tracert 命令跟踪路径。
<p>使用 pathping 测试路由器 <br>pathping 命令是一个路由跟踪工具，它将 ping 和 tracert 命令的功能和这两个工 <br>具所不提供的其他信息结合起来。pathping 命令在一段时间内将数据包发送到到达最 <br>终目标的路径上的每个路由器，然后基于数据包的计算机结果从每个跃点返回。由于 <br>命令显示数据包在任何给定路由器或链接上丢失的程度，因此可以很容易地确定可能 <br>导致网络问题的路由器或链接。某些选项是可用的，如下表所示。
<p>选项 名称 功能 <br>-n Hostnames 不将地址解析成主机名。 <br>-h Maximum hops 搜索目标的最大跃点数。 <br>-g Host-list 沿着路由列表释放源路由。 <br>-p Period 在 ping 之间等待的毫秒数。 <br>-q Num_queries 每个跃点的查询数。 <br>-w Time-out 为每次回复所等待的毫秒数。 <br>-T Layer 2 tag 将第 2 层优先级标记（例如，对于 IEEE 802.1p）连接到数据包并 <br>将它发送到路径中的每个网络设备。这有助于标识没有正确配置第 2 层优先级的网络 <br>设备。-T 开关用于测试服务质量 (QoS) 连通性。 <br>-R RSVP test Che检查以确定路径中的每个路由器是否支持&#8220;资源保留协议 (RSVP)&#8221; <br>，此协议允许主机为数据流保留一定量的带宽。 -R 开关用于测试服务质量 (QoS) 连 <br>通性。
<p>默认的跃点数是 30，并且超时前的默认等待时间是 3 秒。默认时间是 250 毫秒，并 <br>且沿着路径对每个路由器进行查询的次数是 100。
<p>以下是典型的 pathping 报告。跃点列表后所编辑的统计信息表明在每个独立路由器 <br>上数据包丢失的情况。
<p><br>D:\&gt;pathping -n msw
<p>Tracing route to msw [7.54.1.196] <br>over a maximum of 30 hops: <br>0 172.16.87.35 <br>1 172.16.87.218 <br>2 192.68.52.1 <br>3 192.68.80.1 <br>4 7.54.247.14 <br>5 7.54.1.196
<p>Computing statistics for 125 seconds... <br>&nbsp; &nbsp; &nbsp;Source to Here &nbsp;This Node/Link <br>Hop RTT &nbsp;Lost/Sent = Pct Lost/Sent = Pct Address <br>0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;172.16.87.35 <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0/ 100 = 0% &nbsp;| <br>1 &nbsp;41ms &nbsp; 0/ 100 = 0% &nbsp; 0/ 100 = 0% 172.16.87.218 <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 13/ 100 = 13% &nbsp;| <br>2 &nbsp;22ms &nbsp;16/ 100 = 16% &nbsp; 3/ 100 = 3% 192.68.52.1 <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0/ 100 = 0% &nbsp;| <br>3 &nbsp;24ms &nbsp;13/ 100 = 13% &nbsp; 0/ 100 = 0% 192.68.80.1 <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0/ 100 = 0% &nbsp;| <br>4 &nbsp;21ms &nbsp;14/ 100 = 14% &nbsp; 1/ 100 = 1% 10.54.247.14 <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0/ 100 = 0% &nbsp;| <br>5 &nbsp;24ms &nbsp;13/ 100 = 13% &nbsp; 0/ 100 = 0% 10.54.1.196
<p>Trace complete.
<p>当运行 pathping 时，在测试问题时首先查看路由的结果。此路径与 tracert 命令所 <br>显示的路径相同。然后 pathping 命令对下一个 125 毫秒显示忙消息（此时间根据跃 <br>点计数变化）。在此期间，pathping 从以前列出的所有路由器和它们之间的链接之间 <br>收集信息。在此期间结束时，它显示测试结果。
<p>最右边的两栏 This Node/Link Lost/Sent=Pct 和 Address 包含的信息最有用。172 <br>.16.87.218（跃点 1）和 192.68.52.1（跃点 2）丢失 13% 的数据包。 所有其他链 <br>接工作正常。在跃点 2 和 4 中的路由器也丢失寻址到它们的数据包（如 This Node <br>/Link 栏中所示），但是该丢失不会影响转发的路径。
<p>对链接显示的丢失率（在最右边的栏中标记为 |）表明沿路径转发丢失的数据包。该 <br>丢失表明链接阻塞。对路由器显示的丢失率（通过最右边栏中的 IP 地址显示）表明 <br>这些路由器的 CPU 可能超负荷运行。这些阻塞的路由器可能也是端对端问题的一个因 <br>素，尤其是在软件路由器转发数据包时。</p>
</div>
<img src ="http://www.cppblog.com/ivy-jie/aggbug/85571.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ivy-jie/" target="_blank">ivy-jie</a> 2009-05-24 09:24 <a href="http://www.cppblog.com/ivy-jie/articles/85571.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>MCSE :TCP/IP 考题</title><link>http://www.cppblog.com/ivy-jie/articles/85495.html</link><dc:creator>ivy-jie</dc:creator><author>ivy-jie</author><pubDate>Sat, 23 May 2009 01:58:00 GMT</pubDate><guid>http://www.cppblog.com/ivy-jie/articles/85495.html</guid><wfw:comment>http://www.cppblog.com/ivy-jie/comments/85495.html</wfw:comment><comments>http://www.cppblog.com/ivy-jie/articles/85495.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/ivy-jie/comments/commentRss/85495.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ivy-jie/services/trackbacks/85495.html</trackback:ping><description><![CDATA[<p>Question 1. Under Windows NT, what command would you use if you wanted to trace a packet from its source host to a destination host? <br><br>&nbsp;&nbsp;&nbsp; A. TRACERT<br><br>&nbsp;&nbsp;&nbsp; B. ROUTE<br><br>&nbsp;&nbsp;&nbsp; C. NBTSTAT<br><br>&nbsp;&nbsp;&nbsp; D. IPCONFIG <br><br>&nbsp;&nbsp;&nbsp; The TRACERT utility is Microsoft's own, used to trace a packet from its source ( your computer ) to a destination host ( a remote computer ).<br><br>&nbsp;&nbsp;&nbsp; Question 2. If you wanted to display all entries in the ARP cache, which of the following utilities would you use? <br><br>&nbsp;&nbsp; &nbsp;A . ARP - G<br><br>&nbsp;&nbsp; &nbsp;B. ARP - E<br><br>&nbsp;&nbsp;&nbsp; C. ARP - D<br><br>&nbsp;&nbsp;&nbsp; D. ARP - S</p>
<p>&nbsp;&nbsp;&nbsp; To display all entries in the ARP ( Address Resolution Protocol ) cache, you would use the ARP utility with the -G or - A switch. They are the same thing. To get the answer type "arp /?" at the command prompt. </p>
<p>&nbsp;&nbsp;&nbsp; ARP ( Address Resolution Protocol ) is used to obtain hardware ( MAC = Media Access Control ) addresses for communications with a destination host.<br><br>&nbsp;&nbsp;&nbsp; Question 3. You notice that the subnet mask is 0.0.0.0 on your Windows NT computer while using the IPCONFIG utility at the command prompt to check for IP address configuration. What does it mean when the IPCONFIG utility displays a subnet mask of 0.0.0.0? <br><br>&nbsp;&nbsp;&nbsp; A. The default gateway on your computer does not match the default gateway of the network.<br><br>&nbsp;&nbsp;&nbsp; B. Your computer has the same subnet mask as another computer on the network.<br><br>&nbsp;&nbsp;&nbsp; C. Your computer does not have the correct IP address class specified for it.<br><br>&nbsp;&nbsp;&nbsp; D. Your computer has the same IP address as another computer on the network. </p>
<p>&nbsp;&nbsp;&nbsp; The most likely cause in this scenario is that your computer has the same IP address as another computer in the network. When this happens, running IPCONFIG will yield an IP address of 0.0.0.0.<br>&nbsp;<br>&nbsp;&nbsp;&nbsp; Question 4. If you want to copy files from one Windows NT computer to another, what TCP / IP utility would you use?</p>
<p>&nbsp;&nbsp;&nbsp; A . RCP<br><br>&nbsp;&nbsp;&nbsp; B. REXEC<br><br>&nbsp;&nbsp;&nbsp; C. TELNET<br><br>&nbsp;&nbsp;&nbsp; D. TRACERT</p>
<p>&nbsp;&nbsp;&nbsp; The RCP ( Remote Copy ) is Microsoft's own TCP / IP utility. It is used to copy files from a source Windows NT computer to a destination ( remote ) Windows NT computer, or vice-versa. Type "rcp /?" at the command prompt to get the command's full syntax.<br>　&nbsp;<br>&nbsp;&nbsp;&nbsp; Question 5. Use the following diagram to answer this question :&nbsp;<br><br>&nbsp;&nbsp;&nbsp;You are working on your Windows NT workstation, SMALLNT, and you would like to communicate with another Windows NT computer, BIGNT. If both computers are on the same local subnet , where does SMALLNT look for the hardware address of the destination host? ( BIGNT in this case )</p>
<p>&nbsp;&nbsp;&nbsp; A. In its own ARP cache.<br><br>&nbsp;&nbsp;&nbsp; B. In the ARP cache of the destination host, BIGNT in this case.<br><br>&nbsp;&nbsp;&nbsp; C. If there is a DHCP server present , then in the ARP cache of the DHCP server. <br><br>&nbsp;&nbsp;&nbsp; D. In the LMHOSTS or HOSTS file of the source computer.</p>
<p>&nbsp;&nbsp;&nbsp; The ARP protocol ( and NOT the ARP command ) is used to map IP addresses to hardware addresses ( MAC addresses ). Anytime you communicate with a destination host that is on the same subnet ( locally ), then the hardware address of the destination host is obtained from the source host's LOCAL ARP cache. In this scenario, BIGNT's hardware address is obtained from SMALLNT's own ARP cache since both computers are on the same network.</p>
<p>Question 6. You have a print device connected to a server running the LPD service. From your Windows NT computer, you would like to obtain the status of the print device. What utility would you use to achieve the task? <br><br>&nbsp;&nbsp;&nbsp; A. LPD<br><br>&nbsp;&nbsp;&nbsp; B. NET USE<br><br>&nbsp;&nbsp;&nbsp; C. LPQ<br><br>&nbsp;&nbsp;&nbsp; D. GETDAEMON </p>
<p>&#160;</p>
<p>&nbsp;&nbsp;&nbsp; The LPD ( Line Printer Daemon ) is a TCP / IP printing service. A print server that has a TCP / IP print device connected to it must have the LPD service installed on it. However, to obtain the status of a TCP / IP print device ( or print queue as it is often called in the TCP / IP circle ), you would use the LPQ command.</p>
<p>&nbsp;&nbsp;&nbsp; Type "lpq /?" at the command prompt to get the proper syntax. Pay close attention to the "-S" and "-P" switches. For the "-S" switch, you can specify the NAME or IP address of the print server running the LPD service. </p>
<p>&nbsp;&nbsp;&nbsp; Question : Under Windows NT Server 4.0, how do you install the LPD service?</p>
<p>&nbsp;&nbsp;&nbsp; Answer : Under Windows NT, the LPD service is known as "Microsoft TCP / IP Printing" ===&gt; right-click Network Neighborhood | Properties | Services tab | Add... | "Microsoft TCP / IP Printing" service.<br>　 <br>&nbsp;&nbsp;&nbsp; Question 7. Let's say that you want to run a process on a remote host that is using the REXEC service, what Microsoft TCP / IP utility would you use? <br><br>&nbsp;&nbsp;&nbsp; A. RCP<br><br>&nbsp;&nbsp;&nbsp; B. REXEC<br><br>&nbsp;&nbsp;&nbsp; C. TELNET<br><br>&nbsp;&nbsp;&nbsp; D. FTP</p>
<p>&nbsp;&nbsp;&nbsp; The REXEC ( Remote Execute ) command is Microsoft's home-grown utility used to run processes on a remote computer that is also running the REXEC service. Type "rexec /?" at the command prompt to get the full syntax.<br>&nbsp;<br>&nbsp;&nbsp;&nbsp; Question 8. If you want to retrieve system information from a remote host running the Finger service, what TCP / IP utility would you use? <br><br>&nbsp;&nbsp;&nbsp; A. REXEC<br><br>&nbsp;&nbsp;&nbsp; B. PING<br><br>&nbsp;&nbsp;&nbsp; C. RCP<br><br>&nbsp;&nbsp;&nbsp; D. FINGER</p>
<p>&nbsp;&nbsp;&nbsp; The FINGER utility is used to obtain system information from a remote host that is using the Finger service. To get the proper syntax, type "finger" at the command prompt.<br>　 <br>&nbsp;&nbsp;&nbsp; Question 9. Let's say that you want a DHCP client to give up its lease with a DHCP server, what command would you use to accomplish the task? <br><br>&nbsp;&nbsp;&nbsp; A. ipconfig / endlease<br><br>&nbsp;&nbsp;&nbsp; B. ipconfig / release<br><br>&nbsp;&nbsp;&nbsp; C. route / release<br><br>&nbsp;&nbsp;&nbsp; D. route / endlease</p>
<p>&nbsp;&nbsp;&nbsp; The IPCONFIG / RELEASE command is used to send a DHCPRELEASE message from a DHCP client to a DHCP server. The DHCPRELEASE message specifies that a client wishes to give up its current lease with the DHCP server. Type, "ipconfig /?" at the command prompt to display all the switches of the utility.<br>&nbsp;<br>&nbsp;&nbsp;&nbsp; Question 10. You would like to see a list of NetBIOS computer names that have been resolved into IP addresses on your Windows NT computer. Which of the following utilities would you use? <br><br>&nbsp;&nbsp;&nbsp; A. ARP<br><br>&nbsp;&nbsp;&nbsp; B. NetBIOS<br><br>&nbsp;&nbsp;&nbsp; C. NETSTAT<br><br>&nbsp;&nbsp;&nbsp; D. NBTSTAT</p>
<p>&nbsp;&nbsp;&nbsp; You can use the "nbtstat" utitliy to view all NetBIOS computer names that have been resolved into IP addresses. To see the NetBIOS local name table of your workstation, use "nbtstat -n."</p>
<img src ="http://www.cppblog.com/ivy-jie/aggbug/85495.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ivy-jie/" target="_blank">ivy-jie</a> 2009-05-23 09:58 <a href="http://www.cppblog.com/ivy-jie/articles/85495.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>NetBIOS函数</title><link>http://www.cppblog.com/ivy-jie/articles/85491.html</link><dc:creator>ivy-jie</dc:creator><author>ivy-jie</author><pubDate>Sat, 23 May 2009 01:34:00 GMT</pubDate><guid>http://www.cppblog.com/ivy-jie/articles/85491.html</guid><wfw:comment>http://www.cppblog.com/ivy-jie/comments/85491.html</wfw:comment><comments>http://www.cppblog.com/ivy-jie/articles/85491.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/ivy-jie/comments/commentRss/85491.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ivy-jie/services/trackbacks/85491.html</trackback:ping><description><![CDATA[<p>1&nbsp; Win32应用程序可以使用Network Basic Input/Output System（NetBIOS）接口与网络中的其他计算机上的应用程序进行通讯。NetBIOS接口包括一系列显式命令，由一个被称为网络控制块（NCB）的结构提供。应用程序可以对任何支持NetBIOS接口的协议发出NetBIOS命令。<br>2&nbsp; netbios &nbsp; 函数用来解释并执行一个专有的NCB块结构 &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; UCHAR &nbsp; Netbios( &nbsp; <br>&nbsp; &nbsp; &nbsp; PNCB &nbsp; pncb &nbsp; &nbsp; &nbsp; // &nbsp; 指向网络控制块的指针 &nbsp; <br>&nbsp; ); &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; 返回值: &nbsp; <br>&nbsp; &lt;1&gt;作为同步请求,返回值就是NCB的返回代码,同时这个返回代码也包含在NCB的ncb_retcode成员中 &nbsp; <br>&nbsp; &lt;2&gt;作为异步请求有下面几种情况: &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; 1.如果异步命令在netbios()返回返回他的调用者之前已经完成,情况同&lt;1&gt; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; 2.与1.相反,返回值就是0 &nbsp; <br>&nbsp; &lt;3&gt;如果pncb指针无效返回值是NRC_BADNCB &nbsp; <br>&nbsp; &lt;4&gt;如果ncb_length成员的值不正确或者是ncb_buffer区域被写保护返回值为NRC_BUFLEN &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; 下面讲讲NCB控制块的结构: &nbsp; <br>&nbsp; typedef &nbsp; struct &nbsp; _NCB &nbsp; { &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; UCHAR &nbsp; &nbsp; ncb_command; &nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; UCHAR &nbsp; &nbsp; ncb_retcode; &nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; UCHAR &nbsp; &nbsp; ncb_lsn; &nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; UCHAR &nbsp; &nbsp; ncb_num; &nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PUCHAR &nbsp; ncb_buffer; &nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; WORD &nbsp; &nbsp; &nbsp; ncb_length; &nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; UCHAR &nbsp; &nbsp; ncb_callname[NCBNAMSZ]; &nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; UCHAR &nbsp; &nbsp; ncb_name[NCBNAMSZ]; &nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; UCHAR &nbsp; &nbsp; ncb_rto; &nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; UCHAR &nbsp; &nbsp; ncb_sto; &nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; void &nbsp; (*ncb_post) &nbsp; (struct &nbsp; _NCB &nbsp; *); &nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; UCHAR &nbsp; &nbsp; ncb_lana_num; &nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; UCHAR &nbsp; &nbsp; ncb_cmd_cplt; &nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; UCHAR &nbsp; &nbsp; ncb_reserve[10]; &nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; HANDLE &nbsp; ncb_event; &nbsp; &nbsp; <br>&nbsp; } &nbsp; NCB;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>3&nbsp; ncb_command:指定一个命令码和一个该NCB是同步还是异步处理的标志,如果ASYNCH常量通过"|"运 &nbsp; 算符与命令码组合的话,那么这个NCB块将会异步执行。 &nbsp; <br>&nbsp; &nbsp; .NCBACTION:用于 &nbsp; Win &nbsp; NT非标准的Netbios &nbsp; 3.0的标准命令 &nbsp; <br>&nbsp; &nbsp; .NCBADDGRNAME:添加一个组名字到本地名字表,这个名称不能被网络上的其他进程作为一个唯一的 &nbsp; 名字来使用但是他可以被其他进程作为组名字来添加 &nbsp; <br>&nbsp; &nbsp; .NCBADDNAME:添加一个唯一名字到本地名字表,TDI驱动程序保证这个名字在网络中的唯一性 &nbsp; <br>&nbsp; &nbsp; .NCBASTAT:返回一个本地或者远程适配器的状态,当使用这个命令的时候,ncb_buffer &nbsp; 成员指向一个ADAPTER_STATUS结构后面紧跟着一个NAME_BUFFER结构数组 &nbsp; <br>&nbsp; &nbsp; .NCBCALL:用另外一个名字开启一个会话 &nbsp; <br>&nbsp; &nbsp; .NCBCANCEL:终止前一个未执行完的命令 &nbsp; <br>&nbsp; &nbsp; .NCBCHAINSEND:发送两份数据缓冲到指定的会话伙伴 &nbsp; <br>&nbsp; &nbsp; .NCBCHAINSENDNA:发送两份数据缓冲到指定的会话伙伴,但不等待对方应答就立即返回 &nbsp; <br>&nbsp; &nbsp; .NCBDELNAME:从本地名字表中删除一个名字 &nbsp; <br>&nbsp; &nbsp; .NCBDGRECV:接收来自宁一个名字的数据包 &nbsp; <br>&nbsp; &nbsp; .NCBDGRECVBC:接收来自宁一个名字的以广播方式发送的数据包 &nbsp; <br>&nbsp; &nbsp; .NCBDGSEND:发送一个数据包到一个指定的名字(进程) &nbsp; <br>&nbsp; &nbsp; .NCBDGSENDBC:发送一个数据包到局域网中的每一台主机 &nbsp; <br>&nbsp; &nbsp; .NCBENUM:用于WinNT,非标准的Netbios3.0的命令 &nbsp; <br>&nbsp; &nbsp; .NCBFINDNAME:定位一个名字在网络中的位置,此时ncb_buffer指向FIND_NAME_HEADER结构,同时后面紧跟着一个或者多个FIND_NAME_BUFFER结构 &nbsp; <br>&nbsp; &nbsp; .NCBHANGUP:关闭一个指定的会话 &nbsp; <br>&nbsp; &nbsp; .NCBLISTEN:允许一个会话以另外一个名字打开(本地或者远程的会话都可以) &nbsp; <br>&nbsp; &nbsp; .NCBRECV:从一个指定的会话伙伴接收数据 &nbsp; <br>&nbsp; &nbsp; .NCBRECVANY:从任何一个其他的以一个指定的名字通信的会话接收数据 &nbsp; <br>&nbsp; &nbsp; .NCBRESET:复位一个网络适配器,在他接收任何命令(与ncb_lana_num成员有相同的数字)之前必须进行复位操作???? &nbsp; <br>&nbsp; &nbsp; .NCBSEND:发送数据到指定的会话伙伴 &nbsp; <br>&nbsp; &nbsp; .NECBSENDNA:发送数据到指定的会话伙伴后不等待应答立即返回 &nbsp; <br>&nbsp; &nbsp; .NCBSSTAT:返回某个会话的状态,指定这个命令以后ncb_buffer成员指向一个SESSION_HEADER &nbsp; 结构,后面紧接着一个或多个SESSION_BUFFER &nbsp; 结构 &nbsp; <br>&nbsp; &nbsp; .NCBUNLINK:断开一个适配器的连接,该命令的设置是处于兼容性的考虑,在Win32中不支持该命令</p>
<img src ="http://www.cppblog.com/ivy-jie/aggbug/85491.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ivy-jie/" target="_blank">ivy-jie</a> 2009-05-23 09:34 <a href="http://www.cppblog.com/ivy-jie/articles/85491.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>