156 :
157 Input(port, lidar_ip, packet_size),
158 packet_rate_(packet_rate),
159 filename_(filename) {
160 pcap_ = NULL;
161 empty_ = true;
162 packet_rate_ = packet_rate;
163 lidar_ip_ = lidar_ip;
164
165 read_once_ = read_once;
166 read_fast_ = read_fast;
167 repeat_delay_ = repeat_delay;
168
169 if (read_once_)
170 AINFO <<
"Read input file only once.";
171 if (read_fast_)
172 AINFO <<
"Read input file as quickly as possible.";
173 if (repeat_delay_ > 0.0)
174 AINFO <<
"Delay %.3f seconds before repeating input file."
175 << repeat_delay_;
176
177
178 AERROR <<
"Opening PCAP file " << filename_;
179 if ((pcap_ = pcap_open_offline(filename_.c_str(), errbuf_)) == NULL) {
180 AERROR <<
"Error opening lslidar socket dump file.";
181 return;
182 }
183
184 std::stringstream filter;
185 if (lidar_ip != "") {
186 filter << "src host " << lidar_ip << " && ";
187 }
188 filter << "udp dst port " << port;
189 pcap_compile(
190 pcap_,
191 &pcap_packet_filter_,
192 filter.str().c_str(),
193 1,
194 PCAP_NETMASK_UNKNOWN);
195}