DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Because the DevOps movement has redefined engineering responsibilities, SREs now have to become stewards of observability strategy.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Related

  • The Battle Of New Industry Standards: Is WebRTC Making Zoom Redundant?
  • Endpoint Security Controls: Designing a Secure Endpoint Architecture, Part 2
  • Building Resilient Networks: Limiting the Risk and Scope of Cyber Attacks
  • Detection and Mitigation of Lateral Movement in Cloud Networks

Trending

  • Apache Spark 4.0: Transforming Big Data Analytics to the Next Level
  • How GitHub Copilot Helps You Write More Secure Code
  • Security by Design: Building Full-Stack Applications With DevSecOps
  • Tired of Spring Overhead? Try Dropwizard for Your Next Java Microservice
  1. DZone
  2. Data Engineering
  3. IoT
  4. Simulate Network Latency, Packet Loss, and Low Bandwidth on Mac OSX

Simulate Network Latency, Packet Loss, and Low Bandwidth on Mac OSX

By 
Joe Miller user avatar
Joe Miller
·
Dec. 15, 12 · Interview
Likes (0)
Comment
Save
Tweet
Share
16.3K Views

Join the DZone community and get the full member experience.

Join For Free

Sometimes while testing you may want to be able to simulate network latency, or packet loss, or low bandwidth. I have done this with Linux and tc/netem as well as with Shunra on Windows, but I had never done it on Mac OSX.

It turns out that Mac OSX includes ‘dummynet’ from FreeBSD which has the capability to do this WAN simulation.

Here is a quick example:

  • Inject 250ms latency and 10% packet loss on connections between my workstation and my development web server (10.0.0.1)
  • Simulate maximum bandwidth of 1Mbps
# Create 2 pipes and assigned traffic to and from our webserver to each:
$ sudo  ipfw add pipe 1 ip from any to 10.0.0.1
$ sudo  ipfw add pipe 2 ip from 10.0.0.1 to any
 
# Configure the pipes we just created:
$ sudo  ipfw pipe 1 config delay 250ms bw 1Mbit/s plr 0.1
$ sudo  ipfw pipe 2 config delay 250ms bw 1Mbit/s plr 0.1

A quick test:

$ ping 10.0.0.1
PING 10.0.0.1 (10.0.0.1): 56 data bytes
64 bytes from 10.0.0.1: icmp_seq=0 ttl=63 time=515.939 ms
64 bytes from 10.0.0.1: icmp_seq=1 ttl=63 time=519.864 ms
64 bytes from 10.0.0.1: icmp_seq=2 ttl=63 time=521.785 ms
Request timeout for icmp_seq 3
64 bytes from 10.0.0.1: icmp_seq=4 ttl=63 time=524.461 ms

Disable:

$sudo  ipfw list |grep pipe
  01900 pipe 1 ip from any to 10.13.1.133 out
  02000 pipe 2 ip from 10.13.1.133 to any in
$ sudo  ipfw delete 01900
$ sudo  ipfw delete 02000
 
# or, flush all ipfw rules, not just our pipes
$ sudo ipfw -q flush

Notice that the round-trip on the ping is ~500ms.  That is because we applied a 250ms latency to both pipes, incoming and outgoing traffic.

Our example was very simple, but you can get quite complex since “pipes” are applied to traffic using standard ipfw firewall rules.  For example, you could specify different latency based on port, host, network, etc.

Packet loss is configured with the “plr” command.  Valid values are 0 – 1.  In our example above we used 0.1 which equals 10% packetloss.

This is a very handy way for developers on Mac’s to test their applications in a variety of network environments.  And you get it for FREE.  On Windows you need to buy a commercial tool to achieve this (at least that was true the last time I looked, in 2008.)


Network Bandwidth (computing)

Published at DZone with permission of Joe Miller, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • The Battle Of New Industry Standards: Is WebRTC Making Zoom Redundant?
  • Endpoint Security Controls: Designing a Secure Endpoint Architecture, Part 2
  • Building Resilient Networks: Limiting the Risk and Scope of Cyber Attacks
  • Detection and Mitigation of Lateral Movement in Cloud Networks

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!