21 Feb 2016 home-networking

I recently decided to relocate the router in my house upstairs where I’m setting up my new home office. This seemed like the simplest way to get a wired connection, and also the least destructive (compared to, say, trying to wire up the house for ethernet).

So now the TV (really, the conduit for Netflix) is further from the router, so I’d expect the signal to be worse, but overall not affect performance. First attempt: Netflix streamed fine. Second attempt: nothing, followed by slow loading, and finally the dreaded standard definition television.

Wireless Channels

First off, in your wireless router’s settings, you can select a Channel for it to broadcast on. These channels correspond to frequencies, and North American routers are supposed to use Channels 1 to 11, which exist within the 2.41 to 2.47 GHz range.

I won’t claim to know too much about wireless signals, channel widths, or any of that. My first hypothesis was “the fewer networks that use the same channel as me, the less conflict there will be.” By now, I think this is mostly correct, but there is some extra magic.

Help me, Google

Googling around, this article (July 2013, so probably still relevant) gives a little overview of the problem, and recommends a Windows utility for seeing what channels are in use from other networks. Trying to find a similar utility for Fedora, I wound up on askubuntu (ironic, but still relevant), and the one that ended up helping me was wicd, specifically wicd-cli.

You can see my comment there with my helpful one-liner,

wicd-cli --wireless --list-networks | awk '{print $3}' | sort -n | uniq -c

This gives counts for how many networks (that my laptop can see) that are running on each channel. The output of that (in the back of my house with my TV) looks like:

1 Channel
5 1
4 6
3 11
3 149

Channels 1, 6, and 11 seem to be pretty heavily used. Why no love for the channels inbetween? If you look back at the “Fun Technical notes” section of the howtogeek article, it explains this.

If you look closely, you’ll notice that each of the channels are 5 MHz away from each other, but the Channel Width for 2.4 GHz is actually 20 MHz. What this means is while that the channel might be set to channel 6, it’s also partially using 5 and 7, and probably slightly interfering with 4 and 8.

So they (and others) recommend using channels 1, 6, and 11 because their frequencies are more than the “channel width” away from eachother. Another 2010 post seems to corroborate this idea.

So, what’s with channel 149? That’s part of the 5 GHz wifi band (that my router does not support). Another howtogeek article (July 2015 this time) gives some more background, and this helpful tidbit:

Keep in mind, 5Ghz is ideal for connecting in smaller, open spaces, and you’ll experience better data transmission rates but once you start to spread out and move away from the Internet access point, your results may begin to diminish.

So if that holds true, and even if my router supported it, it might still not be the best choice considering my house has, you know, walls between the main places we use the wifi.

Putting it to use

Using wicd, I ran around the house and kept track of the channel usage in different rooms. I realized that at the front of the house, there were no channel collisions with my channel, but at the back where the TV is situated, there were multiple collisions! Using wicd-gtk I was able to see the networks sorted by strength, and other networks on the same channel had higher strength, which I assume is what got in the way.

Which Channel to pick?

So in my initial hypothesis, I figured I should just pick an unoccupied channel, but we see the channel width problem can arise which still leads to partial interference.

So, without any science to back me up, I decided to go with channel 3 as an experiment (note: it has yet to be seen if I will actually gather any data to inform my further decisions on this). I figured that I would rather go with more partial interference (from networks on channels 1 and 6) and no “full” interference (from the same channel).

I’ll see how this goes; I just know I was having trouble on channel 11.

Feedback

Let me know on Twitter if I’ve made mistakes in my approach to this problem, or in my solution. I learn more by being wrong, and I’d also love to get great wireless signal in my house :)


20 Aug 2015 vagrant intellij

If you’ve had my experience trying to start with Vagrant, you were intrigued by the pitch:

“If you’re a developer, Vagrant will isolate dependencies and their configuration within a single disposable, consistent environment, without sacrificing any of the tools you’re used to working with (editors, browsers, debuggers, etc.).”

You then finish the tutorials, but feel like they skipped over the part where you develop in the VM. The tutorials go over how to get Apache working with your already-developed application whose code you put in the shared /vagrant directory, but what if you wanted to do your development within the VM?

The Use Cases

  • C++ Development. Most C++ dependencies are distributed via the package manager, so playing with any sufficiently complex C++ code base requires installing a good amount of software directly to your system.
  • Repeatable dev environment. Distribute one dev environment to your whole team.
  • Throwaway dev environment. Want to play around with node for a few days? Make a VM, play around for a bit, then let it go

First try: Java and IntelliJ

