1. 原始套接字是否能访问IP包的头部,但却不能访问数据链路层的帧头?2. 如果我想用计算机(装有以太网卡)模拟一种新的数据链路层协议,即数据链路层的帧将重新封装,该如何做呢?即用什么方式(汇编除外)将自定义的数据链路层帧通过以太网卡发送出去呢?3. 若能通过以太网卡发送这样的帧,那么以太网卡能接收这种帧吗?怎么接收呢?
   用什么技术读取整个数据链路层的帧呢?winpcap可以做吗?4. 假设该数据链路帧里边封装的是IP报文,那么如果将该IP报文交与上层协议(TCP/IP)处理呢?

解决方案 »

  1.   

    1。yes
    2.winpcap
    3.yes
    4.数据链路帧里边封装的是IP报文?没听说过
      

  2.   

    4. check the mac header(6bytes des_mac_addr,6bytes src_mac_addr and 2bytes LLC len),and analyse the data from the 13th byte,if it's an IP packet,then make the copy of the data ,process it by the ip callback function which is registed in layer2 data process function.
      

  3.   

    4. 
    我知道IP协议的实现肯定提供了一种钩子式的回调函数来处理IP报文。
    因此我的问题是这个回调函数以什么形式存在?
    怎么利用它?
      

  4.   

    3.
    将以太网卡改成混杂模式,网卡可以获取包括目的地址非本机MAC地址的MAC帧。
    我的问题在于,现在设计的数据链路层协议并非MAC帧,以太网能接收,并放入到网卡缓存,并向上发出中断请求吗?