Fair Bandwidth Allocation (FBA) in Internet gateways is the problem of how to allocate network capacity between users that share an Internet connection. This Thesis starts with explaining different views of fairness and fair resource allocation and how they are related to existing solutions of FBA. The main part of this Thesis describes the implementation of an agent-based electronic market system for FBA. The advantage of the market approach is that users that do not use their Internet connection are being compensated when letting others use their capacity. A testbed is created where the implemented system is tested by using simulated users that sends real network traffic. The tests show that the market is able to shape the users' network traffic according to their bought capacity and that users that seldom use their Internet connection get higher throughput with the system active compared to ordinary FBA solutions. This behavior is expected and wanted as it reduces the unfair subsidization of very active users.