前段时间,我们已经解决如何发送自定义的网络数据。那么接下来要做的是,要是要发送的数据很大, 是否需要把数据拆分,然后封装在多个MDL中发送呢?由于NdisAllocateMDL函数只能分配一个MDL,所以倘若需要多个MDL的话,那么就要解决如何串联多个MDL的问题。现在所掌握的资料,如果通过预分配调用NdisALlocateNetBufferAndNetbufferList的方式构建NBL的话,那么串连两个MDL的可查资料为:
NDIS_MDL_LINKAGE(FirstMdl) = SecondMdl;
需要其他的比如设置dataLength这些应该不要设置了吧。但如果是后来增加新的一个MDL,就需要设置哪些数据参数了。
话又说回来了,如果我统统把所有的数据都放在一个MDL中,会如何呢?据我所知,如果在发送网络数据的时候,过大的数据也自动会被切成多个小包发送。这个网络上的一问一答(http://www.eggheadcafe.com/software/aspnet/33553113/ndisallocatemdl.aspx):
问题:
size of the data buffer being described and physical page size? I looked at
MSDN but it does not say anything about this.
I am guessing that if say I have a 15K buffer on a system with 4k page size
then I will need 4 MDLs to describe the buffer and these MDLs will be chained
and the chain is what is returned from the call to NdisAllocateMdl. Is this
statement correct?
Thanks.
回答是:
describes the entire 15K buffer) then you only need one MDL to describe it.
You don't need multiple MDLs just because the buffer may be "physically
fragmentedâ€.
The fact that the memory might span 5 pages is reflected in the pfn array at
the bottom of the MDL (after the header).
所以我想,不妨先试试看~当然分两个MDL发,肯定也是可以的。只不过我还没有想到如何串联它们俩。https://www.osronline.com/cf.cfm?PageURL=showThread.CFM?link=134437
二:还有一个问题,如何区分多个Filter实例。我们知道每个Filter instance都绑定在对应的网卡上,包含虚拟网卡。那么如何区分哪个filter实例是对应的某个网卡呢?因为倘若要指定某张网卡执行操作,那么必须知道其对应的那个filter实例。目前可以利用的资源就是pFilter中的一个参数:
-
BaseMiniportInstanceName
- A pointer to a an NDIS_STRING type value that contains a counted Unicode string. This string specifies the friendly name of the interface for the base miniport adapter. For Windows 2000 and later versions, NDIS defines the NDIS_STRING type as a UNICODE_STRING type. BaseMiniportName
- The name of the base miniport adapter. FilterModuleGuidName
- The GUID name of the filter module that NDIS is attaching.
-
至于哪个可以用,还需测试~