I'm looking for new solution to play h.264 steaming video ,which is based on 1722 protocol and entered in Ethernet from other device, in Windows 7 or 10 by using socket similarly with the way from linux environment.
I can bind network-interface directly using option of SO_BINDTODEVICE in linux and if I use that, video streaming is so smooth in vlc player and vlc statistics show bitrate is over 20,000 kb/s
so I tried two manners in Windows like below:
using scapy module in python
- sniffing all raw packet Ethernet
- attach data on payload and send packet to vlc player
- result is poor, because the bitrate in vlc statistics is almost under 1500kb/s
using winpcap lib in C(VS)
- sniffing all raw packet through pcap_next_ex or pcap_loop
- attach data on payload and send packet to vlc player
- result is bad, the bitrate in vlc statistics is 3000kb/s
1.
global dgramSock
dgramSock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
def prn(pkt):
global dgramSock
...
#filter to pick specific packet
...
#attach data on payload and naming myPacket
...
send_len = dgramSock.sendto(myPacket, ('127.0.0.1', 44514))
sniff(prn = prn, filter='ether)
2.
sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
addr.sin_family = AF_INET;
addr.sin_addr.s_addr = inet_addr("127.0.0.1");
addr.sin_port = htons(44514);
...
while( (pcap_next_ex(_handle, &header, &pkt_data)) >=0){
...
#filter to pick specific packet
...
#attach data on payload and naming myPacket
...
sendto(sock, (char *)myPacket, myPacketSize, 0, (struct sockaddr *)&(addr), sizeof(addr));
}
I think that two manner what I tried looks not essential way.
In Windows, what is the best solution to send raw packet to other program fastly without loss?