by Spike » Thu Jan 06, 2011 5:10 pm
the 'netchan' is the chunk of code which ensures delivery of reliable or unreliable datagrams to the other end. qw merges unreliable and reliable datagrams into a single udp packet, while nq (even dp7) sends both separately. this is handled by the net_*.c
Socket support is handled internally by the netchan supposedly, net_win/net_wins/net_udp handle this.
net_dgram is the datagram code... as opposed to the magic single-other-person serial/modem code, which is completely different and deserves to die.
the engine itself cares only about reliable and unreliable chunks of svc/clc messages/sizebufs. the demo code is basically an alternative to the netchan.
so input goes into an unreliable sizebuf, it gets sent to the netchan and the netchan forwards it into the dgram code. the dgram code adds sequence and ident info and submits it to the socket code, the socket code sends it to the operating system.
on the server, the engine polls the netchan which polls the datagram which polls the sockets. the packet is checked to make sure its for quake, its sequence is checked to count packetloss and ignore duplicates or packets out of sequence, and its dumped into net_message which is then parsed for its clc payloads via MSG_Read*().
its the dgram code which contains all the bugs really, as its the dgram code which contains the connection process (which is evil and blocks because it is not able to poll iteratively), and the code responsible for separate sockets for each client (nq was written a bit like ftp, with relilable modem/serial links - unreliable just means drop it if you have old unreliable to send and thus it would be really really easy to use tcp instead of udp, with NAT/firewall all the issues that go with it - see ftp nat/firewall rules).
The dgram code also contains the server polling and replies. While these are not 'buggy'
Quakeworld has rewritten netchan for a very good reason.
single sockets fixes nat, and simplifies waiting for activity
combined reliables+unreliables reduces packet rates
challenges on connections means you can't flood servers from spoofed ip addresses.
Quakeworld has no explicit 'dgram' layer as everything is a datagram.
connectionless packets are mostly human-readable.
DP has an lhnet.c which basically provides an nq or qw netchan equivelent. I'm not sure on code compatibility, but it does provide network compatibility if configured that way, as well as far superior server queries.
signon buffers are created each frame and are just blocks of svcs like baselines, static sounds, static ents, initial lightstyles. map stuff that is sent to all. prebuilt and broadcast to all. each one should be kept smaller than a udp packet or reliable packet.
the connection handshake is basically that the client sends a 'gimme a connection' packet to the server. the server directly replies with 'this is the ip:port I will use for you, send your stuff there'. The server then begins to send the serverinfo svc to the source of the connection request from the socket at the address:port it gave. Note that it'll retry multiple times, and send keepalives.
backbuffers are specific to quakeworld, and are 'extra storage' for reliable messages which are longer than the max length. They are flushed in order, and this prevents breaking due to routers with broken udp fragmentation, and without large reliables stalling datagram messages on slow links. They are limited to the max reliable packet size of 1024 bytes, but you get lots at a time, so the total reliable data can be much larger, just with no large individual svcs.
any of that help?
.