Sign in to follow this  

Unity Monitor LAN/router traffic/bandwidth/usage

Recommended Posts

keinmann    122
This may sound weird, but I'm stuck with a crappy ISP (not to mention any names, like HughesNet Satellite) because I live about 3mi outside the boundary where cable/DSL is available. In addition to being slow, unreliable, having horrible customer service, little to no tech support (they diagnose connection problems by blinking lights on the outside of the customer's modem and took over 5 months to fix my satellite when it was hit by lightning) they have this thing called the "Fair Access Policy". The FAP limits how much you can up/down-load in a 24hr period. I have the best advertised plan; so-called "Business Plan" which gives me about 625mb...not an ideal situation when you're trying to work at a company that has around 10GB of stuff on SVN and run your own business and need frequent, large downloads. Only between the hours of 1-6am is the policy relaxed.

The problem is, somehow the download threshold keeps getting violated. What happens is AWFUL. Your connection is slashed to less-than-dialup speed...then they happily extend your "crippled period" if you use the internet much; usually another 24hrs if they're feeling friendly (sometimes much longer, with no explanation; then the "tech support" guy who knows only a few English phrases says "Eet iz seest-uhm, sir! Ie no cahn feex!").

But I MUST solve what is going on here. I know for a fact it is NOT me. I download virtually nothing until that brief window of time where the policy is relaxed. I strongly suspect it is a friend who is staying here for a few days. He did it once, and I explained the problem to him and told him he puts me out of an entire day of work if that happens. Many computer users don't understand they ARE downloading things when they use the internet, even if you don't click a button that says "Download"...and they ALL love watching Youtube videos back to back and downloading music. This was explained, and I told him it was safe to do only between 1-6am; then no videos, music or heavy usage because of my job. Now it's happened again, and you wouldn't believe how long it took me to get here to make this post.

So what I want to do is a bit over my head. I know only a tiny bit about network programming. But I want to write a tool/service which can do a few critical things and maybe a few bonus features:

* = Must-have
- = optional

*Must be able to monitor total download/upload bandwidth consumption in a day

*Must be able to monitor total usage for one PC on my network, or identify what usage is coming/going from where

*Must be able to run for very long periods of time, and reset itself and counters (Windows service seems appropriate; I think I'll also count with an unsigned long and keep the count by kilos to avoid overflow)

-Ability to "catch" anyone except me who consumes more than 150MB, and optionally, warn them or halt their connection to my LAN (I have 4 active PCs on my network)

-Ideally, with the above notion, I'd like to be able to "ration" or put hard limits on other PCs on my network. Even if I have to install this service/background application on my other PCs)

I guess that about covers it. This may sound quite extreme, because it is. Two family members normally use my network, then visitors who come over. Every time this happens now, no one will admit to it. I'm sick of it. And I have no choice but to stop it, and stop it immediately. It costs me dearly. I WISH that my ISP would accept a check to re-enable my service. It would be better (and save me money) to pay $100-300 bucks to lift the "cripple" sometimes. But alas, they don't. Believe me, I've pleaded with them when something very important is going on that requires internet connection. If I miss another Chewbacca Fan Club Online meeting, I will hit the ceiling! Kidding about that part. :)

I just wanted to run this by the fine folks of this community and see what suggestions, pointers, links and help I can get. I'm totally inexperienced with network programming except for writing chat applications, trying to write a failed port-forwarding library with UPnPNATLib.dll (the library itself always threw random exceptions on different routers which I could not understand) and simple TCP/UDP experiments. Other than that, I'm network-dumb.

I'm willing to work in C, C++ or C#; which ever gives me the best shot at accomplishing this efficiently. I would prefer C#, since it will be much faster and much less time worrying about debugging/platform issues. I know .NET has some powerful Networking classes, but I'm ignorant of what they can do and how to use them. Maybe someone can even show me a simple snippet of how to determine total bandwidth usage to get me rolling on this program.

Thanks! Sorry for the lengthy post, but I wanted to make everything clear to get better advice. :)

Share this post

Link to post
Share on other sites
Ravyne    14300
A program to monitor the traffic is probably not what you really want, nor would it be trivial to write.

