开发者

Socket Program to demonstrate Link layer communication in a network without using ip address

开发者 https://www.devze.com 2023-04-03 02:21 出处:网络
As we all know that within a network, communication is by the MAC address and not by the ip address. So I always used to think that whether we can write a socket program in server-client paradigm whic

As we all know that within a network, communication is by the MAC address and not by the ip address. So I always used to think that whether we can write a socket program in server-client paradigm which are only using MAC address for communication but not ip address i.e. the struct sock_in should be left unfilled, and within a lan they should be able to communicate.开发者_运维百科


Raw sockets, as given by the example above (by Carl) can work to give you access for L3 header. However, note that on more up-to-date Windows (XP SP3, Vista and 7) raw sockets are greatly restricted by the socket layer, making it difficult to send arbitrary data of your choosing.

You can also use special libraries that allow for a much more raw access to the Ethernet adapter. WinPcap (for Windows) or libpcap (for Linux) will allow you to manipulate the entire packet data, including the Ethernet header, and indeed send any other L2 protocol you wish.

0

精彩评论

暂无评论...
验证码 换一张
取 消