Here is the code for my first try at using Vagrant to actually develop with Java inside the Vagrant VM using an IDE (IntelliJ IDEA).

Vagrantfile

The Vagrantfile is mostly straightforward. Starting with the vagrant init chef/centos-7.0, I added X11 forwarding through SSH, extra memory, 4 CPUs, and specified a provisioning script. The extra CPUs are needed, or else you’re in for a very sluggish experience with IntelliJ.

Vagrant.configure(2) do |config|
  # Every Vagrant development environment requires a box. You can search for
  # boxes at https://atlas.hashicorp.com/search.
  config.vm.box = "chef/centos-7.0"

  # ssh properties
  config.ssh.forward_agent = true
  config.ssh.forward_x11 = true

  config.vm.provider "virtualbox" do |vb|
    # These numbers gave great performance on laptop with
    # 16 GB memory
    # quad core i7-4710HQ
    vb.memory = "4096"
    vb.cpus = "4"
  end
  
  # script for provisioning dependencies
  config.vm.provision :shell, path: "bootstrap.sh"
end

bootstrap.sh

You can name this script whatever you’d like as long as its specified in the Vagrantfile. I designed mine to install libraries with yum, and any other software is installed manually (combinations of wget and tar).

The first tricky piece was discovering what X11 libraries needed installing from the bare-bones CentOS 7 image in order to launch IntelliJ. Other IDEs (I’ve tried VSCode) required even more X11 and GTK libraries, especially if you wanted a monospaced font.

sudo yum update

devtools='
vim
git
'
x11_stuff='
xorg-x11-xauth
libXtst
libXrender
'
sudo yum install -y \
    $x11_stuff \
    $devtools

The only other “trick” in this script is that it will move any downloaded files to the /vagrant directory so that if you happen to build this image again, the downloaded files will exist on your host machine to speed up the provisioning.

Running

The README describes how to take the VM for a spin. You’ll have to go through first-time setup of IntelliJ after making the VM, but otherwise this should be a fully-working solution for developing inside your VM with acceptable performance.

# mostly takes time to download and install dev tools
vagrant up

# ssh with X11 forwarding
vagrant ssh -- -Y

# you are now in the VM
git clone <my favorite java project>
idea.sh &> idea.log &

09 Apr 2015 unity

I had looked into making a game in Unity before in version 4.6 when the 2D toolkit was released. Since then, Unity’s UI components were released, and now Unity 5.0 came out. Not too many 5.0 features caught my eye, but I figured now would be a good opportunity to get started on an idea I had.

Starting up Development

The Unity editor is only available on Windows and OSX, so I had to go with my Windows 8.1 machine (sorry Fedora!). I pretty much never develop in Windows, so I had to start from scratch with any tools beyond the Unity editor itself (which ships with MonoDevelop, an IDE for the open-source flavor of C#).

Source Control

I’ve read from a few anecdotal sources that Mercurial works better with version tracking text-serialized binary data than Git. The first time I played with Unity, I used a Mercurial project for that reason, but never got to the point where I could come up with an opinion of it.

However, I ended up deciding on Git for this project for two simple reasons:

  • I already know Git
  • Unity’s Cloud Build supports Git, but not Mercurial

Maybe Cloud Build will eventually support Mercurial, but I figured I’d go with what I know for this project.

SourceTree and Bitbucket

So I had used Atlassian’s SourceTree as my client to play with that Mercurial project in the past, so I figured I’d return to it for the new Git project (which it supports). I also decided to stick with Atlassian’s BitBucket to host the remote repository of my code because it allows unlimited free personal (one-user) repositories.

Unity and Git

This blog post (which the author reposted as an answer to a stackoverflow question gave me a good overview of how to set up Unity’s assets to be better tracked. The article specifically lists two versions within 4.x that the instructions are for, but they ended up working on 5.0.0 as well.

Not sure if this is the proper method for setting up my .gitignore file via SourceTree, but I ended up doing this:

  • Right-Click -> Ignore to one of the files I wanted to ignore.
  • Open up .gitignore in Notepad, and paste in all of the records from that blog post.
  • SourceTree automatically recognized the new ignores.

Then I was able to make a commit to my local repository, then push it up to BitBucket. Windows Git weirdness

After pushing to BitBucket, I looked at the project in my browser, and it recommended adding a README, which I was able to do in the browser. After that, I wanted to pull the change back to my machine, but got a strange error message about my Git client having issues with Cygwin.

Google got me to this stackoverflow answer that said to do some voodoo, and then everything will work. They were correct.