Your best bet would be to check out your router's options -- most of them have options to block certain websites, and usually you can block them during certain times of the day, optionally. Some routers may even let you set quotas on certain users by MAC address. I know this kind of sucks for your family and guests, but it doesn't appear their behavior, combined with your ISPs policies, is giving you much choice.

If you don't already, consider using something like cron (*nix) or an equivalent to to any of your large transfers during the free-use window when possible (say, syncing to off-site version control, etc), maybe even set up a proxy server to cache sites you visit frequently (a good deal of the page code doesn't change frequently, so even a partial win will work in your favor).

Another option, if throwing money at the problem really is an option, is to consider installing a second satellite setup (or perhaps you have WiMax or similar in your area) and have one be for you, and the other for the rest of the household. If its strictly business, you can probably even write the cost off on your taxes.

Share this post

Link to post
Share on other sites
keinmann    122
Well thank you for mentioning this. Tell me about WiMAX? How can I possibly get it? And what sort of bandwidth/speed could I expect out of it? If it's not around ++100Mb/s and giving me MORE (or unlimited bandwidth), then I guess it wouldn't be worth it. But I'm not very wise to all of this new internet/networking stuff, nor do I know much about the new providers, technologies and services available (since they haven't been available to me for 5yrs).

I know writing such an application wouldn't be trivial; but I've done some things which I think would be exponentially more complex and difficult. :) Doesn't scare me too much. At least it's doing SOMETHING when I can't see many other options. I will also see what settings the router has, but AFAIK there's nothing which is going to solve this problem. I've gotten to the point where I just want to control it with an iron fist, and am willing to go to extreme measures to do so and ensure I don't get screwed out of 24+ hour periods of work.

I've looked into other options before, and was unable to do anything satisfactory to stop this. Maybe there is new technology which can settle this, so it's worth another look. But I'm still up for solutions about how to approach this "LAN dictator" application until (or if) something viable is discovered.

Share this post

Link to post
Share on other sites
Ravyne    14300
WiMax is similar to (or the same) as something like Clearwire -- basically it's like a long-range WiFi. I mention it because I grew up in a rural area where my parents still live, and Satellite and WiMax are the only non-dail-up options for rural folks outside of where the cable company can reach. It's worth looking into see if its available in your area and checking whether they've got more agreeable terms. Performance-wise I believe its comparable to a speedy DSL line.

What kind of speed are you getting out of your satellite? Does it still require a phone line for the upstream path? Its been awhile since I've looked at satellite-based internet.

Share this post

Link to post
Share on other sites
ApochPiQ    23003
The problem here isn't in implementing the software to do the monitoring; the problem is in network architecture.

The only way you can guarantee that you see all traffic going out to your ISP is to sit between the modem and your network itself, ideally outside your router. If this is even physically possible (some modems won't let you do this, or have integrated routers, etc.) it still represents a pretty hefty engineering challenge. I've written realtime network monitors and filters before, and I can assure you that it's a mammoth task. Traffic shaping in particular is incredibly hard to do right.

As mentioned, you're much better off trying to tap the router hardware itself for this. What model of router are you using? Wireless network or wired? I presume you have administrator access to the router itself? Would it be feasible to drop $80-90 and buy a replacement router with the sophistication to do the reporting and traffic shaping that you need?

In an extreme case, I suggest you just do what I eventually did: buy a $300 Linux or BSD machine, follow some basic setup steps to build that into a router, and then set up existing traffic monitoring/shaping software on that. I've run my local LAN and 802.11g networks off a FreeBSD box for a couple of years now, and it couldn't be better.

Share this post

Link to post
Share on other sites
keinmann    122
Thanks to you both for the concise and knowledgeable answers.

@ Ravyne :

No, no phoneline needed whatsoever. It's purely satellite. I will DEFINITELY look into this, because anything which severs my dependence on HughesNet will be one of the greatest things to ever happen to me; other than when I eventually move, for the sake of my business, and give this house and land to my mother, haha. I love it here, but living in the country is so problematic; especially for a software developer trying to make a living and pay monstrous bills.

@ ApochPIQ:

Let me clarify some things about what I have here; my fault for not giving some tech-specs from the start. Overall architecture looks like this (excuse my crappy diagram skills ;) haha) ::

