Category: networking

A New PC

A New PC

Computer monitors
Image by Gerd Altmann from Pixabay

Moving to a new PC can be a time consuming process. This is my 10th PC since 1989 and I’ve been accumulating files, old programs, websites, manuals etc. as I moved from PC to PC. My first PC had a 20 MB disk, the 2nd PC had a hard disk with 240 MB capacity. On my new PC it’s 10 TB and 1 TB SSD.

It’s another i7 but 11th Gen Intel(R) Core(TM) i7-11700K. Only 32 GB RAM for now as they didn’t have 64 GB in stock but the motherboard can go up to 128 GB.

I estimated that I had accumulated just over 2 TB of my stuff and once I got my new PC setup started the process of moving files across. 2 TB seems a lot but VMs under Hyper-V can easily eat up a few hundred GBs.

Both PCs had a gigabit network card and were plugged into a gigabit switch so what speed did it give me? 11 MB/S. That’s not gigabit speed which would be about 1000 MB/s but closer to 100 Mbs. Trouble was the switch was plugged into a router and I think that pulled things down. I borrowed a crossover cable. Setup both Pcs with static IP and connected them directly. That was much better and it was soon maxing out at 112 MBs.

Windows of course put its spoke in. If you are copying large files- anything over about 1 MB then it uses the full bandwidth but smaller files pull it down and I’d see as slow as KB/s speeds. So I’d have three or four files copying at the same time.

As well as just copying files to the new PC, I was cleaning up my old PC to sell it so I was either deleting stuff or moving it. Overall my total elapsed time was something like 28 hours over four days and evenings. Plus of course installing software (Visual Studio, VS Code, Android Studio, MS Office). It all takes time. Luckily I’ve been quite disciplined and kept all licences and serial numbers in an encrypted text file.

Then I discovered that my new PC’s video cards had different connectors. My old one had DVIs but this one I could only find an HDMI and 2 DisplayPorts. There was a DVI connector on the video card but the firm that did it put the card in the top slot and the DVI (2nd row) was covered up by a blanking plate! It’s a RTX 2060 card. I removed it and all was well.

RTX 2060

Now for some mobile networking

Now for some mobile networking

Early taxi app screenshotNot the face to face type but actual networking. This is needed because I’m working on a game server. My mobile game (Manana Banana) will become networked enabled and thus multiplayer.  C# is ideal for this type of thing but I’m not using the networking capability of MonoGame instead managing the whole lot myself.

Back a few years ago when I was a full-time mobile developer I wrote an app that was used by taxi drivers. It was a conversion of an Android App (I wrote it from scratch running on an iPhone based on the Android source code).  There’s a curious architecture with such apps because not only is the a user interface but in the background the app was “chatting” over 3G to a central server (written in VB6 I kid you not) which sent an “are you alive?” message every six seconds to every driver’s phone.

It was not a traditional client-server architecture but the kind of system where the driver could send a message to the server or the server could send a message to the driver. 

What this meant was the app was always keeping one eye on the 3G, getting messages and then it might for instance popup a screen saying “There’s a job from x to y. Do you want it?”. If the driver said yes then the app would receive details and show the driver the route to the pickup point. If the driver didn’t respond within 30 seconds or said no then the program would pass that back to the server,

What is a ConcurrentQueue?

C# has an advanced data structure called a ConcurrentQueue<t> which is a thread safe generic queue. I used two of these, one for a receive queue and one for a transmit queue in conjunction with a thread that never finished. All the 3G stuff was done using C# TCP/IP clients and ran in this thread. Messages that came in were put on the receive queue and could be popped off and processed in the main program. Messages to send out from the main program were put on the transmit queue and sent out in the thread. It was a very clean way of separating the main application running in the main thread from the 3G running in a background thread. 

Compared to the Android program which was all running in one thread and polled the 3G, I was told by my drivers that my app felt much more responsive!   The screenshot above was a very early image of it. It had a very simple UI where each screen of controls (Views in iOS parlance) was built up dynamically.  

Also C#/Xamarin has a way of getting from a thread to the main thread on iOS. You cannot update any controls from any thread only from the main UI thread.  There’s a method called InvokeOnMainThread for the Xamarin iOS controls. See this Microsoft/Xamarin documentation on how to use it. So that’s what I’ll be doing in my networked game.  

Interestingly because I’m managing everything, the TCP/IP messages can be very small, under 20 bytes each. This allows a very high throughput.