1 #include "CongestionControl.hpp"
2 #include "Connection.hpp"
3 #include "ConnectionHandler.hpp"
7 #include "../app/error.hpp"
8 #include "../geometry/const.hpp"
9 #include "../model/Model.hpp"
10 #include "../world/Entity.hpp"
11 #include "../world/EntityState.hpp"
20 constexpr size_t Packet::Ping::MAX_LEN;
21 constexpr size_t Packet::Login::MAX_LEN;
22 constexpr size_t Packet::Join::MAX_LEN;
23 constexpr size_t Packet::Part::MAX_LEN;
24 constexpr size_t Packet::PlayerUpdate::MAX_LEN;
25 constexpr size_t Packet::SpawnEntity::MAX_LEN;
26 constexpr size_t Packet::DespawnEntity::MAX_LEN;
27 constexpr size_t Packet::EntityUpdate::MAX_LEN;
28 constexpr size_t Packet::PlayerCorrection::MAX_LEN;
29 constexpr size_t Packet::ChunkBegin::MAX_LEN;
30 constexpr size_t Packet::ChunkData::MAX_LEN;
31 constexpr size_t Packet::BlockUpdate::MAX_LEN;
32 constexpr size_t Packet::Message::MAX_LEN;
33 constexpr size_t Packet::Message::MAX_MESSAGE_LEN;
36 CongestionControl::CongestionControl()
37 // I know, I know, it's an estimate (about 20 for IPv4, 48 for IPv6)
39 // only sample every eighth packet for measuring RTT
52 // rtt > 75ms or packet loss > 5% is BAD
55 // rtt > 150ms or packet loss > 15% is UGLY
58 , mode_keep_time(1000) {
59 Uint32 now = SDL_GetTicks();
60 for (Uint32 &s : stamps) {
69 void CongestionControl::PacketSent(uint16_t seq) noexcept {
70 if (!SamplePacket(seq)) {
73 stamps[SampleIndex(seq)] = SDL_GetTicks();
77 void CongestionControl::PacketLost(uint16_t seq) noexcept {
83 void CongestionControl::PacketReceived(uint16_t seq) noexcept {
89 void CongestionControl::UpdatePacketLoss() noexcept {
90 unsigned int packets_total = packets_lost + packets_received;
91 if (packets_total >= 256) {
92 packet_loss = float(packets_lost) / float(packets_total);
98 void CongestionControl::UpdateRTT(uint16_t seq) noexcept {
99 if (!SamplePacket(seq)) return;
100 int16_t diff = int16_t(stamp_last) - int16_t(seq);
101 if (diff < 0 || diff > int(15 * sample_skip)) {
102 // packet outside observed frame
105 int cur_rtt = SDL_GetTicks() - stamps[SampleIndex(seq)];
106 rtt += (cur_rtt - rtt) * 0.1f;
109 bool CongestionControl::SamplePacket(uint16_t seq) const noexcept {
110 return seq % sample_skip == 0;
113 size_t CongestionControl::SampleIndex(uint16_t seq) const noexcept {
114 return (seq / sample_skip) % 16;
117 void CongestionControl::PacketIn(const UDPpacket &pack) noexcept {
118 rx_bytes += pack.len + packet_overhead;
122 void CongestionControl::PacketOut(const UDPpacket &pack) noexcept {
123 tx_bytes += pack.len + packet_overhead;
127 void CongestionControl::UpdateStats() noexcept {
128 Uint32 now = SDL_GetTicks();
129 if (now < next_sample) {
133 tx_kbps = float(tx_bytes) * (1.0f / 1024.0f);
134 rx_kbps = float(rx_bytes) * (1.0f / 1024.0f);
141 void CongestionControl::UpdateMode() noexcept {
142 Mode now_mode = Conditions();
143 if (now_mode > mode) {
144 ChangeMode(now_mode);
145 } else if (now_mode < mode) {
146 CheckUpgrade(now_mode);
152 void CongestionControl::CheckUpgrade(Mode m) noexcept {
153 Uint32 now = SDL_GetTicks();
154 Uint32 time_in_mode = now - mode_entered;
155 if (time_in_mode < mode_keep_time) {
161 void CongestionControl::ChangeMode(Mode m) noexcept {
162 Uint32 now = SDL_GetTicks();
164 // changed to worse mode
165 // if we spent less than 10 seconds in better mode
166 // double keep time till up to 64 seconds
167 if (now - mode_entered < 10000) {
168 if (mode_keep_time < 64000) {
175 mode_reset = mode_entered;
178 void CongestionControl::KeepMode() noexcept {
179 mode_reset = SDL_GetTicks();
180 // if in good mode for 10 seconds, halve keep time till down to one second
181 if (mode == GOOD && mode_keep_time > 1000 && mode_step - mode_reset > 10000) {
183 mode_step = mode_reset;
187 CongestionControl::Mode CongestionControl::Conditions() const noexcept {
188 if (rtt > ugly_rtt || packet_loss > ugly_loss) {
190 } else if (rtt > bad_rtt || packet_loss > bad_loss) {
198 Connection::Connection(const IPaddress &addr)
201 // make sure a packet is sent at least every 50ms since packets contains
202 // acks that the remote end will use to measure RTT
205 , ctrl_out{ 0, 0xFFFF, 0xFFFFFFFF }
206 , ctrl_in{ 0, 0xFFFF, 0xFFFFFFFF }
212 bool Connection::Matches(const IPaddress &remote) const noexcept {
213 return memcmp(&addr, &remote, sizeof(IPaddress)) == 0;
216 void Connection::FlagSend() noexcept {
220 void Connection::FlagRecv() noexcept {
224 bool Connection::ShouldPing() const noexcept {
225 return !closed && send_timer.HitOnce();
228 bool Connection::TimedOut() const noexcept {
229 return recv_timer.HitOnce();
232 void Connection::Update(int dt) {
233 send_timer.Update(dt);
234 recv_timer.Update(dt);
238 Handler().OnTimeout();
244 uint16_t Connection::Send(UDPpacket &udp_pack, UDPsocket sock) {
245 Packet &pack = *reinterpret_cast<Packet *>(udp_pack.data);
246 pack.header.ctrl = ctrl_out;
247 uint16_t seq = ctrl_out.seq++;
249 udp_pack.address = addr;
250 if (SDLNet_UDP_Send(sock, -1, &udp_pack) == 0) {
251 throw NetError("SDLNet_UDP_Send");
255 Handler().PacketOut(udp_pack);
256 Handler().PacketSent(seq);
263 void Connection::Received(const UDPpacket &udp_pack) {
264 Packet &pack = *reinterpret_cast<Packet *>(udp_pack.data);
267 int16_t diff = int16_t(pack.header.ctrl.seq) - int16_t(ctrl_out.ack);
272 ctrl_out.hist <<= diff;
273 ctrl_out.hist |= 1 << (diff - 1);
275 } else if (diff < 0 && diff >= -32) {
276 ctrl_out.hist |= 1 << (-diff - 1);
278 ctrl_out.ack = pack.header.ctrl.seq;
285 Packet::TControl ctrl_new = pack.header.ctrl;
286 Handler().PacketIn(udp_pack);
287 Handler().Handle(udp_pack);
290 // if the packet holds more recent information
291 // check if remote failed to ack one of our packets
292 diff = int16_t(ctrl_new.ack) - int16_t(ctrl_in.ack);
293 // should always be true, but you never know…
295 for (int i = 0; i < diff; ++i) {
296 if (i > 32 || (i < 32 && (ctrl_in.hist & (1 << (31 - i))) == 0)) {
297 Handler().PacketLost(ctrl_in.ack - 32 + i);
301 // check for newly ack'd packets
302 for (uint16_t s = ctrl_new.AckBegin(); s != ctrl_new.AckEnd(); --s) {
303 if (ctrl_new.Acks(s) && !ctrl_in.Acks(s)) {
304 Handler().PacketReceived(s);
311 bool Packet::TControl::Acks(uint16_t s) const noexcept {
312 int16_t diff = int16_t(ack) - int16_t(s);
313 if (diff == 0) return true;
314 if (diff < 0 || diff > 32) return false;
315 return (hist & (1 << (diff - 1))) != 0;
318 uint16_t Connection::SendPing(UDPpacket &udp_pack, UDPsocket sock) {
319 Packet::Make<Packet::Ping>(udp_pack);
320 return Send(udp_pack, sock);
324 ConnectionHandler::ConnectionHandler()
329 void ConnectionHandler::PacketSent(uint16_t seq) noexcept {
333 void ConnectionHandler::PacketLost(uint16_t seq) {
338 void ConnectionHandler::PacketReceived(uint16_t seq) {
339 OnPacketReceived(seq);
340 cc.PacketReceived(seq);
343 void ConnectionHandler::PacketIn(const UDPpacket &pack) noexcept {
347 void ConnectionHandler::PacketOut(const UDPpacket &pack) noexcept {
352 ostream &operator <<(ostream &out, const IPaddress &addr) {
353 const unsigned char *host = reinterpret_cast<const unsigned char *>(&addr.host);
355 << '.' << int(host[1])
356 << '.' << int(host[2])
357 << '.' << int(host[3]);
359 out << ':' << SDLNet_Read16(&addr.port);
365 const char *Packet::Type2String(uint8_t t) noexcept {
375 case PlayerUpdate::TYPE:
376 return "PlayerUpdate";
377 case SpawnEntity::TYPE:
378 return "SpawnEntity";
379 case DespawnEntity::TYPE:
380 return "DespawnEntity";
381 case EntityUpdate::TYPE:
382 return "EntityUpdate";
383 case PlayerCorrection::TYPE:
384 return "PlayerCorrection";
385 case ChunkBegin::TYPE:
387 case ChunkData::TYPE:
389 case BlockUpdate::TYPE:
390 return "BlockUpdate";
399 void Packet::Payload::Write(const T &src, size_t off) noexcept {
400 if ((length - off) < sizeof(T)) {
401 // dismiss out of bounds write
404 *reinterpret_cast<T *>(&data[off]) = src;
408 void Packet::Payload::Read(T &dst, size_t off) const noexcept {
409 if ((length - off) < sizeof(T)) {
410 // dismiss out of bounds read
413 dst = *reinterpret_cast<T *>(&data[off]);
416 void Packet::Payload::WriteString(const string &src, size_t off, size_t maxlen) noexcept {
417 uint8_t *dst = &data[off];
418 size_t len = min(maxlen, length - off);
419 if (src.size() < len) {
420 memset(dst, '\0', len);
421 memcpy(dst, src.c_str(), src.size());
423 memcpy(dst, src.c_str(), len);
427 void Packet::Payload::ReadString(string &dst, size_t off, size_t maxlen) const noexcept {
428 size_t len = min(maxlen, length - off);
431 for (size_t i = 0; i < len && data[off + i] != '\0'; ++i) {
432 dst.push_back(data[off + i]);
436 void Packet::Payload::Write(const glm::quat &val, size_t off) noexcept {
437 // find the largest component
438 float largest = 0.0f;
439 int largest_index = -1;
440 for (int i = 0; i < 4; ++i) {
441 float iabs = abs(val[i]);
442 if (iabs > largest) {
447 // make sure it's positive
448 const glm::quat q(val[largest_index] < 0.0f ? -val : val);
449 // move index to the two most significant bits
450 uint64_t packed = uint64_t(largest_index) << 62;
451 // we have to map from [-0.7072,0.7072] to [-524287,524287] and move into positive range
452 constexpr float conv = 524287.0f / 0.7072f;
453 // if largest is 1, the other three are 0
454 // precision of comparison is the interval of our mapping
455 if (abs(1.0 - largest) < (1.0f / conv)) {
456 packed |= 0x7FFFF7FFFF7FFFF;
458 // pack the three smaller components into 20bit ints each
460 for (int i = 0; i < 4; ++i) {
461 if (i != largest_index) {
462 packed |= uint64_t(int(q[i] * conv) + 524287) << shift;
471 void Packet::Payload::Read(glm::quat &val, size_t off) const noexcept {
472 // extract the 8 byte packed value
475 // two most significant bits are the index of the largest (omitted) component
476 int largest_index = packed >> 62;
477 // if all other three are 0, largest is 1 and we can omit the conversion
478 if ((packed & 0xFFFFFFFFFFFFFFF) == 0x7FFFF7FFFF7FFFF) {
479 val = { 0.0f, 0.0f, 0.0f, 0.0f };
480 val[largest_index] = 1.0f;
483 // we have to map from [-524287,524287] to [-0.7072,0.7072]
484 constexpr float conv = 0.7072f / 524287.0f;
486 for (int i = 0; i < 4; ++i) {
487 if (i != largest_index) {
488 val[i] = float(int((packed >> shift) & 0xFFFFF) - 524287) * conv;
491 // set to zero so the length of the other three can be determined
495 // omitted component squared is 1 - length squared of others
496 val[largest_index] = sqrt(1.0f - glm::length2(val));
497 // and already normalized
500 void Packet::Payload::Write(const EntityState &state, size_t off) noexcept {
501 Write(state.pos.chunk, off);
502 WritePackU(state.pos.block * (1.0f / ExactLocation::fscale), off + 12);
503 Write(state.velocity, off + 18);
504 Write(state.orient, off + 30);
505 WritePackN(state.pitch * PI_0p5_inv, off + 38);
506 WritePackN(state.yaw * PI_inv, off + 40);
509 void Packet::Payload::Read(EntityState &state, size_t off) const noexcept {
510 Read(state.pos.chunk, off);
511 ReadPackU(state.pos.block, off + 12);
512 Read(state.velocity, off + 18);
513 Read(state.orient, off + 30);
514 ReadPackN(state.pitch, off + 38);
515 ReadPackN(state.yaw, off + 40);
516 state.pos.block *= ExactLocation::fscale;
517 state.pitch *= PI_0p5;
521 void Packet::Payload::Write(const EntityState &state, const glm::ivec3 &base, size_t off) noexcept {
522 WritePackB(state.pos.chunk - base, off);
523 WritePackU(state.pos.block * (1.0f / ExactLocation::fscale), off + 3);
524 Write(state.velocity, off + 9);
525 Write(state.orient, off + 21);
526 WritePackN(state.pitch * PI_0p5_inv, off + 29);
527 WritePackN(state.yaw * PI_inv, off + 31);
530 void Packet::Payload::Read(EntityState &state, const glm::ivec3 &base, size_t off) const noexcept {
531 ReadPackB(state.pos.chunk, off);
532 ReadPackU(state.pos.block, off + 3);
533 Read(state.velocity, off + 9);
534 Read(state.orient, off + 21);
535 ReadPackN(state.pitch, off + 29);
536 ReadPackN(state.yaw, off + 31);
537 state.pos.chunk += base;
538 state.pos.block *= ExactLocation::fscale;
539 state.pitch *= PI_0p5;
543 void Packet::Payload::WritePackB(const glm::ivec3 &val, size_t off) noexcept {
544 Write(int8_t(val.x), off);
545 Write(int8_t(val.y), off + 1);
546 Write(int8_t(val.z), off + 2);
549 void Packet::Payload::ReadPackB(glm::ivec3 &val, size_t off) const noexcept {
559 void Packet::Payload::WritePackN(float val, size_t off) noexcept {
560 int16_t raw = glm::clamp(glm::round(val * 32767.0f), -32767.0f, 32767.0f);
564 void Packet::Payload::ReadPackN(float &val, size_t off) const noexcept {
567 val = raw * (1.0f/32767.0f);
570 void Packet::Payload::WritePackN(const glm::vec3 &val, size_t off) noexcept {
571 WritePackN(val.x, off);
572 WritePackN(val.y, off + 2);
573 WritePackN(val.z, off + 4);
576 void Packet::Payload::ReadPackN(glm::vec3 &val, size_t off) const noexcept {
577 ReadPackN(val.x, off);
578 ReadPackN(val.y, off + 2);
579 ReadPackN(val.z, off + 4);
582 void Packet::Payload::WritePackU(float val, size_t off) noexcept {
583 uint16_t raw = glm::clamp(glm::round(val * 65535.0f), 0.0f, 65535.0f);
587 void Packet::Payload::ReadPackU(float &val, size_t off) const noexcept {
590 val = raw * (1.0f/65535.0f);
593 void Packet::Payload::WritePackU(const glm::vec3 &val, size_t off) noexcept {
594 WritePackU(val.x, off);
595 WritePackU(val.y, off + 2);
596 WritePackU(val.z, off + 4);
599 void Packet::Payload::ReadPackU(glm::vec3 &val, size_t off) const noexcept {
600 ReadPackU(val.x, off);
601 ReadPackU(val.y, off + 2);
602 ReadPackU(val.z, off + 4);
606 void Packet::Login::WritePlayerName(const string &name) noexcept {
607 WriteString(name, 0, 32);
610 void Packet::Login::ReadPlayerName(string &name) const noexcept {
611 ReadString(name, 0, 32);
614 void Packet::Join::WritePlayer(const Entity &player) noexcept {
615 Write(player.ID(), 0);
616 Write(player.GetState(), 4);
619 void Packet::Join::ReadPlayerID(uint32_t &id) const noexcept {
623 void Packet::Join::ReadPlayerState(EntityState &state) const noexcept {
627 void Packet::Join::WriteWorldName(const string &name) noexcept {
628 WriteString(name, 46, 32);
631 void Packet::Join::ReadWorldName(string &name) const noexcept {
632 ReadString(name, 46, 32);
635 void Packet::PlayerUpdate::WritePredictedState(const EntityState &state) noexcept {
639 void Packet::PlayerUpdate::ReadPredictedState(EntityState &state) const noexcept {
643 void Packet::PlayerUpdate::WriteMovement(const glm::vec3 &mov) noexcept {
647 void Packet::PlayerUpdate::ReadMovement(glm::vec3 &mov) const noexcept {
651 void Packet::PlayerUpdate::WriteActions(uint8_t actions) noexcept {
655 void Packet::PlayerUpdate::ReadActions(uint8_t &actions) const noexcept {
659 void Packet::PlayerUpdate::WriteSlot(uint8_t slot) noexcept {
663 void Packet::PlayerUpdate::ReadSlot(uint8_t &slot) const noexcept {
667 void Packet::SpawnEntity::WriteEntity(const Entity &e) noexcept {
670 Write(e.GetModel().GetModel().ID(), 4);
672 Write(uint32_t(0), 4);
674 Write(e.GetState(), 8);
675 Write(e.Bounds(), 50);
677 if (e.WorldCollidable()) {
681 WriteString(e.Name(), 78, 32);
684 void Packet::SpawnEntity::ReadEntityID(uint32_t &id) const noexcept {
688 void Packet::SpawnEntity::ReadModelID(uint32_t &id) const noexcept {
692 void Packet::SpawnEntity::ReadEntity(Entity &e) const noexcept {
701 ReadString(name, 78, 32);
705 e.WorldCollidable(flags & 1);
709 void Packet::DespawnEntity::WriteEntityID(uint32_t id) noexcept {
713 void Packet::DespawnEntity::ReadEntityID(uint32_t &id) const noexcept {
717 void Packet::EntityUpdate::WriteEntityCount(uint32_t count) noexcept {
721 void Packet::EntityUpdate::ReadEntityCount(uint32_t &count) const noexcept {
725 void Packet::EntityUpdate::WriteChunkBase(const glm::ivec3 &base) noexcept {
729 void Packet::EntityUpdate::ReadChunkBase(glm::ivec3 &base) const noexcept {
733 void Packet::EntityUpdate::WriteEntity(const Entity &entity, const glm::ivec3 &base, uint32_t num) noexcept {
734 uint32_t off = GetSize(num);
736 Write(entity.ID(), off);
737 Write(entity.GetState(), base, off + 4);
740 void Packet::EntityUpdate::ReadEntityID(uint32_t &id, uint32_t num) const noexcept {
741 uint32_t off = GetSize(num);
745 void Packet::EntityUpdate::ReadEntityState(EntityState &state, const glm::ivec3 &base, uint32_t num) const noexcept {
746 uint32_t off = GetSize(num);
747 Read(state, base, off + 4);
750 void Packet::PlayerCorrection::WritePacketSeq(std::uint16_t s) noexcept {
754 void Packet::PlayerCorrection::ReadPacketSeq(std::uint16_t &s) const noexcept {
758 void Packet::PlayerCorrection::WritePlayer(const Entity &player) noexcept {
759 Write(player.GetState(), 2);
762 void Packet::PlayerCorrection::ReadPlayerState(EntityState &state) const noexcept {
766 void Packet::ChunkBegin::WriteTransmissionId(uint32_t id) noexcept {
770 void Packet::ChunkBegin::ReadTransmissionId(uint32_t &id) const noexcept {
774 void Packet::ChunkBegin::WriteFlags(uint32_t f) noexcept {
778 void Packet::ChunkBegin::ReadFlags(uint32_t &f) const noexcept {
782 void Packet::ChunkBegin::WriteChunkCoords(const glm::ivec3 &pos) noexcept {
786 void Packet::ChunkBegin::ReadChunkCoords(glm::ivec3 &pos) const noexcept {
790 void Packet::ChunkBegin::WriteDataSize(uint32_t s) noexcept {
794 void Packet::ChunkBegin::ReadDataSize(uint32_t &s) const noexcept {
798 void Packet::ChunkData::WriteTransmissionId(uint32_t id) noexcept {
802 void Packet::ChunkData::ReadTransmissionId(uint32_t &id) const noexcept {
806 void Packet::ChunkData::WriteDataOffset(uint32_t o) noexcept {
810 void Packet::ChunkData::ReadDataOffset(uint32_t &o) const noexcept {
814 void Packet::ChunkData::WriteDataSize(uint32_t s) noexcept {
818 void Packet::ChunkData::ReadDataSize(uint32_t &s) const noexcept {
822 void Packet::ChunkData::WriteData(const uint8_t *d, size_t l) noexcept {
823 size_t len = min(length - 12, l);
824 memcpy(&data[12], d, len);
827 void Packet::ChunkData::ReadData(uint8_t *d, size_t l) const noexcept {
828 size_t len = min(length - 12, l);
829 memcpy(d, &data[12], len);
832 void Packet::BlockUpdate::WriteChunkCoords(const glm::ivec3 &coords) noexcept {
836 void Packet::BlockUpdate::ReadChunkCoords(glm::ivec3 &coords) const noexcept {
840 void Packet::BlockUpdate::WriteBlockCount(uint32_t count) noexcept {
844 void Packet::BlockUpdate::ReadBlockCount(uint32_t &count) const noexcept {
848 void Packet::BlockUpdate::WriteIndex(uint16_t index, uint32_t num) noexcept {
849 uint32_t off = GetSize(num);
853 void Packet::BlockUpdate::ReadIndex(uint16_t &index, uint32_t num) const noexcept {
854 uint32_t off = GetSize(num);
858 void Packet::BlockUpdate::WriteBlock(const Block &block, uint32_t num) noexcept {
859 uint32_t off = GetSize(num) + 2;
863 void Packet::BlockUpdate::ReadBlock(Block &block, uint32_t num) const noexcept {
864 uint32_t off = GetSize(num) + 2;
868 void Packet::Message::WriteType(uint8_t type) noexcept {
872 void Packet::Message::ReadType(uint8_t &type) const noexcept {
876 void Packet::Message::WriteReferral(uint32_t ref) noexcept {
880 void Packet::Message::ReadReferral(uint32_t &ref) const noexcept {
884 void Packet::Message::WriteMessage(const string &msg) noexcept {
885 WriteString(msg, 5, MAX_MESSAGE_LEN);
888 void Packet::Message::ReadMessage(string &msg) const noexcept {
889 ReadString(msg, 5, MAX_MESSAGE_LEN);
893 void ConnectionHandler::Handle(const UDPpacket &udp_pack) {
894 const Packet &pack = *reinterpret_cast<const Packet *>(udp_pack.data);
895 switch (pack.Type()) {
896 case Packet::Ping::TYPE:
897 On(Packet::As<Packet::Ping>(udp_pack));
899 case Packet::Login::TYPE:
900 On(Packet::As<Packet::Login>(udp_pack));
902 case Packet::Join::TYPE:
903 On(Packet::As<Packet::Join>(udp_pack));
905 case Packet::Part::TYPE:
906 On(Packet::As<Packet::Part>(udp_pack));
908 case Packet::PlayerUpdate::TYPE:
909 On(Packet::As<Packet::PlayerUpdate>(udp_pack));
911 case Packet::SpawnEntity::TYPE:
912 On(Packet::As<Packet::SpawnEntity>(udp_pack));
914 case Packet::DespawnEntity::TYPE:
915 On(Packet::As<Packet::DespawnEntity>(udp_pack));
917 case Packet::EntityUpdate::TYPE:
918 On(Packet::As<Packet::EntityUpdate>(udp_pack));
920 case Packet::PlayerCorrection::TYPE:
921 On(Packet::As<Packet::PlayerCorrection>(udp_pack));
923 case Packet::ChunkBegin::TYPE:
924 On(Packet::As<Packet::ChunkBegin>(udp_pack));
926 case Packet::ChunkData::TYPE:
927 On(Packet::As<Packet::ChunkData>(udp_pack));
929 case Packet::BlockUpdate::TYPE:
930 On(Packet::As<Packet::BlockUpdate>(udp_pack));
932 case Packet::Message::TYPE:
933 On(Packet::As<Packet::Message>(udp_pack));
936 // drop unknown or unhandled packets