Solid lines represent wired connections, while dashed lines represent wireless connections.

Modem - HughesNet "HN-9000" model
Router - LinkSys "WRT-160N" (a bit dated)

Computers themselves -

"Extra PCs" are other computers which belong to and are usually only used by me for software testing, and I only periodically connect them to the network to get online. At my disposal, I have my main desktop for work, and 4 other PCs (one is broken). One of them, an old salvage laptop, runs XP and Ubuntu Linux. The others all run XP. My main desktop runs Vista x64. The living room PC runs Vista x86, and my mother's laptop runs Vista x64. Hopefully this explains everything we're dealing with.

So, I actually do have disposable machines I can run Linux on (would prefer Linux as I have no BSD experience) and use as a network hub, if that would be a good solution.

Now that you understand my setup, any further advice on how to proceed will be greatly appreciated. Yes, buying a new router, IF it can offer the functionality I need to totally kill this problem, is a feasible option. I just need to know which one and what to do with it. I'm pretty ignorant in this department, so I will gladly accept advice/opinions.

Thanks again, folks.

Share this post

Link to post
Share on other sites
ApochPiQ    23003
I'd say take your Linux box and replace the router with that; setting up a Linux-based routing/shaping system is fairly straightforward, although not without some tricky bits.

You could potentially get a cheap hardware router with the features you need (or void a warranty or two by flashing custom firmware onto one) but that's up to you. IMHO the frustration of bricking routers and finicky router hardware isn't worth it; I'd much rather have a machine I can maintain myself and keep going indefinitely with a software solution. Plus I can do things like use the same box for various Internet-facing servers and such, which comes in handy.

Share this post

Link to post
Share on other sites
keinmann    122
Original post by ApochPiQ
I'd say take your Linux box and replace the router with that; setting up a Linux-based routing/shaping system is fairly straightforward, although not without some tricky bits.

You could potentially get a cheap hardware router with the features you need (or void a warranty or two by flashing custom firmware onto one) but that's up to you. IMHO the frustration of bricking routers and finicky router hardware isn't worth it; I'd much rather have a machine I can maintain myself and keep going indefinitely with a software solution. Plus I can do things like use the same box for various Internet-facing servers and such, which comes in handy.

That sounds like a very elegant solution; almost fun! If I did this, could I even write custom network software on the Linux machine? And could you point me to any links/articles where I can learn more about this and how to do it?

Also, will this still allow wireless connection? How? I only know what you've told me so far, so I appreciate all of this enlightenment and what is to come. :)

Share this post

Link to post
Share on other sites
ApochPiQ    23003
Yep, you can still do wireless; I have my BSD machine running as a wireless gateway for my local networks. Be aware though that most commodity wireless hardware does not allow you to run it in access-point mode, only client mode; so do some research to make sure you get compatible hardware.

I learned most of what I needed to know by hunting around on Google for a few hours; unfortunately I didn't save any links or I'd point you towards where I got my info. The best I can suggest is to pick a Linux/BSD distro and stick to it; starting with a known distro gives you a set of packages to work with and an anchor point for doing some research. You may find the terms "router", "gateway", "bridge", "traffic shaping", "wireless access point", and such useful. A good place to start on the software side is pf for BSD and iptables for Linux.

Share this post

Link to post
Share on other sites
keinmann    122
Thanks again, Apoch!

Yep, I suppose I need to dig in and do some searching of my own. We can't have everything handed to us, shame, haha. I suppose this is worth an attempt, since I theoretically don't have to buy anything nor spend time writing some complex piece of software pertaining to a subject matter I don't know jack about.

I guess I'll go ahead and mark this thread "[SOLVED]"! Just kidding! ;)

Thanks again!

Share this post

Link to post
Share on other sites
samfok    100
I got similar experience in my wireless environment, and I just used dedicated bandwidth management to solve this.

