add resend feature

This commit is contained in:
AlanRen 2024-05-07 22:57:36 -06:00
parent 71c22a276b
commit 695928f9da
2 changed files with 39 additions and 10 deletions

34
.vscode/launch.json vendored
View File

@ -59,7 +59,7 @@
"request": "launch",
"program": "${workspaceFolder}/release/out/PcapRawSender",
// "args": ["/media/alan/Data/Alan/Documents/WorkSpace/SecMedia/PcapRawSender/h265-hikvision-10min.pcap",
// "127.0.0.1","40001","udp src port 15060"],
// "127.0.0.1","30001","udp src port 15060"],
// "args": ["/media/alan/Data/Alan/Documents/WorkSpace/SecMedia/PcapRawSender/afterSign.pcap",
// "127.0.0.1","30001","udp src port 15060"],
// "args": ["/media/alan/Data/Alan/Documents/WorkSpace/SecMedia/PcapRawSender/HaiKang_platform.pcap",
@ -67,17 +67,35 @@
// "args": ["/media/alan/Data/Alan/Documents/WorkSpace/SecMedia/PcapRawSender/EncMedia_rtp_encoded.pcapng",
// "127.0.0.1","60006","udp src port 10005"],
// "args": ["/media/alan/Data/Alan/Documents/WorkSpace/SecMedia/PcapRawSender/EncMedia_rtp.pcapng",
// "127.0.0.1","40001","udp src port 10005"],
// "127.0.0.1","30001","udp src port 10005"],
// "args": ["/media/alan/Data/Alan/Documents/WorkSpace/SecMedia/PcapRawSender/rawcamera.pcap",
// "127.0.0.1","40001","udp src port 15060"],
// "127.0.0.1","30001","udp src port 15060"],
// "args": ["/media/alan/Data/Alan/Documents/WorkSpace/SecMedia/PcapRawSender/h264.pcap", //
// "127.0.0.1","30001","udp src port 21999"],
// "127.0.0.1","20001","udp src port 21999"],
// "args": ["/media/alan/Data/Alan/Documents/WorkSpace/SecMedia/PcapRawSender/123.pcap",
// "127.0.0.1","40001","udp dst port 10001"],
"args": ["/media/alan/Data/Alan/Documents/WorkSpace/SecMedia/PcapRawSender/51.pcap",
"127.0.0.1","40001","udp dst port 30008"], //svac
// "args": ["/media/alan/Data/Alan/Documents/WorkSpace/SecMedia/PcapRawSender/svac_dec.pcap",
// "127.0.0.1","40001","udp dst port 20001"], //svac
// "args": ["/media/alan/Data/Alan/Documents/WorkSpace/SecMedia/PcapRawSender/51.pcap",
// "127.0.0.1","40001","udp dst port 30008"], //svac
// // "args": ["/media/alan/Data/Alan/Documents/WorkSpace/SecMedia/PcapRawSender/svac_dec.pcap",
// // "127.0.0.1","40001","udp dst port 20001"], //svac
// "args": ["/media/alan/Data/Alan/Documents/WorkSpace/SecMedia/PcapRawSender/1.pcap",
// "127.0.0.1","40001","udp dst port 40001"], //svac
// "args": ["/media/alan/Data/Alan/Documents/WorkSpace/SecMedia/PcapRawSender/hz-pt.pcap",
// "127.0.0.1","40001","udp src port 10000"],
// "args": ["/media/alan/Data/Alan/Documents/WorkSpace/SecMedia/PcapRawSender/ipc-hz.pcap",
// "127.0.0.1","40001","udp src port 15060"],
// "args": ["/media/alan/Data/Alan/Documents/WorkSpace/SecMedia/PcapRawSender/videoblur/H265_ps_bug.pcap",
// "127.0.0.1","40001","udp src port 10005"],
// "args": ["/media/alan/Data/Alan/Documents/WorkSpace/SecMedia/PcapRawSender/videoblur/86h264.pcap",
// "127.0.0.1","30001","udp src port 15060"],
// "args": ["/media/alan/Data/Alan/Documents/WorkSpace/SecMedia/PcapRawSender/cameraAndboxh265.pcap",
// "127.0.0.1","30001","udp src port 15060 && src host 192.168.0.93"],
"args": ["/media/alan/Data/Alan/Documents/WorkSpace/SecMedia/PcapRawSender/cameraAndBoxh264.pcap",
"127.0.0.1","40001","udp src port 15060 && src host 192.168.1.95"],
// "args": ["/home/alan/Downloads/br0.pcap",
// "127.0.0.1","60006","udp dst port 10001"]
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],

View File

@ -51,7 +51,14 @@ timespec TimeDiff(T && minu,U && sub){
}
int ReadPcapAndSend(int socket,sockaddr_in & addr,const string & filename,const string & filter,void * sign_handle){
auto reader=pcpp::IFileReaderDevice::getReader(filename);
pcpp::IFileReaderDevice * reader;
reader=pcpp::IFileReaderDevice::getReader(filename);
while (1)
{
// verify that a reader interface was indeed created
if (reader == NULL)
{
@ -117,7 +124,10 @@ int ReadPcapAndSend(int socket,sockaddr_in & addr,const string & filename,const
// cout<<" stamp:" << rawPacket.getPacketTimeStamp().tv_sec<<" len:"<< rawPacket.getRawDataLen()<<endl;
}
cout<<" resend pcap" <<endl;
reader->close();
// delete reader;
}
// reader->getNextPacket(rawPacket);
@ -134,6 +144,7 @@ int ReadPcapAndSend(int socket,sockaddr_in & addr,const string & filename,const
pcpp::IPcapDevice::PcapStats stats;
reader->getStatistics(stats);
std::cout << "Read " << stats.packetsRecv << " packets successfully and " << stats.packetsDrop << " packets could not be read" << std::flush;
delete reader;
return 0;
}
int main(int argc, char *argv[]){