31 std::function<void(TcpSocketHandle,
const std::string &msg)> new_msg_cb;
32 std::function<void(TcpSocketHandle,
const Ipv4 &ip, uint16_t port)> client_connected_cb;
33 std::function<void(TcpSocketHandle)> client_disconnected_cb;
58 void send(TcpSocketHandle receiver,
const std::string &msg);
60 uint16_t getPort()
const;
65 ns3::Ptr<ns3::Socket> listening_socket_;
72 struct TcpConnection {
73 ns3::Ptr<ns3::Socket> socket;
78 TcpSocketHandle next_handle_ = 1;
81 std::unordered_map<TcpSocketHandle, TcpConnection> connections_;
83 void readFromSocket(TcpSocketHandle handle, ns3::Ptr<ns3::Socket> socket);
84 void processPacket(ns3::Ptr<ns3::Packet> packet, TcpSocketHandle sender);
86 void handleClose(TcpSocketHandle handle, ns3::Ptr<ns3::Socket> socket);
88 bool connectionRequest(ns3::Ptr<ns3::Socket>,
const ns3::Address &);
89 void newConnectionCreated(ns3::Ptr<ns3::Socket> socket,
const ns3::Address &addr);
91 void successfulConnect(ns3::Ptr<ns3::Packet>);
92 void failedConnect(ns3::Ptr<ns3::Packet>);