landyjie
驱动牛犊
驱动牛犊
  • 注册日期2008-09-16
  • 最后登录2018-04-07
  • 粉丝0
  • 关注0
  • 积分-23分
  • 威望56点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
  • 社区居民
阅读:3211回复:2

【求助】DHCP报文格式、分析

楼主#
更多 发布于:2012-06-30 16:32
我用VB写了简短几句:

Dim i
Private Sub Form_Load()
w.Protocol = sckUDPProtocol
w.Bind 67
End Sub
Private Sub w_DataArrival(ByVal bytesTotal As Long)
Me.Caption = bytesTotal
Open "c:\t" & i & ".txt" For Binary As #1
Dim b
w.GetData b
Put #1, , b
Close #1
i = i + 1
End Sub

然后我拔插网线后收到4个回复,下面是第一个,应该是DHCP discover 包:

Offset 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

00000000 11 20 01 00 2C 01 00 00 00 00 00 00 01 01 06 00 . ..,...........
00000016 B1 05 66 6C 00 00 00 00 00 00 00 00 00 00 00 00 ?fl............
00000032 00 00 00 00 00 00 00 00 00 1A 73 4F A1 59 00 00 ..........sO?..
00000048 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000064 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000080 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000096 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000112 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000128 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000144 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000160 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000176 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000192 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000208 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000224 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000240 00 00 00 00 00 00 00 00 63 82 53 63 35 01 01 74 ........c係c5..t
00000256 01 01 3D 07 01 00 1A 73 4F A1 59 0C 0F 63 68 69 ..=....sO?..chi
00000272 6E 61 2D 61 32 32 38 39 31 38 66 62 3C 08 4D 53 na-a228918fb<.MS
00000288 46 54 20 35 2E 30 37 0B 01 0F 03 06 2C 2E 2F 1F FT 5.07.....,./.
00000304 21 F9 2B 2B 02 DC 00 FF !?+.?
驱网无线,快乐无限
landyjie
驱动牛犊
驱动牛犊
  • 注册日期2008-09-16
  • 最后登录2018-04-07
  • 粉丝0
  • 关注0
  • 积分-23分
  • 威望56点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
  • 社区居民
沙发#
发布于:2012-06-30 16:35
接上
我再把端口改成68,下面是收到的第一个包:

Offset 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

00000000 11 20 01 00 22 01 00 00 00 00 00 00 02 01 06 00 . .."...........
00000016 5E CE 51 F2 00 00 00 00 00 00 00 00 C0 A8 6F 45 ^蜵?.......括oE
00000032 C0 A8 6F 6F 00 00 00 00 00 1A 73 4F A1 59 00 00 括oo......sO?..
00000048 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000064 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000080 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000096 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000112 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000128 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000144 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000160 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000176 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000192 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000208 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000224 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000240 00 00 00 00 00 00 00 00 63 82 53 63 35 01 02 01 ........c係c5...
00000256 04 FF FF FF 00 3A 04 00 00 A8 C0 3B 04 00 01 27 .
驱网无线,快乐无限
landyjie
驱动牛犊
驱动牛犊
  • 注册日期2008-09-16
  • 最后登录2018-04-07
  • 粉丝0
  • 关注0
  • 积分-23分
  • 威望56点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
  • 社区居民
板凳#
发布于:2012-06-30 16:35
00000272 50 33 04 00 01 51 80 36 04 C0 A8 6F 6F 03 04 C0 P3...Q
00000288 A8 6F 6F 06 08 77 06 06 06 CA 6A 00 14 FF ╫o..w...蔶..
 
 
问题:
1。 数据开始00000000 11 20 01 00 2C 01 00 00 00 00 00 00  代表的是什么?我写程序怎么去组这些数据?
2。 第一个数据包结尾处63 82 53 63 带表的是什么?我写程序怎么去组这些数据?
3。 接着问题2后面35 01 01 代表的是DHCP Discover,帮我详细分析一下后面的内容。如果我自己写客户端,35 01 01后面哪些是必须的?
4。 第二个包的内容我已经知道是网卡参数方面的了。重点解释前3个问题吧。
驱网无线,快乐无限
游客

返回顶部