3.3. Obtain the Wireshark sources

There are several ways to obtain the sources from Wireshark’s Git repository.

[Tip]Check out from the master branch using Git.

Using Git is much easier than synchronizing your source tree by hand using any of the snapshot methods mentioned below. Git merges changes into your personal source tree in a very comfortable and quick way. So you can update your source tree several times a day without much effort.

[Note]Keep your sources up to date

The following ways to retrieve the Wireshark sources are sorted in decreasing source timeliness. If you plan to commit changes you’ve made to the sources, it’s a good idea to keep your private source tree as current as possible.

The age mentioned in the following sections indicates the age of the most recent change in that set of the sources.

3.3.1. Git over SSH or HTTPS

Recommended for development purposes.

Age: a few minutes.

You can use a Git client to download the source code from Wireshark’s code review system. Anyone can clone from the anonymous git URL:

  • https://code.wireshark.org/review/wireshark

If you create a Gerrit account you can clone from an authenticated URL:

SSH lets you use Gerrit on the command line. HTTP lets you access the repository in environments that block the Gerrit SSH port (29418). At the time of this writing (early 2014) we recommend that you use the SSH interface. However, this may change as more tools take advantage of Gerrit’s HTTP REST API.

The following example shows how to get up and running on the command line. See Section 4.13, “Git client” for information on installing and configuring graphical Git and Gerrit clients.

  1. Sign in to https://code.wireshark.org/review using OpenID (click Register or Sign In in the upper right corner of the web page). Follow the login instructions.
  2. In the upper right corner of the web page, click on your account name and select Settings.
  3. Under Profile set a username. This will be the username that you use for SSH access. For the steps below we’ll assume that your username is henry.perry.
  4. Select SSH Public Keys and add one or more keys. You will typically upload a key for each computer that you use.
  5. Install git-review. This is an installable package in many Linux distributions. You can also install it as a Python package. (This step isn’t strictly necessary but it makes working with Gerrit much easier.) To install it from Chocolatey run

    # If you have not already, install Python 3 first and then *restart* the shell.
    PS$> choco install -y python3
    PS$> choco install -y git-review -source python
    # Make sure that "git-review" is present in our path (edit the version as needed).
    PS$>$userpath = [Environment]::GetEnvironmentVariable("Path", [EnvironmentVariableTarget]::User)
    PS$>$userpath += ";C:\Python37\Scripts"
    PS$>[Environment]::SetEnvironmentVariable("Path", $userpath, [EnvironmentVariableTarget]::User)
  6. Now on to the command line. First, make sure git works:

    $ git --version
  7. If this is your first time using Git, make sure your username and email address are configured. This is particularly important if you plan on uploading changes.

    $ git config --global user.name "Henry Perry"
    $ git config --global user.email [email protected]
  8. Next, clone the Wireshark repository:

    $ git clone ssh://[email protected]:29418/wireshark

    The clone only has to be done once. This will copy all the sources (including directories) from the server to your machine and check out the latest version. This may take some time depending on the speed of your internet connection.

  9. Then set up the git pre-commit hook and the push address:

    $ cd wireshark
    $ cp tools/pre-commit .git/hooks/
    $ git config --add remote.origin.push HEAD:refs/for/master

    This will run a few basic checks on commit to make sure that the code does not contain trivial errors. It will also warn if it is out of sync with its master copy in the tools/ directory. The change in the push address is necessary: We have an asymmetric process for pulling and pushing because of gerrit.

  10. Initialize git-review.

    $ git review -s

    This prepares your local repository for use with Gerrit, including installing the commit-msg hook script.

3.3.2. Git web interface

Recommended for informational purposes only, as only individual files can be downloaded.

Age: a few minutes (same as anonymous Git access).

The entire source tree of the Git repository is available via a web interface at https://code.wireshark.org/review/gitweb?p=wireshark.git. You can view each revision of a particular file, as well as diffs between different revisions. You can also download individual files but not entire directories.

3.3.3. Buildbot Snapshots

Recommended for development purposes, if direct Git access isn’t possible (e.g. because of a restrictive firewall).

Age: some number of minutes (a bit older than the Git access).

The Buildbot server will automatically start to generate a snapshot of Wireshark’s source tree after a source code change is committed. These snapshots can be found at https://www.wireshark.org/download/automated/src/.

If Git access isn’t possible, e.g. if the connection to the server isn’t possible because of a corporate firewall, the sources can be obtained by downloading the Buildbot snapshots. However, if you are going to maintain your sources in parallel to the "official" sources for some time, it’s recommended to use the anonymous (or authenticated) Git access if possible (believe it, it will save you a lot of time).

3.3.4. Released sources

Recommended for building pristine packages.

Age: from days to weeks.

The official source releases can be found at https://www.wireshark.org/download.html. You should use these sources if you want to build Wireshark on your platform for with minimal or no changes, such Linux distribution packages.

The differences between the released sources and the sources in the Git repository will keep on growing until the next release is made. (At the release time, the released and latest Git repository versions are identical again :-).