i created my own protocol for my games...

Поделиться
HTML-код
  • Опубликовано: 10 окт 2024
  • / theprimeagen
    Best Way To Support Me
    Become a backend engineer. Its my favorite site
    boot.dev/?prom...
    This is also the best way to support me is to support yourself becoming a better backend engineer.
    MY MAIN YT CHANNEL: Has well edited engineering videos
    / theprimeagen
    Discord
    / discord
    Have something for me to read or react to?: / theprimeagen
    Kinesis Advantage 360: bit.ly/Prime-K...
    Get production ready SQLite with Turso: turso.tech/dee...

Комментарии •

  • @notrealsaga
    @notrealsaga 23 часа назад +243

    Watching people who are great at using vim is like watching people training at the gym: you find them sexy, you want to be like them, but you don't want to go through the effort

    • @Skaffa
      @Skaffa 23 часа назад +18

      i like the way you worded that

    • @Kane0123
      @Kane0123 22 часа назад +3

      This is perfeft

    • @moonasha
      @moonasha 21 час назад +6

      not even worth the effort for me. I spend maybe 5% of the time actually coding, the rest is switching between files, peeking at classes, debugging. All the shortcuts don't mean diddly squat for me. But visual studio's tab layout and ability to peek at stuff really quickly helps.

    • @hamm8934
      @hamm8934 21 час назад +16

      Vim speeds up switching files, peeking at classes, and debugging, and much more. Vim isnt just about the improved speed writing code. Vim speeds up window management, navigating files, moving window panes, etc..

    • @Testvvjnb-ci3zl
      @Testvvjnb-ci3zl 21 час назад +3

      @@moonasha hm really? I am working in a medium sized go project in lazyvim currently and few months ago used vs code. To me, all of the things you said feel much more comfortable in it. Debugging is basically on par (weird default shortcuts), but for me project navigation, or switching between files is much easier in vim.

  • @Crcs-1997
    @Crcs-1997 День назад +81

    These video formats are my favorite. Love the content

  • @kaibe5241
    @kaibe5241 21 час назад +11

    Man, really wanna see more of these kinds of videos - your deep dive into this, showcasing also your knowledge of things like TCP protocol and websockets, is super interesting :)

  • @AlucardNoir
    @AlucardNoir День назад +45

    "[...]I think that's probably more than enough, than I need" You're just asking for trouble now.

    • @Exilum
      @Exilum 20 часов назад +5

      That's what the version tag is for

  • @kefpull6676
    @kefpull6676 День назад +148

    "kinda FUN"
    (laughs in 9999 possible vulnerabilities)

    • @AstuteJoe
      @AstuteJoe 23 часа назад +9

      Kinda the only way to make profitable realtime* multiplayer games unfortunately though

    • @ahmednishaal9432
      @ahmednishaal9432 23 часа назад +4

      Let's have Thor ethically hack his servers 😂😂😂

    • @rusting_in_peace
      @rusting_in_peace 21 час назад +6

      first make shit work, then make it safe. Securing a protocol/channel is not an easy task, and you probably need the support of your Russian/Asian hacker friend to do it.

    • @AstuteJoe
      @AstuteJoe 21 час назад +2

      ​@@rusting_in_peace Not quite the case with multiplayer games too, if you don't plan the architecture ahead, and consider the gameplay implications of each architecture, you can end up with a networking model that will never be cheat proof, like making a peer to peer competitive shooter

    • @rusting_in_peace
      @rusting_in_peace 21 час назад

      @@AstuteJoe you have a point. And I think even now, hundreds of AAA game's middleware engineers must be working on it constantly to find an effective way...but the nature of the domain is what should be addressed on a case-by-case basis.

  • @nexovec
    @nexovec День назад +12

    Yes, I did. Unfortunately it was written in lua, so as you can imagine, the moment I stopped sending string identifiers was the moment it kind of lost its ground.

  • @AJMansfield1
    @AJMansfield1 22 часа назад +6

    I've built my own network format, it was horrible to debug because it was specifically designed to resist casual inspection -- using a hash-based addressing scheme where each station needed to use its cryptographic key to decide whether or not any given packet was addressed to and/or meant to be relayed by them.

  • @privacyvalued4134
    @privacyvalued4134 22 часа назад +10

    0:29 I've made so many protocols at this point, from binary to text protocols, that this is child's play for me. My recommendation for anyone's first network protocol: Two-way JSON separated by newlines. Is it efficient? Nope. JSON encoding/decoding performance is always terrible. Will it work surprisingly well? Yup! Can you easily interop fairly complex data across multiple languages and avoid a ton of bugs and security pitfalls? Sure. Can you alter it without worrying about its structure? Absolutely.

  • @Moner-nt5td
    @Moner-nt5td 8 часов назад +1

    I created my protocol 10 years ago, consider a short in the packet for routing, do not use a int for len unless you want recieve 2 gb packets, handle all connections and packets in a own async thread pool. the CPU has a fast array copy instruction, keep that in mind.

  • @TheScabbage
    @TheScabbage 18 часов назад +2

    I've been using little-endian in my protocols for years, just because all the major architectures use it. It simplifies a lot of code and saves the small perf hit of having to convert back and forth constantly.

  • @kajika135bis
    @kajika135bis 12 часов назад +4

    "if count == 5" should be "if count == BUF_COUNT", just sayin

  • @sskeptix
    @sskeptix 17 часов назад +1

    I played with that stuff 2 years ago. I did almost the same except I didn't have an encoding flag but instead I had a packageId flag. You may have a situation when your client sends multiple packages and the server can spend a different amount of time handling them. Client sample sequence of events:
    Send1, send2, send3, receive response1, receive3, send4, receive2, receive4
    You may have 2 types of packages: notifications (fire and forget), request, and response.

  • @RedSpark_
    @RedSpark_ День назад +1

    I love these videos, they're so inspiring. I started building a text based adventure game to learn about OOP and some design patterns, but now I'm thinking about how I could make it multiplayer.

  • @GlennLewis
    @GlennLewis 18 часов назад +1

    Remember the Amiga IFF ("Interchange File Format")? This brings back lots of fond memories. 🙂 Thanks for sharing!

    • @Patterner
      @Patterner 11 часов назад

      sometimes in my nightmares after i wake up screaming

  • @KvapuJanjalia
    @KvapuJanjalia 23 часа назад +3

    I've created my own protocol but with variable length integers in header, because it is more _fun._

  • @regiondeltas
    @regiondeltas 22 часа назад +4

    This is my cup of tea. I'm not a developer by trade but I've been working on a Pico powered hobby project, in rust because of course. I've written an extensive low level TCP protocol for data transfer, super lightweight, extensible, variable packet sizes and data types etc and with a nice shared library so that I can use the same core code for both the server (again, in rust) and the pico client. You learn a LOT when implementing things at this level and its so satisfying when you get it working end to end. Got a simple UDP discovery protocol too, which was fun to do

  • @mickey20512
    @mickey20512 18 часов назад

    More of these videos please! love these insights and learn heaps more then the react vidoes

  • @pixelfingers
    @pixelfingers 21 час назад

    Love these videos, you’re very good at describing and teaching, excellent ❤

  • @reybontje2375
    @reybontje2375 15 часов назад

    Fixed-length encoding for the length header. Gigachad.
    I don't know if it was a conscious choice, but using variable-length integers for the length header drastically increases the complexity of parsing the header in a safe/secure way that doesn't open you up to DoS attacks that come from carefully engineered messages.

    • @aredrih6723
      @aredrih6723 5 часов назад +1

      The assert around 7:14 checking that the packet length is greater than 0 is a DoS waiting to happen (a message with no body will crash the server).
      As for using variable length integers in headers, beside overflows in naive parsing, I fail to see the issue with them. I agree more considerations and processing are required to handle variable length fields and their flexibility is really too useful but IMHO the difference between fixed size and variable size isn't that large and you can reuse the code elsewhere.
      Unless you plan to decode raw messages by hand (in this case, a decoding util is pretty good), I fail to see the difference.

  • @masterflitzer
    @masterflitzer 7 часов назад +2

    11:32 wait prime is not raw dogging git cli?

  • @ericmackrodt9441
    @ericmackrodt9441 21 час назад

    That's very similar to the Napster protocol. I made a similar one to communicate with a Windows 3.11 chat app I'm building.
    The difference is that the actual values are sent in a specific order separated by spaces after the length.

  • @NostraDavid2
    @NostraDavid2 8 часов назад

    What? You've got a nice encoding-decoding setup going and you're NOT PBTing that shit? HAWK TUA ON THAT CODE!
    Slapping some Property-Based Testing on code that bijective code is the best you can do here!

  • @valentinrafael9201
    @valentinrafael9201 14 часов назад +2

    Dude, you are inspiring!

  • @canofpulp
    @canofpulp День назад +5

    Microsoft recall is enabled by default in the latest Windows update!!!!!!!!! update 24H2

  • @wdavid3116
    @wdavid3116 19 часов назад

    If the packet is being sent via UDP you don't have to send the length because the UDP packet has a length associated with it and it will be received as a discrete message. If you send the packet via TCP (unlikely to be a good idea for real time game data,) you absolutely need a length to know where in the stream a particular message ends, or you have to do something ugly like a delimiter or fixed size messages or something.
    There isn't really any reason to use bigendian. Virtually all modern CPUs use little endian though it is pretty trivial to byteswap from big endian. The only potential advantage is that reading the data in hex format will be easier with bigendian but there isn't any reason to do that when you developed the protocol and clearly have code to parse it and present it to you in a readable fashion. It isn't very wasteful but unless you're doing raw sockets or something there is no reason to do big endian.
    Personally I really wish go had a c struct compatibility library similar to the python struct library. That would take care of all the padding and you could just use structures fill them with data and send them through sockets without serialising anything (as long as all the struct members are simple data types or structs composed of them with no pointers.) I think you can do this with unsafe go but then you lose a bunch of the benefits of using go. I settled on just using protobufs for my protocols in go. They aren't for a game but likely would be just fine for basically any game someone might write and I can generate code for all the other languages I use without doing anything. I almost went with CapNProto but it didn't support all the languages I jump between for my side projects.

  • @niklaswojtkowiak3
    @niklaswojtkowiak3 18 часов назад +1

    Was this supposed to be on the Vimagen?

    • @tayoyuva2203
      @tayoyuva2203 13 часов назад +1

      Ya i guess he uploaded in the wrong channel probably :)

  • @bautistarescala
    @bautistarescala День назад +2

    May i know how you type those sequence diagrams easily? I assume it's some Vim macro but i don't use Vim so i don't know but i'd like to learn. Seems pretty useful.

  • @barry_wastaken
    @barry_wastaken 12 часов назад

    Wait untill he finds out about event driven architectures, he will have no hair left.

  • @_Gart_
    @_Gart_ День назад +1

    I need the matrix so I can download programming knowledge like this guy. He's so fast

  • @HypeLevels
    @HypeLevels День назад +10

    ligmuh (I am scared let's watch this 😂)

  • @pdougall1
    @pdougall1 21 час назад

    Such a great experience in having a horrible time... my whole existence

  • @ErazerPT
    @ErazerPT 22 часа назад

    Kinda wondering if just having packet[2]+packet[3]*256 (or packet[3]+packet[2]*256 depending on how you wrote it) would have any significant speed difference over a function call that basically does... just that. An optimizing compiler should inline it, but...

  • @vessbakalov8958
    @vessbakalov8958 7 часов назад

    This was really good.

  • @metaltyphoon
    @metaltyphoon 15 часов назад

    Lol with those asserts and break the world all it takes is non ECC memory to fail in the right place and it all falls apart.

  • @MrAbrazildo
    @MrAbrazildo 23 часа назад

    4:05, if PACKET_ ... _SIZE is a constant, shouldn't this assert be 'n < PACKET...'?
    4:08, literal numbers... the most underestimated issue of all time! They should be MAX_TYPE_SIZE and ENCOD_SHIFT.
    6:36, couldn't it be bigger? In this case, your if would fail.

  • @gamemusicmeltingpot2192
    @gamemusicmeltingpot2192 17 часов назад

    I worked on a game that had this type of special protocol

  • @digiryde
    @digiryde 2 часа назад

    As to creating your own packet structure.... Do you have to have succeeded for it to count?

  • @portal-jx5pu
    @portal-jx5pu 14 часов назад

    Nice protocol

  • @AndreanFranc
    @AndreanFranc 9 часов назад

    I think little-endian makes more sense (even though it's not the network byte order), just because most of the architectures are little-endian now anyway. Better pay a penalty for conversion only on the outlier architectures (big-endian, if they even exist as your clients), than pay for it everywhere in a wasteful manner.

  • @TheDoppelganger29
    @TheDoppelganger29 21 час назад +1

    Just where do you find time after work??

    • @johnyewtube2286
      @johnyewtube2286 18 часов назад

      He no longer works at Netflix, he is full time e celeb.

  • @jop0693
    @jop0693 23 часа назад +1

    Anyone knows how he did the markdown graphics?

  • @dennisloska
    @dennisloska День назад

    What's the fonts/plugin name which Prime is using here? The != and

    • @benbrook469
      @benbrook469 День назад +1

      they are ligatures

    • @arashiryuu1624
      @arashiryuu1624 22 часа назад

      The font is JetBrainsMono and those are ligatures as another commenter already mentioned. I'm not sure but I think this is the default font for Ghostty. It doesn't look like Prime has done much if any customization.

    • @dennisloska
      @dennisloska 9 часов назад

      @@benbrook469 I learned somethong new today, thanks man!

    • @dennisloska
      @dennisloska 9 часов назад

      @@arashiryuu1624 Thanks!

  • @johnlovell8299
    @johnlovell8299 22 часа назад

    You didn't use Mermaid in your Markdown? Shame! :)

  • @Haise-san
    @Haise-san Час назад

    Is that csharp ?

  • @aajas
    @aajas 23 часа назад +4

    6c is lowercase, the thumbnail has uppercase L

  • @kimberlycelaya1895
    @kimberlycelaya1895 День назад

    Welcome💙 🔥🔥🔥

  • @Cdaprod
    @Cdaprod 21 час назад

    All the time.

  • @harithbakhrani
    @harithbakhrani 14 часов назад

    I didn't understand anything, but it was fun watching 😅

  • @ոakedsquirtle
    @ոakedsquirtle 14 часов назад

    okay but what is a framer

  • @Noober666
    @Noober666 День назад

    I already knew how to do this, just wasn’t gonna tell u 😏

  • @luizalbertolausdarosa6819
    @luizalbertolausdarosa6819 22 часа назад

    Now do it with UDP, please!

    • @justanothercomment416
      @justanothercomment416 22 часа назад

      Basically the same thing. He can either fill a buffer with multiple packets and send that as a datagram (looping on read), or simply send/recv on packet per datagram. TCP is usually slightly more involved because you need to know how to parse the stream and to account for short reads and so on. Which requires lengths so as to know when the full packet (or plural) has arrived. He has lengths embedded in his packets so it's good.

    • @Testvvjnb-ci3zl
      @Testvvjnb-ci3zl 21 час назад

      @@justanothercomment416 udp gets fun when you need: Reliability Types, ACKs, NAKs, Ordering Channels, Split Packets, Priorities

  • @asmod4n
    @asmod4n День назад

    you can send empty packets for keep alive :)

    • @greyshopleskin2315
      @greyshopleskin2315 20 часов назад

      The kernel should automatically send keep alive packets (assuming the socket type is tcp)

    • @asmod4n
      @asmod4n 14 часов назад

      Realtime communication protocols aren't tcp. I also believe you can restrict usage of tcp keep alive for apps on some operating systems.

  • @codingwithifeanyi5379
    @codingwithifeanyi5379 18 часов назад

    it this go?

  • @bertram-raven
    @bertram-raven 23 часа назад +1

    Naive in so many ways from the start. Does it get better? Where is the error correction? Where is the message resync?

  • @memory_leaps
    @memory_leaps День назад +1

    how did u made the ascii tables

    • @ItzD3fW1sH
      @ItzD3fW1sH День назад +1

      Plenty of online generators for it

  • @milseq
    @milseq 8 часов назад

    Go is so damn beautiful I really need to learn it and find a project to use it on

  • @Mraeth8n
    @Mraeth8n 23 часа назад

    why did you choose 8 bits for the version? Wouldn't like maybe even 4 be sufficient?

    • @chinoto1
      @chinoto1 22 часа назад +2

      If you're careful, but if you run fast and break things constantly... Maybe he should have gone bigger 🤣

    • @Mraeth8n
      @Mraeth8n 21 час назад

      @@chinoto1 haha 🤣

  • @thip1754
    @thip1754 День назад

    Ligma

  • @mitaskeledzija6269
    @mitaskeledzija6269 12 часов назад

    Kinda fun, is just coping because I don't have a job.. 🤣 commit to open source create a game create protocol bla bla.. still no job fuck this market

  • @tsgraphics1
    @tsgraphics1 День назад +1

    First

  • @jonathan-._.-
    @jonathan-._.- День назад +1

    tldr: always add version byte... (tes rest can be ignored 😌)

  • @healord51
    @healord51 22 часа назад

    this is not funny, I almost died of ligma a couple years ago

  • @midicine2114
    @midicine2114 День назад +1

    There's no money in creating a protocol for funsies therefore none of the new devs are going to do it.

  • @blackCladLad
    @blackCladLad День назад

    What’s Ligma

  • @johnlovell8299
    @johnlovell8299 22 часа назад

    binary.BigEndian FTW!

  • @mattbillenstein
    @mattbillenstein 22 часа назад

    msgpack-rpc and yolo

  • @thetruth000
    @thetruth000 День назад +1

    first