I used MyQoS to do this:
1. Record bandwidth usage of each and every IP addresses in my network daily, monthly, yearly
2. Limit each and every IP in my network with 256Kb/s, or 512Kb/s
3. Use the real-time monitor to check the current connections, bandwidth usage of each online users
4. Apply automatic p2p throttle like:
If any IP address has averaged more than 256Kb/s for the last 60 minutes, set the profile on that IP to reduce usage for 15 minutes.

MyQoS provides 2Mb/s free license, and it's quite flexible. You could get it at

Share this post

Link to post
Share on other sites
keinmann    122
Thanks, samfok. I will be looking into this option too. Still open to even more suggestions if anyone has them. If not, I will let this thread slip into oblivion and start doing something on my own.

Thanks again to everyone for their input! I'm very gracious for your time and effort.

Share this post

Link to post
Share on other sites
bpoint    464
Coding Horror posted a great article about this exact subject.

Dedicating a PC to the task of routing would certainly do the task, but it's also extremely overboard. If you don't mind the power bill/space used/noise emitted/etc., then by all means. :)

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Similar Content

    • By ilovegames
      You - the chief doctor of the hospital. Working late into the evening, did not notice the majority of hospital workers went home ... But where you disappeared the night shift is also not known. Hastily taking important documents, go home, but something went wrong as usual ... Can you get out of the hospital alive?

    • By Gator Man
      Game Concept Doc:

      We are looking for every position. From Game designer, to marketer, to programmer, to 3D modeler. Any further questions can be discussed through discord
      DISCORD: Gator#5635
    • By ilovegames
      Wind Of Fear is a game where we have to kill different kinds of waves of monsters packing weapons. The main goal is to survive the waves and pump up your own weapons. There is a store where you will buy new weapons, scattered crystals that restore your life are also on the map!

      WASD - Walking
      Shift - Running
      Mouse1 - Attack
      Space - Jump
      ScrolDown - weapon change
      T - Deceleration of time
      G - Bleed your weapon
      Esc - Exit, pause

    • By ilovegames
      Continuation of the first part of the game, Invention. While you were on the island exploring the underground laboratory, the infection was busy spreading throughout the world. In this episode, you have to go through a city populated by monsters in search of salvation aided by weapons that you will find during your travels. The gloomy atmosphere, music and atmosphere and a crowd of walking meat will keep you on your toes!

    • By Jacob Laurits Besenbacher Kjeldsen
      Intro - "The challenges of dynamic system design"
      Custom Quest evolved during development, from a minor quest system used for our own needs in our own game production Quest Accepted, to something entirely more dynamic and customizable, now finally released, these are our thoughts on quest design and developing standalone subsystems. 
      Splitting what is a major production for a small indie team, into smaller installments such as a quest system was a good idea we thought, this way we can get some releases out there and fuel the development of our game. But building a system that works for yourself is one thing, building a unity plugin that will let other developers create quests, missions, and objectives, you would never have thought of is something else entirely.
      The first thing we had to realize was that when building a quest system, the task is not to design great quests, the task is to enable the users to create great quests.
      That still meant we had to find out what good quest design is and what a quest really is.
      Our task was to create a system where the user is free to create creative engaging and rewarding mission experiences for their players.
      What is a quest? - "Cut to the core"
      First off, we need to know what a quest really is.
      A quest is the pursuit, search, expedition, task or assignment a person(s) does in order to find, gain or obtain something.
      In games, quests and missions function in many different ways depending on the genre.
      A single game can contain a multitude of different types of quests put together in just as many ways. In an MMO, for instance, quests are vehicles for the story and the player's progression. In many cases they are formulaic and simple, some can even be repeated, there are hundreds of them and everyone can do them. In other games quests are for single player campaigns only, here they shape each level giving the player a sense of purpose.
      Quests can span the whole game or just be a minor optional task on the way, there are so many design philosophies and creative quest designs that we had to narrow it down and really cut to the core of what is needed for good quest design.
      What all quests have in common is the task, the criteria for successful completion of the quest, and the reward, the goal of the quest, what the player gets out of doing what we ask of him.
      Quests cover an incredible variety of tasks so it was important for us to base our decisions on thorough research. In our research, we found that there are three layers to quest design.
      The type, the pattern and the superstructure.
      Quest types exist within quest patterns and quest patterns exist within the quest superstructure.
      We found that there are 8 basic types of quests these are the various tasks/criteria the player must do in order to complete the specific quest.
      There are 12 quest patterns. These are ways designers can use their quests, connect multiple quests set them up in engaging ways or teach players how to interact with and get the most out of the game world creating variety and engaging the player.
      Enveloping the patterns is the quest superstructure, the overall structure of quests in the game, we found that there are two main ways of structuring your quests.
      Historically quest have a quest giver, an NPC or object that informs the player about the quest, what they need to do, the story behind it and perhaps even what their reward will be should they complete the quest.
      Quest types - "Do this, do that"
      The core task each quest consists of, the criteria for completing part of or all of a single quest. These are the actions we want Custom Quest to be able to handle.
      Probably the most basic quest type, the task is to kill something in the game, for example; kill 10 goblins. Gather
      Again very simple, the task is to gather x things in the game world, collecting berries or the like. Escort
      The player must escort or follow a person or object from point A to B while keeping it safe. FedX
      The player is the delivery boy, they must deliver an item to a person or point. Defend
      The player has to defend a location from oncoming enemies, often for a set number of waves or time. Profit
      The player must have a certain amount of resources to complete the quest, contrary to gather quests these resources are resources the player would otherwise be able to use himself. Activate
      The player's task is to activate/interact with one or more objects in the game world or talk to a number of NPC’s. In some cases, this must be done in a certain order for a puzzle effect. Search
      Search an area, discover an area of the game world. This is useful for introducing areas of the map to the player and giving them a sense of accomplishment right off the bat, showing them a new quest hub or the like. Quest Patterns - "An engaging experience"
      Tasks are one thing, and in many games, that might be plenty but we wanted custom quest to let the users create chains of quests, specialize them and set them up in ways that draw the player into the experience, there are many ways to go about this.
      The most basic quest pattern, the quest chain starts out broad and easy, the player has to kill some low-level cronies. The next quest is narrower, the player must kill fewer but tougher enemies, lets say the boss' bodyguards. The last quest is the boss fight, the player has killed the gang and can now kill the boss. This quest pattern is very straightforward and works well, giving rewards either at every stage or only when the boss is dead.  
      Side stub 
      A side stub is an optional part of the overlapping quest. Lets say quest A leads to quest C but there is an option to complete a side objective B, which makes completing C easier or it changes the reward, for example. The player must escape prison, the side stub is “free the other prisoners” in this example escaping with all the prisoners is voluntary but it might make it easier to overpower the guards or the prisoners might reward the player when he gets them out. The side stub differs from a generic side quest in that it is tied to the main quest directly.  
      Continuous side-quests
      These are side-quests that evolve throughout the game, one unlocks the next, but they are also affected by external requirements such as story progress. This pattern is often found with party members in RPG games, where the player must befriend the party member to unlock their story quests.  
      As the name implies these quests are time sensitive. The task can be of any type, the important thing is that the quest fails if time runs out. This could also be used for a quest with a side quest where the side quest is timed for extra rewards but the main objective is not.  
      Deja-vu quests
      This kind of quest pattern gives the player a quest they have done or seen before. In some cases, this “new” quest will have a twist or something that sets it apart. It can also be the same sort of quest that exists in different areas of the game world, perhaps there is more than one goblin camp? or perhaps the player has to pick berries daily.  
      Delayed impact
      Delayed consequences of a previous decision. Often used in games where the story is important and the players’ choices matter. These quests are tied together without the player knowing. Let's say the player is set the optional task of giving a beggar some gold to feed himself. The player gives the beggar a few gold and is on his way. The next time he meets the beggar the beggar has become rich and rewards the player for his kindness with ten times what he gave.  
      One of many
      The player is presented with a number of quests, they have to choose which one to complete, they can only choose one. The others will not be available.  
      Hidden quests
      Hidden tasks that aren’t obviously quests at first glance or are hidden away for only the most intrepid players to find. This could be an item the player picks up with an inscription in it if the player then finds the person the inscription is about he can get a reward for delivering it. A good quest pattern for puzzles, these kinds of quests can really make the game world come alive and feel a lot more engaging, allowing the player to uncover secrets, Easter eggs and discover all of the world created for them   
      Moral dilemma
      Punish the bread thief who stole to feed his family? often used in games that have a good/ evil alignment level for the players, these kinds of quests make the player make a choice about what kind of character they want to play, they get to choose if their character is good or evil.  
      Side quests
      Optional quests, these quests are often found in level based games where the overall quest must be completed to get to the next level, the player can optionally do some extra tasks to get more points. The important part is that these are optional but they give the player a reward for, getting everything they can out of the game.  
      Tournament style quests, a series of quests that get harder as the player progresses. An example could be a gladiatorial arena if the player defeats five enemies one after the other he gets rewarded as the champion of the arena, but if for example, he fails at the third, the whole tournament is failed and he has to start all over from quest 1.  
      Vehicle missions
      Despite the name these quests are not confined to being about cars, these are simply quests where the players control scheme changes to complete the quest(s). An example could be; changing from running around in the game world to driving a tank to destroy a fort.  
      Quest superstructure - "The whole package"
      With quest superstructures, we are venturing into general game design. The superstructure is how the player is allowed to complete quests in the game world. It's basically a question of whether the game is “open world” or a linear experience.
      The diamond structure 
      The open world model, think games like The Elder Scrolls V: Skyrim, the player is introduced to the game through a quest, but after that, they can go wherever and do whatever quests they want. There are tons of quests of the above types and patterns, the player is free to pick and choose which to do, giving the player the illusion of freedom within the game world (the diamond). However, the game still ends by completing a quest that is locked and always a requirement to complete the game. This can, of course, be varied by different choices the player has made throughout the game or even have multiple endings. Quests can be concentrated into quest hubs, i.e. towns with lots to do or the like, but they don't have to be completed in a linear fashion  
      Linear hub structure
      This structure consists of a number of required “bridge” quests that need to be completed in order to unlock the next area or “hub”, each hub can have any number of quests, this could be a town full of people in trouble, each with their own quests and quest chains to complete, when they are all done, the player moves on to the next hub through another bridge quest. Limiting the quest size of the hubs will make the quest structure feel more linear and thereby the game linear, and creating larger more open hubs can make the player feel freer.  
      Outcome - "So many options!"
      The development of custom quest has been the quest to allow game developers to create quests and missions that use these types. However, no matter how well we have researched, some one will come up with a new and creative way of doing quests.
      The solution for us was to make the system more customizable. Letting users convert their quest prefabs to quest scripts that automatically inherits the core functionality, so the user can freely add their own additional functionality on top of the existing core
      Asset development as fuel - "A learning experience"
      Developing this way, splitting the production into sub systems that can function on their own and even be used by others is not something that should be taken lightly, but if you can build something lasting, something others can find value in using, then the final product will be all the better for it. Custom Quest started as a project we thought could be completed in a couple of months, it ended up taking 7.
      In part this is because we realised that if we were going to release the system, we might as well do it right, that meant creating a system that was customizable and robust, a system that can be added to the users game and not the other way around, a system we could be proud of.
      The experience of developing for other developers is quite different to developing a game. One that has made us much stronger as programmers and as a company, it forced us to think in new ways, in order to create a dynamic and customizable solution. Custom quest has evolved from an asset we could use in Quest Accepted, into a tool others can use to create a unique game experience. All in all, the experience has been a good one and Random Dragon is stronger for it, I would, however, recommend thinking about your plugin and extra time before you start developing.
      Sources: -"We know you aren't stupid" - a quest design master class from CD Projekt RED - Game Design Essentials: 20 RPGs -
      Extra credits - Quest Design I - Why Many MMOs Rely on Repetitive Grind Quests
      Extra credits - Quest Design II - How to Create Interesting MMO and RPG Quests
      Center for Games and Playable Media - Situating Quests: Design Patterns for Quest and Level Design in Role-Playing Games -
      Center for Games and Playable Media - RPG Design patterns
      Special thanks to Allan Schnoor, Kenneth Lodahl and Kristian Wulff for feedback, constructive criticism and background materials.
  • Popular Now