c++ - Setting up a server using Boost-ASIO for Wireshark to connect to and receive packets? -
i trying create simple server using asio in order send packets wireshark view them using remote interfaces feature.
this code sets server , waits connection.
void server(boost::asio::io_service& io_service, unsigned short port) { tcp::acceptor a(io_service, tcp::endpoint(tcp::v4(), port)); (;;) { auto psock = std::make_shared<tcp::socket>(io_service); auto handler = [psock](const boost::system::error_code& err) -> void { if (err) { psock->close(); return; } auto buf = connecttonamedpipe(); streamout(psock, buf); psock->close(); }; std::cout << "awaiting connection" << std::endl; a.async_accept(*psock, handler); io_service.run(); } }
this code sends packet once client connects
void streamout(std::shared_ptr<tcp::socket> psock, const std::pair<std::unique_ptr<char[]>, std::size_t>& b) { ::boost::system::error_code ec; write(*psock, ::boost::asio::buffer(b.first.get(), b.second)); (;;) { char a; std::cin >> a; if (a == 'e') return; } }
however when wireshark connect (using remote interfaces tab in manage interfaces dialog), hangs , stops respond until close application. there other data need send wireshark before starts sending data? sending data incorrectly? server not set correctly?
wireshark "wire-tap".
you don't "send packets viewing" , doesn't "connect" application.
instead, wireshark taps nic , sees packets transmitted. so, instead connect server regular client (like netcat
) , have wireshark monitor nic(s) involved.
you can, simplicity, capture traffic on network adaptors @ once, believe.
Comments
Post a Comment