Search This Blog

Showing posts with label OSX. Show all posts
Showing posts with label OSX. Show all posts

Wednesday, 5 August 2015

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

OSX used to contain the binaries to configure ‘dummynet’ from FreeBSD which has the capability to do WAN simulation.

Mavericks no longer has support for dummynet but still has the code in the backend.  Find and copy the IPFW binary from an older machine into /sbin and you're good to go.

Example:

Inject 250ms latency and 10% packet loss on connections between workstation and web server (10.0.0.1) and restrict bandwidth to 1 Mbit/s.

# Create 2 pipes and assigned traffic to/from:
$ 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 with latency & packet loss:
$ 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
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.0.0.1 out
  02000 pipe 2 ip from 10.0.0.1 to any in
$ sudo  ipfw delete 01900
$ sudo  ipfw delete 02000
 
# or, flush all ipfw rules, not just our pipes
$ sudo ipfw -q flush

Round-trip is ~500ms because it applied a 250ms latency to both pipes, incoming and outgoing traffic.

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.

Friday, 10 April 2015

OSX Keyboard Media Keys Stopped Working in iTunes

For me the Chrome Google play extension had stolen the functions.

Chrome | Settings | Extensions & scroll to the bottom of the page | Keyboard Shortcuts

Sunday, 17 August 2014

OSX Proxy [on/off] Script

#!/bin/bash

e=$(networksetup -getwebproxy wi-fi | grep "No")

if [ -n "$e" ]; then
  echo "Turning on proxy"
#  sudo networksetup -setstreamingproxystate wi-fi on
#  sudo networksetup -setsocksfirewallproxystate wi-fi on
  sudo networksetup -setwebproxystate wi-fi on
  sudo networksetup -setsecurewebproxystate wi-fi on
else
  echo "Turning off proxy"
#  sudo networksetup -setstreamingproxystate wi-fi off
#  sudo networksetup -setsocksfirewallproxystate wi-fi off
  sudo networksetup -setwebproxystate wi-fi off
  sudo networksetup -setsecurewebproxystate wi-fi off

fi

Thursday, 19 June 2014

Re-enable the Apple-provided Java SE 6 web plug-in and Web Start features

Use this at your own risk as Apple, and most people distrust JAVA.


Taken from http://support.apple.com/kb/HT5559

  1. Open Terminal, located in the Utilities folder.
  2. Enter this command, then press the Return or Enter key: 
    sudo mkdir -p /Library/Internet\ Plug-Ins/disabled 
  3. Enter this command, then press the Return or Enter key:
    sudo mv /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin /Library/Internet\ Plug-Ins/disabled
  4. Enter this command, then press the Return or Enter key:
    sudo ln -sf /System/Library/Java/Support/Deploy.bundle/Contents/Resources/JavaPlugin2_NPAPI.plugin /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin 
  5. To re-enable Java SE 6 Web Start, enter this command, then press the Return or Enter key:
    sudo ln -sf /System/Library/Frameworks/JavaVM.framework/Commands/javaws /usr/bin/javaws

Additional Information

The following steps will undo the above commands and restore Java 7 in OS X Lion and later.
  1. Disable Java SE 6 Web Start opening:
    • Enter this command, then press the Return or Enter key:
    • sudo ln -sf /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/javaws /usr/bin/javaws
      
    • When prompted, enter your administrator password, then press the Return or Enter key.
  2. Re-enable the Java 7 applet plug-in by downloading and reinstalling the latest version of Oracle Java 7 JRE.

Wednesday, 15 May 2013

Changing an OSX Icon

Your going to copy an image to the clipboard and then past it into the object properties that you want to change.

So how ever you want to get the image into the clipboard, eg using 'preview'.

Then on the object you wish to change the icon for:
  1. Right click | Get Info
  2. Click the Icon image in the top left of the properties box (blue border) and from the filer menu 'paste'



You can use this technique for any object, apps, folders etc ..

