Development:Network:Packet format

From VsWiki
Revision as of 08:59, 22 June 2006 by Nachtwolf (talk | contribs) (Added first revision of implemented networking packet format.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Contents

Packet format

acctserver.cpp

CMD_LOGIN: C->S, CMD_LOGIN (S to A)

  • Function sent:
  • Handler function:
  • Data:
    • char flags; // Don't seem to be used.
    • string callsign; // The username should be restricted to a reasonable subset of ASCII
    • string passwd; // Not encrypted -- Should be encrypted with a token (or timestamp).

LOGIN_NEW (A to S)

  • Function sent:
  • Handler function:
  • Data:
    • No Data

Sent the first time someone logs into an account -- asks for faction, ship, etc.

LOGIN_ACCEPT (A to S)

  • Function sent:
  • Handler function:
  • Data:
    • No Data

LOGIN_ALREADY, LOGIN_UNAVAIL (A to S), LOGIN_ERROR (A to S)

  • Function sent: CMD_NEWSUBSCRIBE, CMD_LOGIN
  • Handler function:
  • Data:
    • No Data

CMD_LOGOUT (C to S)

  • Function sent:
  • Handler function: references logoutList...
  • Data:
    • FIXME WRITEME

CMD_LOGOUT (S to A)

  • Function sent:
  • Handler function:
  • Data:
    • string callsign;
    • string passwd; // Why send the password to logout?

CMD_NEWCHAR (S to A)

UNIMPLEMENTED!!!

// Should receive the result of the creation of a new char/ship

CMD_NEWSUBSCRIBE (S to A)

  • Function sent:
  • Handler function:
  • Data:
    • string callsign;
    • string passwd;

Subscribes an account.

(Cmd)0 (A to S)

  • Function sent: CMD_NEWLOGIN
  • Handler function: The input checking that the server most certainly uses.

Unable to open account file?

CMD_RESYNCACCOUNTS (S to A)

  • Function sent:
  • Handler function:
  • Data:
    • ObjSerial nbclients; // Number of clients?
    • Array [nbclients]
      • short sertmp;


Calls setConnected(true) on all included Client serials.

CMD_SAVEACCOUNTS (S to A)

  • Function sent:
  • Handler function: AccountServer::writeSave(data, dataLen);
  • Data:
    • SaveString savestr;
    • XmlString xmlstr; // Actually, the CSV ship data.
FileUtil::WriteSaveFiles(savestr, xmlstr, callsign);

CltSerial serial; vector<string> saves = FileUtil::GetSaveFromBuffer( netbuf );


LOGIN_DATA (C to A)

  • Function sent:
  • Handler function: AccountServer::sendServerData(sock, elem);
  • Data:
    • string callsign;
    • string passwd;

Responds with IP address to connect to.

netserver.cpp

CMD_ADDCLIENT (C to S)

  • Function sent:
  • Handler function: NetServer::addClient(clt);
  • Data:
    • CltSerial ser;

CMD_POSUPDATE (C to S)

  • Function sent:
  • Handler function: NetServer::posUpdate(clt);
  • Data:
    • CltSerial ser;

Client tells server its actual position. Server accepts client's position with no validation.

CMD_LETSGO (C to S)

UNIMPLENTED!

CMD_PING (C to S)

  • Function sent:
  • Handler function:
  • Data:
// Nothing to do here, just receiving the packet is enough

Source code comments are usually right.

CMD_SERVERTIME (C to S)

  • Function sent:
  • Handler function: serverTimeInitUDP(clt, netbuf);
  • Data:

CMD_ACK (C to S)

// Commented out.

CMD_ASKFILE (C to S)

UNIMPLENTED!

CMD_DOWNLOAD (C to S)

  • Function sent:
  • Handler function: _downloadManagerServer->addCmdDownload( clt->tcp_sock, netbuf );
  • Data:
    • FIXME WRITEME

CMD_FIREREQUEST (C to S)

  • Function sent: Unit::fire???
  • Handler function:
  • Data:
    • ObjSerial target_serial;
    • int mount_num;
    • char mis;

This seems to be sent *constantly* while firing! A waste of bandwidth and console buffer.

CMD_UNFIREREQUEST (C to S)

  • Function sent: Unit::unfire???
  • Handler function:
  • Data:
    • ObjSerial target_serial;
    • int mount_num;

Not being sent very well. Firing has a tendency currently to get stuck.

CMD_JUMP (C to S)

  • Function sent:
  • Handler function:
  • Data:
    • string newsystem;
    • ObjSerial jumpserial;
    • ushort zonenum;

No idea how this is supposed to work... transfer to another server?

CMD_SCAN (C to S)

  • Function sent:
  • Handler function:
  • Data:
    • ObjSerial target_serial;
    • ushort zone;

UNIMPLENTED???

CMD_STARTNETCOMM, CMD_STOPNETCOMM, CMD_SOUNDAMPLE, CMD_TXTMESSAGE (C to S)

FIXME netcomm

CMD_DOCK (C to S)

  • Function sent:
  • Handler function:
  • Data:
    • ObjSerial utdwserial; // Unit to dock with.
    • ushort zonenum;

CMD_UNDOCK (C to S)

  • Function sent:
  • Handler function:
  • Data:
    • ObjSerial utdwserial; // Unit to dock with.
    • ushort zonenum;

netclient.cpp

LOGIN_ACCEPT (S to C)

  • Function sent: Account server forwarded through netserver?????
  • Handler function: NetClient::loginAccept(packet);
  • Data:
    • FIXME WRITEME

CMD_ASKFILE (S to C)

  • Function sent:
  • Handler function:
  • Data:
    • string filename;
    • string file;

CMD_DOWNLOAD (S to C)

  • Function sent:
  • Handler function: _downloadManagerClient->processCmdDownload( clt_tcp_sock, netbuf );
  • Data:
    • FIXME WRITEME

LOGIN_ERROR,LOGIN_UNAVAIL (S to C)

  • Function sent:
  • Handler function: NetClient::disconnect();
  • Data:
    • No data.

CMD_CREATECHAR (S to C)

// Commented out.
  • Function sent:
  • Handler function: NetClient::createChar();
  • Data:
    • FIXME WRITEME

CMD_LOCATIONS (S to C)

  • Function sent:
  • Handler function: NetClient::receiveLocations(Packet);
  • Data:
    • FIXME WRITEME
// Should receive possible starting locations list

I assume this means that the client can choose where to start within a system?

IMO, the in-system starting point may just as well be determined randomly in the server.

CMD_SNAPSHOT (S to C)

  • Function sent:
  • Handler function: NetClient::receivePositions(numUnits, timestamp, netbuffer);
  • Data:
    • uint numUnits;
    • uint timestamp;
    • double deltatime; // NETFIXME: Uses netbuf.getFloat???

This is the packet that updates a client on *every* position!

Perhaps the server should optimize based on the distance from the client?

CMD_ENTERCLIENT (S to C)

  • Function sent:
  • Handler function: NetClient::AddClientObject(NetBuffer, ObjSerial);
  • Data:
    • FIXME WRITEME

CMD_EXITCLIENT (S to C)

  • Function sent:
  • Handler function: NetClient::removeClient(Packet);
  • Data:
    • FIXME WRITEME

CMD_ADDEDYOU (S to C)

  • Function sent:
  • Handler function: this->game_unit.GetUnit()->curr_physical_state = netbuf.getTransformation();
  • Data:
    • Transformation curr_physical_state;

CMD_DISCONNECT (S to C)

  • Function sent:
  • Handler function: VSExit(1);
  • Data:
    • No data.

In my opinion, this could have a slightly more graceful exit.

It doesn't even seem to close the socket...

As the code says, /*** TO REDO IN A CLEAN WAY ***/

CMD_ACK (S to C)

// Commented out.

CMD_FIREREQUEST (S to C)

  • Function sent:
  • Handler function: netclient.cpp:574 (case)
  • Data:
    • int mount_num;
    • ObjSerial mis;
    • ObjSerial unSerial = p1.getSerial(); // Not sure how Packet and NetBuffer are different?

CMD_UNFIREREQUEST (S to C)

  • Function sent:
  • Handler function: netclient.cpp:618 (case)
  • Data:
    • int mount_num;
    • ObjSerial unSerial;

CMD_SCAN (S to C)

  • Function sent:
  • Handler function: Cockpit::ReceivedTargetInfo();
  • Data:
    • No data.

CMD_SNAPDAMAGE (S to C)

  • Function sent:
  • Handler function: ALL 85 lines in netclient.cpp:673-759
  • Data:
    • int nbupdates = packet_serial;
    • ObjSerial serial;
    • Array[nbupdates]
      • short damages [mask];
      • ObjSerial serial;
      • More data based on mask:
        • See netclient.cpp:673 for more detail.

CMD_DAMAGE (S to C)

  • Function sent:
  • Handler function: Unit::ApplyNetDamage(pnt, normal, amt, ppercentage, spercentage, col);
  • Data:
    • float amt;
    • float ppercentage;
    • float spercentage;
    • Vector pnt;
    • Vector normal;
    • GFXColor col; // Unused.
    • ObjSerial target;
    • Shield sh;
    • Armor ar;

Seems to be in an #ifdef NET_SHIELD_SYSTEM_1

CMD_DAMAGE1 (S to C)

// Commented out.

CMD_KILL (S to C)

  • Function sent:
  • Handler function: netclient.cpp:800 (case), Unit::Destroy()
  • Data:
    • ObjSerial clt = p1.getSerial();

CMD_JUMP (S to C)

  • Function sent:
  • Handler function: netclient.cpp:830
  • Data:
    • string newsystem;
    • ObjSerial unserial;
    • ObjSerial jumpserial;
    • ushort zoneid;

CMD_STARTNETCOMM, CMD_STOPNETCOMM, CMD_SOUNDSAMPLE, CMD_SECSNDSAMPLE, CMD_TXTMESSAGE, CMD_SECMESSAGE (S to C)

FIXME Netcomm stuff...

CMD_DOCK (S to C)

  • Function sent:
  • Handler function: netclient.cpp:960
  • Data:
    • ObjSerial utdw_serial;
    • int dockport;
    • p1.getSerial();

CMD_UNDOCK (S to C)

  • Function sent:
  • Handler function: netclient.cpp:970
  • Data:
    • ObjSerial utdw_serial;
    • p1.getSerial();

CMD_POSUPDATE (S to C)

  • Function sent:
  • Handler function: netclient.cpp:970
  • Data:
    • QVector serverpos;
// If a client receives that it means the server want to force the client position to be updated
// with server data

Forces your position to be updated.

Normally, since SNAPSHOTs are old, they is ignored on CMD_SNAPSHOT. I assume, that after this, the client will relay its position, velocity, etc. back to the server to be broadcast?

The server should never have to manually update a client's position.

CMD_CREATE{UNIT|NEBULA|PLANET|ASTER|MISSILE} (S to C)

  • Function sent:
  • Handler function: netclient.cpp:1000-1125
  • Data:
    • FIXME WRITEME

Loads a lot of stuff from the packet, and then calls UnitFactory::create{Unit|...} (...);

CMD_SERVERTIME (S to C)

// No action... apparently receiving this is enough.

How is this different from CMD_PING?