From: <sv...@ww...> - 2004-12-12 18:52:18
|
Author: mkrose Date: 2004-12-12 10:52:12 -0800 (Sun, 12 Dec 2004) New Revision: 1372 Modified: trunk/CSP/SimCore/Battlefield/GlobalBattlefield.h trunk/CSP/SimNet/ClientServer.cpp trunk/CSP/SimNet/NetworkInterface.cpp trunk/CSP/SimNet/NetworkInterface.h trunk/CSP/SimNet/PeerInfo.cpp Log: Fix bandwidth allocation. Was 0/0, which was causing all update packets to be throttled. Browse at: https://www.zerobar.net/viewcvs/viewcvs.cgi?view=rev&rev=1372 Modified: trunk/CSP/SimCore/Battlefield/GlobalBattlefield.h =================================================================== --- trunk/CSP/SimCore/Battlefield/GlobalBattlefield.h 2004-12-12 17:53:43 UTC (rev 1371) +++ trunk/CSP/SimCore/Battlefield/GlobalBattlefield.h 2004-12-12 18:52:12 UTC (rev 1372) @@ -176,7 +176,7 @@ command->setDestination(client_id); command->setRoutingType(ROUTE_COMMAND); command->setReliable(); - m_NetworkServer->queue()->queueMessage(command); + m_NetworkServer->queue()->queueMessage(command, client_id); } void bindCommandDispatch(simnet::DispatchHandler::Ref const &dispatch) { @@ -189,6 +189,7 @@ PlayerJoin::Ref makeJoin(const PeerId id) { PlayerJoin::Ref join = new PlayerJoin(); join->setRoutingType(ROUTE_COMMAND); + join->setReliable(); ClientData &data = m_ClientData[id]; simnet::PeerInfo const *peer_info = m_NetworkServer->getPeer(id); join->set_peer_id(id); @@ -210,11 +211,13 @@ // if the external ips match, these hosts are probably on a LAN and should communicate via their // internal interfaces; otherwise use the external ip. + /* XXX broken since join is shared for all outbound messages if (iter->second.external_ip_addr == new_client_data.external_ip_addr) { join->set_ip_addr(new_client_data.internal_ip_addr); } else { join->set_ip_addr(new_client_data.external_ip_addr); } + */ m_NetworkServer->queue()->queueMessage(join, iter->first); } Modified: trunk/CSP/SimNet/ClientServer.cpp =================================================================== --- trunk/CSP/SimNet/ClientServer.cpp 2004-12-12 17:53:43 UTC (rev 1371) +++ trunk/CSP/SimNet/ClientServer.cpp 2004-12-12 18:52:12 UTC (rev 1372) @@ -117,6 +117,9 @@ SIMNET_LOG(HANDSHAKE, DEBUG, "connection request " << *msg); PeerId client_id = msg->getSource(); ConnectionData &connection_data = m_PendingConnections[client_id]; + if (msg->incoming_bw() < 1000 || msg->outgoing_bw() < 1000) { + SIMNET_LOG(HANDSHAKE, ERROR, "client reports very low bandwidth " << *msg); + } connection_data.incoming_bw = msg->incoming_bw(); connection_data.outgoing_bw = msg->outgoing_bw(); ConnectionResponse::Ref response = new ConnectionResponse(); @@ -132,9 +135,11 @@ SIMNET_LOG(HANDSHAKE, DEBUG, "received acknowledgement " << *msg); PendingConnectionMap::iterator iter = m_PendingConnections.find(msg->getSource()); if (iter == m_PendingConnections.end()) { - SIMNET_LOG(HANDSHAKE, ERROR, "received unsolicited connection acknowledgement from client id " << msg->getSource()); + SIMNET_LOG(HANDSHAKE, WARNING, "received unsolicited connection acknowledgement from client id " << msg->getSource()); return; } + SIMNET_LOG(HANDSHAKE, INFO, "adding client " << msg->getSource() + << " (bw " << (iter->second.incoming_bw) << "/" << (iter->second.outgoing_bw) << ")"); m_NetworkInterface->establishConnection(msg->getSource(), iter->second.incoming_bw, iter->second.outgoing_bw); m_PendingConnections.erase(iter); } @@ -164,6 +169,8 @@ request->setReliable(); request->setRoutingType(0); request->setRoutingData(getLocalNode().getPort()); + request->set_incoming_bw(m_NetworkInterface->getNominalIncomingBandwidth()); + request->set_outgoing_bw(m_NetworkInterface->getNominalOutgoingBandwidth()); m_MessageQueue->queueMessage(request); // wait for a response Modified: trunk/CSP/SimNet/NetworkInterface.cpp =================================================================== --- trunk/CSP/SimNet/NetworkInterface.cpp 2004-12-12 17:53:43 UTC (rev 1371) +++ trunk/CSP/SimNet/NetworkInterface.cpp 2004-12-12 18:52:12 UTC (rev 1372) @@ -153,7 +153,10 @@ // queued packets when a peer disconnects). if (!peer || !peer->isActive()) { // check that this peer id was previously active (not a very stringent test). - assert(peer->getLastDeactivationTime() > 0); + //assert(peer->getLastDeactivationTime() > 0); + if (peer->getLastDeactivationTime() <= 0) { + SIMNET_LOG(PACKET, WARNING, "sending to inacive peer " << header->destination() << " and last deactivation time <= 0 " << (!peer ? "null" : "nonnull")); + } queue->releaseReadBuffer(); continue; } @@ -773,6 +776,7 @@ SIMNET_LOG(PEER, INFO, "connection established with peer " << id); PeerInfo *peer = getPeer(id); if (peer && peer->isActive() && peer->isProvisional()) { + SIMNET_LOG(PEER, INFO, "setting peer bandwidth " << incoming << ", " << outgoing); peer->updateBandwidth(incoming, outgoing); peer->setProvisional(false); } Modified: trunk/CSP/SimNet/NetworkInterface.h =================================================================== --- trunk/CSP/SimNet/NetworkInterface.h 2004-12-12 17:53:43 UTC (rev 1371) +++ trunk/CSP/SimNet/NetworkInterface.h 2004-12-12 18:52:12 UTC (rev 1372) @@ -368,6 +368,16 @@ * recently disconnected. */ PeerId nextDisconnectedPeerId(); + + /** Get the nominal (max) incoming bandwidth, in bytes per second. This is + * the value specified when the network interface was initialized. + */ + inline int getNominalIncomingBandwidth() const { return m_IncomingBandwidth; } + + /** Get the nominal (max) ougoing bandwidth, in bytes per second. This is + * the value specified when the network interface was initialized. + */ + inline int getNominalOutgoingBandwidth() const { return m_OutgoingBandwidth; } }; } // namespace simnet Modified: trunk/CSP/SimNet/PeerInfo.cpp =================================================================== --- trunk/CSP/SimNet/PeerInfo.cpp 2004-12-12 17:53:43 UTC (rev 1371) +++ trunk/CSP/SimNet/PeerInfo.cpp 2004-12-12 18:52:12 UTC (rev 1372) @@ -56,8 +56,8 @@ m_bytes_self_to_peer(0), m_average_outgoing_packet_size(100.0), m_packets_throttled(0), - m_desired_rate_self_to_peer(1), - m_desired_rate_peer_to_self(1), + m_desired_rate_self_to_peer(100), + m_desired_rate_peer_to_self(100), m_allocation_peer_to_self(100), // ~10% of inbound bandwidth initially m_allocation_self_to_peer(100), // ~10% of inbound bandwidth initially m_desired_bandwidth_peer_to_self(0.0), |