Wednesday, 8 August 2012

iTunes/AppStore default apps assigned to another user

The iLife apps which now come with Lion+ are by default 'assigned' to the first iTunes user that logs in to the MAC and updates.

Which is fine if its your personal device but not fine when its a business one and that initial user leaves the company.  Apple provide no method to re-assign apps and the no media mandate means you can't re-install.  Essentially your broken and can't update any of the apps.

Spent a good deal of time on Google and eventually emailed support - who were crap.

Resorted to calling Apple Care and after the first tech tried to send me back to iTunes support.  With some perseverance I got through to a senior tech (who wishes to remain anonymous). He took the details and totally owned the case.

Came back within the hour and said we could switch the registration from user XYZ to ABC.  We registered ABC, which will now become the business iTunes account and had the apps switched over.

At first this failed but a suggestion to delete the apps and then re-install resolved that.

Happy user, and really happy with the way Apple support dealt with this.

Saturday, 14 April 2012

Alfa AWUS036H/RTL8187L on OSX 10.6

The drivers on the Alfa site only support up to OSX 10.5.  I found various blogs, which were all EXACT copies of each other and none of which worked.

Eventually stumbled this article which got me close.

This post will just extend that blog with the things I found.
  1. Download the 10.5 driver from the Alfa download site
  2. Install, ignore the corrupt warning & reboot
  3. Open a terminal and type :
  4. sudo kextutil /System/Library/Extensions/RTL8187l.kext
    Notice: /System/Library/Extensions/RTL8187l.kext has debug properties set.
    /System/Library/Extensions/RTL8187l.kext has problems:
    Authentication Failures:
    File owner/permissions are incorrect (must be root:wheel, nonwritable by group/other):
    /System/Library/Extensions/RTL8187l.kext/Contents/Resources
    /System/Library/Extensions/RTL8187l.kext/Contents/Resources/English.lproj
    /System/Library/Extensions/RTL8187l.kext/Contents/Resources/English.lproj/InfoPlist87l.strings
  5. You now need to :
sudo chmod go-w [The File]
eg : 
sudo chmod go-w /System/Library/Extensions/RTL8187l.kext/Contents/Resources
sudo chmod go-w /System/Library/Extensions/RTL8187l.kext/Contents/Resources/English.lproj
sudo chmod go-w /System/Library/Extensions/RTL8187l.kext/Contents/Resources/English.lproj/InfoPlist87l.strings

Now this is where it goes a little off piste.  Following the reference article you should now just run the Realtech util and off you go.  For me that didn't work and the app wouldn't even run.

I restarted again and ran :
sudo kextutil /System/Library/Extensions/RTL8187l.kext

It reported no file permission errors but at the same time I was both prompted with OSX's "found a new network interface" and the RealTech app launched and allowed me to configure the NIC.

UPDATE 12/11/2012 : These drivers are 32bit.  Apple has removed the ability to do anything in 32bit with the Mountain Lion release.  So far I can't find anyway to get the 8187L working on ML. <sad face>

Friday, 9 March 2012

MAC Keyboard with anything other than OSX

My friend @coringrieves recently posted a picture of his desktop. Which is a Windows PC (he is averse to anything other than Windows) and a wired MAC keyboard. After mocking him furiously I then went and did the same myself.

Still persevering with Ubuntu it has an English (UK, Macintosh)keyboard layout which works great.

Not so the VirtualBox Windows 7 VM I run nor the Win64 alternative OS I sometimes boot into (Never did find a decent/working H.232 Linux video client).

Trawling around it seems the options are mostly based on installing Apples bootcamp.  Which is huge, I'd rather have gone and bought a Mac looky likely kb than install that bloat-ware.

Stumbled across another suggestion of using Microsofts keyboard layout tool to create your own, or in this case someone else kindly did it.

http://www.logikdev.com/2010/02/18/apple-uk-keyboard-layout-for-windows/

Installed, VirtualBox VM and vanilla OS all work fine.