100% found this document useful (3 votes)
29 views

[FREE PDF sample] Building Multiplayer Games in Unity: Using Mirror Networking Dylan Engelbrecht ebooks

Games

Uploaded by

sigalatimic
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (3 votes)
29 views

[FREE PDF sample] Building Multiplayer Games in Unity: Using Mirror Networking Dylan Engelbrecht ebooks

Games

Uploaded by

sigalatimic
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 65

Download Full Version ebook - Visit ebookmeta.

com

Building Multiplayer Games in Unity: Using Mirror


Networking Dylan Engelbrecht

https://ebookmeta.com/product/building-multiplayer-games-in-
unity-using-mirror-networking-dylan-engelbrecht/

OR CLICK HERE

DOWLOAD NOW

Discover More Ebook - Explore Now at ebookmeta.com


Instant digital products (PDF, ePub, MOBI) ready for you
Download now and discover formats that fit your needs...

Start reading on any device today!

Unity Networking Fundamentals: Creating Multiplayer Games


with Unity First Edition Sloan Kelly

https://ebookmeta.com/product/unity-networking-fundamentals-creating-
multiplayer-games-with-unity-first-edition-sloan-kelly/

ebookmeta.com

Introduction to Unity ML-Agents: Understand the Interplay


of Neural Networks and Simulation Space Using the Unity
ML-Agents Package 1st Edition Dylan Engelbrecht
https://ebookmeta.com/product/introduction-to-unity-ml-agents-
understand-the-interplay-of-neural-networks-and-simulation-space-
using-the-unity-ml-agents-package-1st-edition-dylan-engelbrecht/
ebookmeta.com

Introduction to Unity ML-Agents: Understand the Interplay


of Neural Networks and Simulation Space Using the Unity
ML-Agents Package 1st Edition Dylan Engelbrecht
https://ebookmeta.com/product/introduction-to-unity-ml-agents-
understand-the-interplay-of-neural-networks-and-simulation-space-
using-the-unity-ml-agents-package-1st-edition-dylan-engelbrecht-2/
ebookmeta.com

A Study in Stone 1st Edition Michael Campling

https://ebookmeta.com/product/a-study-in-stone-1st-edition-michael-
campling/

ebookmeta.com
Learning at Speed 1st Edition Nelson Sivalingam

https://ebookmeta.com/product/learning-at-speed-1st-edition-nelson-
sivalingam/

ebookmeta.com

His Curvy Bride Nichole Rose

https://ebookmeta.com/product/his-curvy-bride-nichole-rose/

ebookmeta.com

International Human Rights Law. Theory and Practice 1st


Edition Mazzeschi

https://ebookmeta.com/product/international-human-rights-law-theory-
and-practice-1st-edition-mazzeschi/

ebookmeta.com

Lenkov The Bad Boys 1st Edition Shyla Colt Kyra Nyx

https://ebookmeta.com/product/lenkov-the-bad-boys-1st-edition-shyla-
colt-kyra-nyx/

ebookmeta.com

Hot Mess Wedding An Accidental Wedding Curvy Girl Romance


1st Edition Kat Baxter

https://ebookmeta.com/product/hot-mess-wedding-an-accidental-wedding-
curvy-girl-romance-1st-edition-kat-baxter-2/

ebookmeta.com
The Laboratory Rat Laboratory Animal Pocket Reference 2nd
Edition Sharp Patrick Villano Jason S

https://ebookmeta.com/product/the-laboratory-rat-laboratory-animal-
pocket-reference-2nd-edition-sharp-patrick-villano-jason-s/

ebookmeta.com
Building
Multiplayer
Games in Unity
Using Mirror Networking

Dylan Engelbrecht
Building Multiplayer
Games in Unity
Using Mirror Networking

Dylan Engelbrecht
Building Multiplayer Games in Unity: Using Mirror Networking
Dylan Engelbrecht
Johannesburg, South Africa

ISBN-13 (pbk): 978-1-4842-7473-6 ISBN-13 (electronic): 978-1-4842-7474-3


https://doi.org/10.1007/978-1-4842-7474-3

Copyright © 2022 by Dylan Engelbrecht


This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the
material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation,
broadcasting, reproduction on microfilms or in any other physical way, and transmission or information
storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now
known or hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with
every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an
editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the
trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not
identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to
proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication,
neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or
omissions that may be made. The publisher makes no warranty, express or implied, with respect to the
material contained herein.
Managing Director, Apress Media LLC: Welmoed Spahr
Acquisitions Editor: Spandana Chatterjee
Development Editor: Laura Berendson
Coordinating Editor: Shrikant Vishwakarma
Cover designed by eStudioCalamar
Cover image designed by Pexels
Distributed to the book trade worldwide by Springer Science+Business Media LLC, 1 New York Plaza, Suite
4600, New York, NY 10004. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-sbm.
com, or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole member (owner)
is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware
corporation.
For information on translations, please e-mail [email protected]; for reprint, paperback,
or audio rights, please e-mail [email protected], or visit http://www.apress.com/
rights-permissions.
Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook versions and
licenses are also available for most titles. For more information, reference our Print and eBook Bulk Sales
web page at http://www.apress.com/bulk-sales.
Any source code or other supplementary material referenced by the author in this book is available to
readers on GitHub via the book’s product page, located at www.apress.com/978-­1-­4842-­7473-­6. For more
detailed information, please visit http://www.apress.com/source-­code.
Printed on acid-free paper
“The pursuit of mastery is an endless journey,
but those who persevere etch their names in history.”
—Riot Games
Table of Contents
About the Author����������������������������������������������������������������������������������������������������� xi

About the Technical Reviewer������������������������������������������������������������������������������� xiii

Chapter 1: A Brief Introduction��������������������������������������������������������������������������������� 1


Why Multiplayer?�������������������������������������������������������������������������������������������������������������������������� 2
Benefits of Multiplayer������������������������������������������������������������������������������������������������������������ 2
Caveats of Multiplayer������������������������������������������������������������������������������������������������������������� 3
The Options of Multiplayer in Unity����������������������������������������������������������������������������������������������� 4
Why Mirror?���������������������������������������������������������������������������������������������������������������������������������� 5
Prerequisites and Resources�������������������������������������������������������������������������������������������������������� 5
Summary�������������������������������������������������������������������������������������������������������������������������������������� 6

Chapter 2: The Messenger Pigeon, Packets, and a Trip Around the World��������������� 7
Introduction to Networking����������������������������������������������������������������������������������������������������������� 7
A Brief History of Networking�������������������������������������������������������������������������������������������������� 8
Understanding Packets����������������������������������������������������������������������������������������������������������������� 9
A Look at TCP Packets����������������������������������������������������������������������������������������������������������� 10
A Look at UDP packets���������������������������������������������������������������������������������������������������������� 12
How Packets of Data Get Transported Around the World������������������������������������������������������������ 13
TCP/IP Model������������������������������������������������������������������������������������������������������������������������� 13
IPv4 – Internet Protocol Version 4����������������������������������������������������������������������������������������� 15
ARP – Address Resolution Protocol��������������������������������������������������������������������������������������� 18
DNS – Domain Name System������������������������������������������������������������������������������������������������ 19
How a Headshot Travels Around the World���������������������������������������������������������������������������� 20
The Importance of Keeping Your Packets Small�������������������������������������������������������������������� 23
Network Topologies��������������������������������������������������������������������������������������������������������������� 27
Gateways������������������������������������������������������������������������������������������������������������������������������� 35

v
Table of Contents

DHCP – Dynamic Host Configuration Protocol����������������������������������������������������������������������� 36


NAT – Native Address Translation������������������������������������������������������������������������������������������ 40
Port Forwarding��������������������������������������������������������������������������������������������������������������������� 42
Ports�������������������������������������������������������������������������������������������������������������������������������������� 43
Security��������������������������������������������������������������������������������������������������������������������������������������� 47
The Firewall��������������������������������������������������������������������������������������������������������������������������� 47
Kinds of Attacks and How to Mitigate Them�������������������������������������������������������������������������� 48
Networking Diagnostic���������������������������������������������������������������������������������������������������������������� 52
Tools of the Trade������������������������������������������������������������������������������������������������������������������ 52
Summary������������������������������������������������������������������������������������������������������������������������������������ 58
Exercises������������������������������������������������������������������������������������������������������������������������������������� 59

Chapter 3: A Hall of Mirrors������������������������������������������������������������������������������������ 67


Architecture�������������������������������������������������������������������������������������������������������������������������������� 67
Transport Layers������������������������������������������������������������������������������������������������������������������������� 68
Comparing Transport Layers�������������������������������������������������������������������������������������������������� 69
Additional Transport Component Logic���������������������������������������������������������������������������������� 71
Layers of Choice�������������������������������������������������������������������������������������������������������������������� 75
The Client, the Server, and the Host�������������������������������������������������������������������������������������������� 77
The Client������������������������������������������������������������������������������������������������������������������������������ 78
The Server����������������������������������������������������������������������������������������������������������������������������� 78
The Host�������������������������������������������������������������������������������������������������������������������������������� 79
The Network Manager���������������������������������������������������������������������������������������������������������������� 80
Configuration������������������������������������������������������������������������������������������������������������������������� 82
Scene Management��������������������������������������������������������������������������������������������������������������� 83
Network Info�������������������������������������������������������������������������������������������������������������������������� 83
Authentication – Network Authenticator������������������������������������������������������������������������������� 84
Player Object������������������������������������������������������������������������������������������������������������������������� 93
Registered Spawnable Prefabs��������������������������������������������������������������������������������������������� 94
Network Identities����������������������������������������������������������������������������������������������������������������������� 94
Summary������������������������������������������������������������������������������������������������������������������������������������ 95

vi
Table of Contents

Chapter 4: The Chain of Command������������������������������������������������������������������������� 99


Authority������������������������������������������������������������������������������������������������������������������������������������� 99
Game Server Architecture��������������������������������������������������������������������������������������������������������� 100
Input vs. State-Based Architecture�������������������������������������������������������������������������������������� 101
Deterministic vs. Indeterministic Architecture�������������������������������������������������������������������� 103
Peer-to-Peer������������������������������������������������������������������������������������������������������������������������ 104
Lockstep������������������������������������������������������������������������������������������������������������������������������ 108
Client-Server Architecture��������������������������������������������������������������������������������������������������� 108
Understanding the Chain of Command������������������������������������������������������������������������������������� 111
Remote Procedure Calls������������������������������������������������������������������������������������������������������ 113
Commands�������������������������������������������������������������������������������������������������������������������������� 115
Synchronization – Properties���������������������������������������������������������������������������������������������� 117
Synchronization – Components������������������������������������������������������������������������������������������� 127
Network Messages�������������������������������������������������������������������������������������������������������������� 133
Client-Side Prediction���������������������������������������������������������������������������������������������������������� 136
Spawning���������������������������������������������������������������������������������������������������������������������������������� 137
Registering Prefabs During Runtime����������������������������������������������������������������������������������� 140
Mirror’s Order of Events������������������������������������������������������������������������������������������������������������ 140
Interest Management���������������������������������������������������������������������������������������������������������������� 141
A Note About Hosts�������������������������������������������������������������������������������������������������������������� 145
Creating Our First Multiplayer Game����������������������������������������������������������������������������������������� 145
What If I Get Stuck?������������������������������������������������������������������������������������������������������������� 146

Chapter 5: The Memory of a Goldfish������������������������������������������������������������������� 147


What Is Data Persistence, and Why Is It Important?����������������������������������������������������������������� 147
Data Persistence Using Player Prefs����������������������������������������������������������������������������������� 147
Data Persistence for Large-Scale Multiplayer Games��������������������������������������������������������� 149
What Are Database Engines?���������������������������������������������������������������������������������������������������� 150
Relational vs. Non-relational Databases����������������������������������������������������������������������������� 150
Using DynamoDB���������������������������������������������������������������������������������������������������������������������� 154
Installing the AWS DotNet API���������������������������������������������������������������������������������������������� 155
Configuring AWS DotNet API������������������������������������������������������������������������������������������������ 155

vii
Table of Contents

Connecting to the Database from Your Game Server���������������������������������������������������������� 157


Designing the Database������������������������������������������������������������������������������������������������������ 158
Storing Information�������������������������������������������������������������������������������������������������������������� 161
Retrieving Information��������������������������������������������������������������������������������������������������������� 165
Updating Information����������������������������������������������������������������������������������������������������������� 167
Serving Content to Your Players������������������������������������������������������������������������������������������������ 169
Some Closing Notes for AWS API���������������������������������������������������������������������������������������������� 169

Chapter 6: Scaling Up, A Lot��������������������������������������������������������������������������������� 171


Viral Game Studies�������������������������������������������������������������������������������������������������������������������� 172
How Among Us Became a Part of Us����������������������������������������������������������������������������������� 172
“Halo Meets Portal”������������������������������������������������������������������������������������������������������������� 174
Hosting Servers������������������������������������������������������������������������������������������������������������������������� 175
Shared/Virtual Hosting�������������������������������������������������������������������������������������������������������� 176
Dedicated Hosting/Bare-Metal�������������������������������������������������������������������������������������������� 177
So, What Is the Best Option for Hosting Then?�������������������������������������������������������������������� 178
Using Cloud Services to Host Your Game Servers��������������������������������������������������������������������� 179
AWS – Amazon Web Services���������������������������������������������������������������������������������������������� 180
Google Cloud����������������������������������������������������������������������������������������������������������������������� 187
Azure����������������������������������������������������������������������������������������������������������������������������������� 190
Unity Multiplay��������������������������������������������������������������������������������������������������������������������� 193
Stress Testing, Stress Clients, and Market Research���������������������������������������������������������������� 194

Chapter 7: Insights from the Masters������������������������������������������������������������������� 195


Michael “vis2k” W. – Mirror Networking����������������������������������������������������������������������������������� 195
Tell Me a Bit About Yourself and Where You Come From����������������������������������������������������� 195
What Are Some of the Biggest Networking-Related Challenges That You and
Your Team, or Clients, Have Faced While Shipping Multiplayer Games?����������������������������� 197
How Did You Overcome These Challenges?������������������������������������������������������������������������� 197
What Would You Say Is Important?�������������������������������������������������������������������������������������� 198
How Much Value Per Player in USD Is a Good Target?��������������������������������������������������������� 198
What Is Your Preferred Cloud Infrastructure Provider for Server Hosting?�������������������������� 198

viii
Table of Contents

What Is the Most Crucial Piece of Advice You Could Give to Someone
Learning Multiplayer Game Development?������������������������������������������������������������������������� 198
Do You Have Any Other Advice That You’d Like to Include for My Readers?������������������������ 199
Do You Want to Thank Anyone?������������������������������������������������������������������������������������������� 199
Curt – Senior Solutions Architect���������������������������������������������������������������������������������������������� 199
Tell Me a Bit About Yourself and Where You Come From����������������������������������������������������� 199
What Are Some of the Biggest Networking-Related Challenges That You and
Your Team, or Clients, Have Faced While Shipping Multiplayer Games?����������������������������� 200
How Did You Overcome These Challenges?������������������������������������������������������������������������� 201
What Would You Say Is Important?�������������������������������������������������������������������������������������� 201
What Is More Important in Multiplayer-Level Design? Balance or Map Fun Factor?����������� 201
How Much Value Per Player in USD Is a Good Target?��������������������������������������������������������� 201
How Much Should You Be Spending on Cloud Infrastructure as a Percentage of
Your Budget?����������������������������������������������������������������������������������������������������������������������� 202
What Is Your Preferred Cloud Infrastructure Provider for Databases?��������������������������������� 202
What Is Your Preferred Cloud Infrastructure Provider for Server Hosting?�������������������������� 202
What Is the Most Crucial Piece of Advice You Could Give to Someone Learning
Multiplayer Game Development?���������������������������������������������������������������������������������������� 202

Chapter 8: Challenge What You Know������������������������������������������������������������������� 203


Beginner Challenges – Core Multiplayer Functionality������������������������������������������������������������� 203
Challenge #1 – Multiplayer 2D Table Tennis������������������������������������������������������������������������ 204
Challenge #2 – Top-Down Shooter Prototype���������������������������������������������������������������������� 208
Intermediate Challenges – User Data Persistence�������������������������������������������������������������������� 212
Challenge #3 – Chat Room App with a User Message History�������������������������������������������� 212
Advanced Challenges – World Persistence������������������������������������������������������������������������������� 215
Challenge #4 – Farming Mechanics with World Persistence���������������������������������������������� 216
Challenge #5 – Box-Hoarder����������������������������������������������������������������������������������������������� 221

Chapter 9: Where To Now? Conclusion����������������������������������������������������������������� 229


A Special Thank You������������������������������������������������������������������������������������������������������������������ 229

Index��������������������������������������������������������������������������������������������������������������������� 231

ix
About the Author
Dylan Engelbrecht is a Unity specialist. Born and raised
in South Africa, he has worked at the top enterprise VR
development studio in the country, and he’s currently
working at the largest game development studio on the
continent. He has in-depth knowledge of commercial and
enterprise game development, with work showcased by
invite at Comic Con Africa and rAge Expo. He is an avid
gamer who enjoys immersive experiences and real-time
strategy games.

xi
About the Technical Reviewer
Deepak Jadhav is a game developer based in Bonn,
Germany. He received his bachelor’s in Computer
Technology and master’s in Game Programming and Project
Management. Deepak has been involved in developing
games on multiple platforms such as mobiles, console,
and PC. He has a strong background in C# and C++ as well
as years of experience in using Unity, Unreal Engine for
Game Development, Augmented Reality, Mixed Reality, and
Virtual Reality.

xiii
CHAPTER 1

A Brief Introduction
Content is king, but a king is nothing without the people. The same applies to games. You
could create all of the world’s content and walk your new land like a king – but it would
still feel like it’s missing something. Humans are social creatures, craving interaction and
shared experiences. We’re fascinated by new ways of experiencing, and linear, single-
player experiences are great, but they can feel empty and soulless if not done perfectly.
Welcome to Building Multiplayer Games in Unity Using Mirror Networking, where
I’ll take you on a deep dive into multiplayer with Unity3D. We’ll use Mirror Networking
to bring your players together, creating the ultimate shared experience. Learn the
fundamentals of RPC/Command multiplayer architecture, and dig deeper into
networking and data persistence to achieve scalable, highly performant, large-scale
multiplayer.
You’ll learn to develop multiplayer games using Unity within a commercial or
enterprise environment. We’ll take a look behind the scenes at what makes multiplayer
games tick. Explore how you can utilize different authoritative structures to best suit
your needs. We’ll also look into scaling your architecture and explore industry-leading
methods of deploying your game to the masses.
You’ll form a solid understanding of valuable networking principles and boost your
game development career. Finally, we’ll wrap up with some advice from leading experts
who’ve deployed the games that you love and play. These experts will shed light on past
mistakes and provide valuable advice for your next project.

1
© Dylan Engelbrecht 2022
D. Engelbrecht, Building Multiplayer Games in Unity, https://doi.org/10.1007/978-1-4842-7474-3_1
Chapter 1 A Brief Introduction

Why Multiplayer?
Multiplayer, used right, can add a certain depth to a game that we cannot achieve
otherwise. I’m not implying that you should make every game multiplayer. Certain
games do indeed feel better as a single-player experience if done right. So, it’s essential
to look at what your product has to offer, its downfalls, and what multiplayer can give or
take from the player experience.

Benefits of Multiplayer
Let’s explore some of the benefits of multiplayer:

• It adds a new dimension to how players interact with your


product - Multiplayer allows players to interact with the experience
you’ve designed and with each other. Creating a whole new
dimension for how players interact with your product has the
potential to be extremely rewarding.

• Multiplayer games boost social interaction, resulting in improved


user retention - Humans are social creatures of habit. We thrive on
interacting with other people. For some, this can be more challenging
due to social anxiety. However, games have a unique way of breaking
down this barrier, allowing your players to form meaningful
friendships. Those friendships in themselves add new reasons for
your players to keep coming back, resulting in improved player
retention.

• Multiplayer begets competition and cooperation - Competition is


a fundamental trait amplified through games. Healthy competition
can encourage more extended use of your product by your players,
resulting in more monetization opportunities. At the same time,
depending on game design, multiplayer brings cooperation where
players should work as a team and which helps engaging players in a
creative way.

2
Chapter 1 A Brief Introduction

• More effective analytics and player behavioral data - Games as


a service allow us more flexibility in collecting player behavioral
data and analytics that we can use to improve our product. This
behavioral data becomes exponentially more powerful in enterprise
environments, where you have more consent to user data.

• Community engagement - Multiplayer games are a great source


of content for streamers and content creators. This influencer-
driven marketing will prove invaluable in driving your community
engagement and offering new forms of monetization.

Caveats of Multiplayer
Multiplayer offers many benefits, but it does have some caveats that you should be aware
of when deciding to build or convert your existing product into a multiplayer game:

• Not all games make for an excellent multiplayer experience -


Some games are just better as a single-player experience. If done
incorrectly, multiplayer can take more away from a game than it can
give, which is especially prevalent in very story-driven games, where
the narrative revolves around the player.

• Multiplayer service life expectancy - If you’re providing your


product as a service, you’ll need to host the dedicated servers
yourself. Product as a service brings up a caveat of multiplayer games
that rely on the developer to host the game, and that’s the multiplayer
service life expectancy. Most multiplayer games that developers host
will not run indefinitely. Eventually, developers will shut the servers
down. Mitigate service life expectancy by evolving your product to
keep pace with the market or finally giving your players the ability to
host private servers.

• Competition begets toxicity - The same competition that


encourages more use of your product can also decay into toxicity if
left unchecked. This decay could result in users leaving or negative
publicity. So how do we mitigate this risk? Let’s look at the next point.

3
Chapter 1 A Brief Introduction

• Moderation of user-interactive spaces - To prevent your


community’s decay, you’ll need to look into moderation options to
ensure that your community isn’t creating a negative experience for
new users.

The Options of Multiplayer in Unity


There are several options available to us when creating multiplayer games with Unity.
Each of these options has various pros, cons, and outright limitations. So it’s critical to
evaluate your game’s needs and decide what you’re willing to sacrifice. Let’s have a look
at Figure 1-1 to compare a few of the top networking solutions.

Figure 1-1. A comparison chart with various Unity networking solutions and
frameworks

Note Single-game CCU (Concurrent Users on the same game server at the same
time) is highly dependent on your game’s architecture and coding.

So, why not develop a multiplayer game in Unity using Unity’s built-in HLAPI? Well,
that’s what you’d expect. Unity has a networking framework, called UNet, and a big part
of UNet is the HLAPI or High-Level Application Programming Interface. However, the
Unity HLAPI is deprecated, and you really should avoid it for any new projects. It also
has several limitations, preventing it from being a good, scalable solution. Unity has
promised us a new networking framework. Unity released the initial public version of
their new multiplayer framework, called MLAPI, in March 2021. Many of the concepts
you’ll learn in this book will also apply to the MLAPI, as they’re all loosely based around
the same source code and architecture.

4
Chapter 1 A Brief Introduction

W
 hy Mirror?
So, if there are so many networking options available, then why choose Mirror? Well,
Mirror has built-in support for switching out the transport layer, which removes a lot of
the limitations in other networking solutions, namely, how many concurrent players
we can get into a single instance. Mirror is also free and relatively easy to use and
implement, with a massive supportive community that will gladly assist you with any
problems or questions.

P
 rerequisites and Resources
To follow along with this book, you’ll need the following tools, source code, and
knowledge.

PREREQUISITES AND RESOURCES

• Be experienced in C#, there will be a lot of coding involved, and C# experience


is required if you’d like to follow along with this book.

• Proficient in Unity, you should have a solid understanding of Unity and its design
patterns.

• Unity3D, in this book I’ll be using Unity 2020.3 LTS which you can download
from Unity Hub.

• Mirror, the networking framework that we’ll be using throughout this book. You
can get the latest build from the Unity Asset Store.

• KCP, which you can download from the mirror website, https://mirror-
networking.com/transports/.

• An IDE, such as Visual Studio. My preferred IDE is JetBrains Rider.

• Wireshark, which you can download and install from www.wireshark.org/


download.html.

5
Chapter 1 A Brief Introduction

• Optionally, an AWS free tier account, which you can sign up for at
https://aws.amazon.com/free/.

Did you know? Mirror was created to replace a deprecated UNet and was
originally released October 2018.

S
 ummary
In this chapter, we explored what multiplayer can offer your game or product, as well
as the caveats that come with multiplayer game development. We explored what our
options are when developing a multiplayer game and got a brief introduction to who I
am and what you’ll be learning in this book.
In the next chapter, we’ll tackle the foundational elements of networking, to
understand exactly how data travels around the world.

6
CHAPTER 2

The Messenger Pigeon,


Packets, and a Trip
Around the World
Before we begin creating multiplayer games using one of the many provided APIs, it’s
crucial to understand how computers communicate with each other. Understanding
how computers communicate will allow us to improve network performance and weed
out pesky bugs. In this chapter, we’ll be touching on the history of computer networking
and discussing the fundamental principles that enable computers to communicate.

I ntroduction to Networking
A network in computer terminology, by definition, is a group of computers or devices
that communicate using a shared communication protocol. The two primary protocols
that we’ll be discussing for game development are TCP and UDP. These two standard
protocols are what allow devices to communicate with one another in a common
language.

7
© Dylan Engelbrecht 2022
D. Engelbrecht, Building Multiplayer Games in Unity, https://doi.org/10.1007/978-1-4842-7474-3_2
Chapter 2 The Messenger Pigeon, Packets, and a Trip Around the World

A Brief History of Networking


It’s crucial to understand the importance of standardized protocols in computer
networking. Before the Open Systems Interconnection Model, or OSI model, was created
in 1978 by French computer scientist Hubert Zimmerman, computer networking was
largely unstandardized. The lack of standardization meant that computer networking,
in large part, was limited to massive government-funded contracts or limited to ­vendor-­
specific standards. Essentially, computers all spoke different languages to one another,
without a common tongue. The world needed a set standard to follow, a universal
language.
The first significant attempt at this standardization, or common tongue, was
conceived. The OSI model was a massive industry undertaking, attempting to persuade
industry participants to agree on common networking standards to allow for multi-­
vendor interoperability. The seven-layer OSI model provided a conceptual framework
for engineers to build around, allowing devices to communicate easily with one another,
regardless of vendor, internal structure, or technology.
Now, the OSI model itself is obsolete for the most part, as it never gained the
popularity that it needed to achieve its goal. However, it did highlight the dire need for a
standardized approach to networking. It’s worth noting that despite the OSI model not
gaining the popularity that it needed, we still use the OSI model today for reference and
teaching.
During roughly the same period, two scientists developed another set of protocols
that would become what OSI should have been. These two scientists, Vinton Gray “Vint”
Cerf and Robert Kahn, would later be known as “The fathers of the Internet.” Robert
Kahn was hired in 1972 by Lawrence Roberts, the program manager of the Information
Processing Techniques Office (IPTO), a Defense Advanced Research Projects Agency
(DARPA) branch of the US Department of Defense. While working at IPTO, Robert
Kahn started a project to establish a ground-based radio packet network. He faced
similar challenges that the industry was facing. He realized a need to develop an open
architecture model that would allow networks to communicate, regardless of hardware
and software configuration. Robert Kahn set forth to create such a model and proposed
four critical goals for designing the model. This model would later become known as the
Transmission Control Protocol (TCP). Interestingly, early versions of the technology had
the same abbreviation as its modern counterpart but stood for Transmission Control
Program.

8
Chapter 2 The Messenger Pigeon, Packets, and a Trip Around the World

The four initial goals for TCP were as follows:

• Intercommunication - Any network should communicate with


another network, regardless of hardware or software configuration,
through a gateway.

• Robust - No internal changes would have to be made to a network to


connect to another network.

• Distributed - The protocol should allow for a distributed network


with no central network administration or control.

• Error handling and recovery - The protocol should be able to detect


lost packets and retransmit them.

In 1973, Vinton Gray joined Robert Kahn on the project, where the two would work
together on TCP. Later, in May 1974, Vinton and Robert wrote a paper, published by the
Institute of Electrical and Electronics Engineers (IEEE), describing their internetworking
protocol for sharing resources using packet switching among network nodes. Later, this
work resulted in the Internet Protocol (IP) Suite.
And in March 1982, the US Department of Defense declared TCP/IP as the standard
for all military computer networking. Later, in 1985, the Internet Architecture Board
(IAB) held a three-day workshop on TCP/IP for the computer industry, promoting the
protocol and its eventual commercial use, finally achieving the OSI model’s original goal.
While Vinton and Robert were cementing their technology in the industry, another
notable scientist appeared in the early 1980s, a computer scientist named David Patrick
Reed. David developed a protocol called the User Datagram Protocol (UDP). UDP is an
alternative transport layer protocol designed with simplicity in mind. Created on top of
the Internet Protocol Suite, it provides incredible speed while transmitting packets over
the network, albeit sacrificing TCP’s error correction and handling and reliability.

Understanding Packets
Now that we know why TCP and UDP were created, let’s dive into the how. A packet is
a formatted unit of data, generally a part of a larger message. We can break this packet
down further into control information and a payload. The control information defines
the packet’s information, for example, where it needs to go, where it came from, and
perhaps even the packet’s order. The payload is typically the user data.

9
Chapter 2 The Messenger Pigeon, Packets, and a Trip Around the World

Typically, in a multiplayer game, if we have a player named Lucy and a player named
John, they will be sharing packets of data among one another to keep the state of the
game synced. If Lucy moves five units north, she’ll send a data packet with a payload
representing that movement. John then receives the packet and interprets the payload.
He can then see that Lucy moved five units North and update his visual representation of
Lucy to move five units North.
In many cases, the various multiplayer tools and APIs available for Unity will allow
you to share that information between Lucy and John without ever seeing the packet
directly, so it almost becomes easy to forget that they exist, especially for newcomers
to multiplayer. However, that’s no reason to downplay the importance of packets.
Understanding how packets are structured and how your data affects packets is vital to
create scalable, smooth, multiplayer experiences.
Typically, when creating a multiplayer game, you’ll be using either TCP or UDP
or a combination of both. TCP and UDP each have their strengths and weaknesses,
determining where you use them based on your project’s individual needs.

Figure 2-1. The figure is comparing the core differences between TCP and UDP

A Look at TCP Packets


Let’s take a look at Figure 2-1. Here, we can see that TCP is a reliable protocol that allows
us to transmit ordered data from A to B securely. What exactly does that mean? Well, a
TCP connection involves each party confirming or acknowledging the receipt of a data
packet. Let’s look at Lucy and John for another analogy and create an extreme situation
to visualize data flow.

10
Chapter 2 The Messenger Pigeon, Packets, and a Trip Around the World

We’ll use Figure 2-2 for reference, which represents how a TCP packet looks.

Figure 2-2. This figure breaks down the structure of a TCP packet

Firstly, notice how there is an optional section that allows for up to 40 bytes of
data? The additional options are why the header can be between 20 and 60 bytes long.
Secondly, see how the destination only includes a port number and no IP address?
That’s because TCP doesn’t know or care about IP addresses. It is solely responsible for
transmitting application-level data from application to application reliably. It’s the job
of the Internet Protocol to send the packet between devices. Let’s put ourselves in the
shoes of TCP for the sake of our analogy; we don’t know anything about IP addresses or
how the data gets from Lucy to John. We only care that Lucy and John speak the same
language. They’re both using TCP to communicate.
Firstly, Lucy will need to greet John. TCP is a connection-oriented, byte stream
service with reliability. Connection-oriented means that two applications using TCP
must first establish a connection before exchanging data. Once Lucy has greeted John,
she can now start speaking to him. So, she puts together a packet of data for John. The
origin is her mouth, and the destination is John’s ears. The sequence then determines
the order of the message, preventing John from hearing “Goodbye” before “Hello!”
Next, Lucy smiles while talking to indicate intent. The miscellaneous data within a
packet contains various little pieces of information about the packet. These small pieces
of information are called flags and provide information about the packet, such as intent.
Lucy then indicates how much she’s willing to stay and listen to John’s response. The
window part of the TCP packet represents the size of the receive window, which specifies
the number of bytes that this segment’s sender is willing to receive at any point in time.

11
Chapter 2 The Messenger Pigeon, Packets, and a Trip Around the World

Lucy then puts together a checksum, a data piece that will allow John to know that he
heard Lucy correctly. The 16-bit checksum field of the TCP packet gets used for error-­
checking the TCP header, the payload, and an IP pseudo-header. The IP pseudo-header
allows John to know that the message is for him.
If Lucy decides that her message is urgent, she can set the URG flag in the header’s
miscellaneous data section. Once the packet is marked as urgent, she’ll be able to
provide a 16-bit offset, indicating where the last urgent data byte was. Lucy decides that
her greeting is not urgent and leaves out the urgent pointer.
Next, there are several options for Lucy to use, but she decides not to use any as
those go outside the scope of this explanation. Finally, Lucy pads the rest of her headers
with 0s until her header ends, and data begins on a 32-bit boundary.
Finally, Lucy adds data to her TCP packet, “Hello! How are you?” John hears Lucy's
message and can understand it.

A Look at UDP packets


Next up, we have UDP packets. The User Datagram Protocol is connectionless, which
may seem confusing at first. But, we should remember that UDP is not responsible
for the actual transmission of the packet. UDP is simply a protocol for us to transmit
data through the Internet protocol. However, unlike TCP, it doesn’t care about who the
recipient is. Unlike TCP, UDP does not require a connection to the destination.
Let’s take a look at the anatomy of a UDP packet (Figure 2-3).

Figure 2-3. The figure showcases a UDP packet

The first thing we notice about UDP packets is that they’re tiny compared to TCP
packets. UDP packet headers are a measly 8 bytes. Compare this to the potentially
60 bytes of header data in a TCP packet in a worst-case scenario. Now, you might be
thinking that 60 bytes still seems small. What about my 200Mbps fiber connection at
home? Sure, a single 60-byte packet will go unnoticed by your Internet connection, but
we need to think in terms of scale.

12
Chapter 2 The Messenger Pigeon, Packets, and a Trip Around the World

What if you’re dealing with 60 packets a second? Okay, so we’re up to 3.6KB/s, big
deal, right? Game server with 100 connected players? 360KB/s. Well, even that doesn’t
sound so bad, right? Well, that’s 360KB/s on headers alone. The exact amount of packets
over UDP would be 48KB/s in comparison. That’s a massive 87% improvement. Keep this
in mind for later when we discuss the importance of keeping your packets small. When
we work with multiplayer code, it’s vital to put yourself into a scalability mindset.
Let’s use a similar analogy to what we used with TCP to see the difference between
TCP and UDP. This time, Lucy is giving a presentation in front of hundreds of guests at a
major event. The source is once again her mouth, with the destination being everyone’s
ears. However, this time, Lucy is giving a presentation; she doesn’t know who the
guests are. Instead, she’s able to broadcast to anyone who can hear her in the room.
She shares her presentation, and John, who is one of the guests, hears her presentation.
Lucy doesn’t care or even know that John is there or if he can listen to her presentation.
This fast-paced transfer of data is ideal in situations where you need to relay a lot of
information while having many listeners. Sure, John might have missed a word here and
there, but he hears enough of the presentation to make sense of it.

 ow Packets of Data Get Transported Around


H
the World
So, we understand that packets are a storage container for data transported through
the transport layer, but we haven’t spoken much about how we send the data across the
world. So in this section, I’ll be going into more detail on how networks communicate.
We’ll discuss how that packet of yours will travel from your game server to your game
clients.

TCP/IP Model
I briefly introduced the OSI model and how it attempted to standardize networking.
Now, let’s have an in-depth look at the TCP/IP Model. TCP/IP is an extensive suite of
protocols named after its two most important members. It, much like the OSI model, is a
conceptual framework. However, unlike the OSI model’s seven layers, the TCP/IP Model
has only five layers.

13
Chapter 2 The Messenger Pigeon, Packets, and a Trip Around the World

Let’s take a look at Figure 2-4.

Figure 2-4. A diagram illustrating the five-layer TCP/IP Model and its various
protocols for data transmission over the network

The TCP/IP Model splits into five different layers. These five layers are the following:

• The application layer - This layer is responsible for creating and


interpreting data. In multiplayer games, this will be the actual
game or game server’s job. The game and game server fall within
the application layer. Data within the application layer could be a
variable called “playerHealth” as an example. The protocol data unit
of the application layer is simply known as data. The application layer
includes HTTP protocols outside of game development, which your
web browser uses to display websites. Its purpose is to be used by
applications running on devices.

• The transport layer - This layer is responsible for converting our


data into either TCP or UDP segments, depending on the transport
layer that we’re using. Transport layer packets are known as segments
within the TCP/IP Model. These “segments” are the protocol data
unit of the transport layer. These transport layer packets, or segments,
are what we covered when looking at TCP and UDP packets. The
main protocols used by the transport layer are TCP and UDP.

• The network layer - This layer is responsible for the segment-packet


conversion. The network layer is where our segments (transport layer
packets) are converted into packets and sent to our network adapter.
Packets are the protocol data unit within the network layer. The most
used protocols within the network layer are IPv4 and the Address
Resolution Protocol (ARP).

14
Chapter 2 The Messenger Pigeon, Packets, and a Trip Around the World

• The data-link layer - This is where our packets get converted from
packets to frames. Frames are essentially just another type of data
container, forming the protocol data unit of the data-link layer.

• The physical layer - This layer is responsible for using frames and
transmitting them as bits over the network, between devices. Bits
are the protocol data unit of the physical layer. The most important
layers to understand in game development are the application and
transport layers. However, it is crucial to understand the other layers,
too, as this will help significantly with debugging.

IPv4 – Internet Protocol Version 4


IPv4 is the fourth version of the Internet Protocol. It’s a network layer protocol
responsible for internetworking, the practice of interconnecting multiple computer
networks. It’s one of the main protocols that essentially enables the Internet. IPv4 uses
logical addressing and routing to allow the delivery of packets across the living room or
past the ocean. IPv4 was originally deployed for production between 1982 and 1983, yet
it is still responsible for routing the large majority of Internet traffic today.
The protocol itself isn’t perfect, however. When it was originally created, no one
could ever anticipate what it would become. IPv4 is the protocol that started the Internet.
Originally, the Internet was simply a playground for academics; no one could have
anticipated the global reach and adoption. As such, when IPv4 was created, there was no
expected need for a large addressing space, so a 32-bit addressing system was created.
The reason behind a 32-bit addressing space, instead of, say, a 256-bit addressing
space, is that the larger the addressing space, the larger the need for the IP header. In
the early days of computing, bandwidth was exceptionally valuable; besides, a 32-bit
addressing space would allow for nearly 4.3 billion addresses or devices connected to the
Internet. That’s enough, right? Well, as it turns out, the Internet exploded in popularity
and so did the global population. This has led to what’s known as IPv4 exhaustion. We’ll
cover this in more detail during the “NAT – Network Address Translation” section of this
chapter.

15
Chapter 2 The Messenger Pigeon, Packets, and a Trip Around the World

IPv4 itself is a connectionless protocol and does not guarantee the reliable delivery
of packets. Unreliability means that packets might never arrive at their destination
or packets may arrive in the incorrect order or even arrive duplicated. These errors,
including data integrity, are handled by the upper layer – the transport layer. Like TCP
and UDP packets, or “segments” as the correct terminology in their respective layer, IP
also has packets. These packets encapsulate their upper layer neighbor’s segments for
use in the network layer.
Much like TCP and UDP segments, IPv4 packets contain a header and its respective
payload. In this case, the payload is a TCP or UDP segment.
The IPv4 packet itself is 24 bytes.
Let’s take a look at how an IP packet looks like in Figure 2-5.

Figure 2-5. The anatomy of an IPv4 packet, with a header size of 24 bytes

Now, unlike the TCP and UDP segments, IPv4 packets don’t care about the payload
contents. The purpose of IPv4 packets is to get the segment from the transport layer, then
convert it into a packet for the network layer.
This IP packet has a few notable fields. The most important ones to be aware of are
the following:

• Source IP address - The origin of the IP packet, which is the sender’s


IP address.

• Destination IP address - This is the destination IP address of the


packet.

• Total length - The total length of the packet, with the minimum size
being 20 bytes and the maximum size being 65,535 bytes. If the data
is larger than 65,535 bytes, then the packet needs to be fragmented
into multiple packets. The sender or a router generally does this. The
receiving device does the reassembly of fragmented packets.
16
Chapter 2 The Messenger Pigeon, Packets, and a Trip Around the World

• Identification - This field allows for identifying groups of fragmented


IP packets.

• Protocol - Defines the transport layer protocol within the payload. It


is typically TCP or UDP; however, several other protocols exist.

• Version - The version of the IP packet; in IP version 4, this value is


always 4.

IPv4 relies on IPv4 addressing. Let’s discuss this in some more detail.

Addressing
In order for IP packets to know where they came from, and where they’re going, each
device connected to the network requires a unique IPv4 address. This IPv4 address is a
32-bit integer value, most often represented in dot-decimal notation. This dot-decimal
structure consists of four octets of the address, expressed individually in decimal
numbers separated by a dot or period.
These binary octets look something like this:

10010011.10011101.11010101.01110100

However, because they’re represented individually in decimal numbers, those binary


octets look more like the following to the user:

147.157.213.116

The preceding number is a typical representation of an IPv4 address. Since each


piece of an IPv4 address is represented by an 8-bit octet, our minimum decimal value is
0, and the maximum value is 255.
This gives us roughly 4.3 billion unique IP addresses to identify devices on the global
network or the Internet.
However, there are more than 4.3 billion devices that need to be connected to the
Internet. So that’s a problem. We’ll cover how computer scientists created a workaround
to this problem while the world very slowly transitions to IPv6, in the “NAT – Network
Address Translation” section of this chapter.

17
Chapter 2 The Messenger Pigeon, Packets, and a Trip Around the World

ARP – Address Resolution Protocol


The Address Resolution Protocol is a communication protocol that allows for the
discovery of data-link layer addresses, typically that of network layer addresses such
as Ipv4. These addresses are generally in the form of MAC (Media Access Control)
addresses. In IPv6, the neighbor discovery protocol (NDP) is used instead of ARP. ARP
works on a request response structure, and ARP messages only communicate within
their network boundaries. We’ll discuss how ARP fits into the flow of data a little later on
in the book, but for now, let’s take a look at how ARP works (Figure 2-6).

Figure 2-6. We will use the example network in the figure to explain the Address
Resolution Protocol

Let’s say you’re on a device with the IP address of 192.168.1.10, and you need to
send your player health to a player on the same network as you, with the IP address
of 192.168.1.20. You know their IP address, but you don’t know their MAC address,
meaning your Ethernet card doesn’t have a destination to send the data. In this case,
your device will put together an ARP request with your IP address, your MAC address,
and the IP address of the recipient whose MAC address you need to find. The Ethernet
card will then send this ARP request out to the network.

18
Chapter 2 The Messenger Pigeon, Packets, and a Trip Around the World

The ARP request then arrives at your router. Your router then adds the IP address
of your machine to its own ARP table. It then checks to see if its ARP table contains an
entry for 192.168.1.20. In this example, we’ll say that the router doesn’t yet have an ARP
table entry for 192.168.1.20. It duplicates the ARP request and rebroadcasts it out of each
network port, an action known as “flooding.”
Device 192.168.1.30 receives the ARP request and sees that the request is for a
different device, adding the router to its ARP table and ignoring the request. Finally,
192.168.1.20 receives the ARP request. It adds the router to its ARP table and adds
192.168.1.10 to its ARP table. It then compiles an ARP response. Looking at its own ARP
table, it can determine that the destination MAC address is cc:cc:cc:cc:cc:cc. The ARP
response then travels to the router. The router receives the ARP response and passes it
on to 192.168.1.10 while adding 192.168.1.20 to its own ARP table so future requests are
easier to handle.

DNS – Domain Name System


So, what happens if you don’t know the IP address of the destination or you want to
migrate your game server to a new host, with a new IP address, without needing to
deploy an update to your clients? That’s where the domain name system comes in.
At its core, it’s the system that allows you to type in “www.google.com” into your web
browser and get to 172.217.170.78. The domain name system is essentially a glorified
directory, with human-readable addresses that your device can cross-reference to get
the corresponding IP address. It’s worth noting that DNS uses multiple servers and is a
decentralized service.
Another vital thing to note about DNS servers is that different users worldwide can
receive different responses for the same DNS entries. If you were to type “ping
www.google.com” into your command prompt, you’d likely receive a different IP address
to the one previously mentioned. This ability for DNS to provide proximal responses
gets employed by major Internet services, such as Google. This proximal response could
allow you to configure a game server in America and Europe – tied to the same DNS
address. However, there are other alternatives for game servers in an actual deployed
environment, which we will discuss later in this book.
DNS Databases typically store the following information:

• SOA - Start of authority

• A or AAAA - IP addresses

19
Discovering Diverse Content Through
Random Scribd Documents
Part I.

BUTTERFLIES.

PIERIS CHEIRANTHI.
Plate I.—Fig. 2.
This is a large creamy-white butterfly peculiar to the Canary Islands.
It is found in some numbers on and near the coast of Teneriffe from
April to September; the time of its appearance, however, varies
somewhat in different years. The larva is smooth, and has a ground-
colour of grey, finely dotted over with black spots. There is a yellow
stripe on the back and along each side. It feeds on the nasturtium
gregariously, and the pupa attaches itself, head downwards, to a
wall near the plant.
The female butterfly, the underside of which is illustrated, has a long
uneven blotch of black on the surface of the fore-wings; the male
has none. The upper surface of both sexes is cream-white, with a
black apical patch on the fore-wings. The under-sides have the long
black blotch as seen on the surface of the female, and the ground-
colour of both is yellow, finely sprinkled with black dots. The
measurement across the wings varies from two and a half to three
and a half inches.
It is best to procure the larvæ to obtain good specimens, but the
Ichneumon fly is such an enemy to this species that great
disappointment will probably be experienced in the rearing if the
caterpillars are not well examined before being placed in the
breeding-cages.
PIERIS WOLLASTONI.
Plate I.—Fig. 1.
This butterfly is allied to the Cheiranthi, but is a distinct variety, only
recently met with in this island. Mr. Butler, of the British Museum,
has named and fully described this insect, which has hitherto only
been found in Madeira, but is now for the first time enumerated in
the list of Teneriffe Lepidoptera. It is somewhat smaller than the
Cheiranthi, measuring not more than two and a half inches in
expanse. The reverses of the female (which is illustrated) and of the
male are of a grey tinge, in place of the rather bright yellow shade
of the Cheiranthi, sprinkled over with fine black dots. The apical
patch is also grey, and both sexes have long black spots on the fore-
wings. The upper surface is cream-white; the female has two
distinctly marked long black spots on the fore-wings; the male
having none. The black apical markings are similar in both sexes,
and a small black spot is seen on the inner margin of the hind-wing
of both male and female.
There are no observations to record on the caterpillar and pupa, as
the specimens of the fly (one of which is illustrated) were netted;
but very possibly larvæ may be found gregariously with the
Cheiranthi in like manner to the Callirrhoe and Atalanta, or the
Plexippus and Chrysippus.
The specimens taken were netted about 500 feet above the sea.

PIERIS RAPÆ.
The common English variety, Small Cabbage White. The fore-wings
are creamy white, with an irregular blackish mark at the tip. The
male generally has a black spot in the middle of the wing, the
female having two; and both sexes have two black spots on the
underside, which is of a yellowish colour, thickly dotted with small
black atoms. All the markings vary greatly, however. The larva is dull
green, with a yellowish stripe on its back and yellow dots on the
side. It generally feeds on the cabbage, but is found also on the
nasturtium. It is very common, and may be found everywhere from
February to October. The Ichneumon fly is a great enemy to this
insect.

PIERIS DAPLIDICE.
This butterfly resembles the rare English specimen Bath White. It is
very common in some years,[2] and found in most localities from
February to October. It seems mostly to frequent rough poorly-
cultivated fields. The wings are white, the fore-wings having a large
black spot in the middle, and being bordered with black encircling
distinct white spots. The markings of the under-side show through
on the hind-wings, and these have black markings on the edges in
the female. The underside has a ground colour of sage-green, freely
spotted with white. The markings show considerable variety, some
being marked much more heavily than others. It measures across
the wings from two to two and a half inches. The caterpillar, which is
greyish green, has yellow stripes on the back, and feeds generally
on cabbage. The butterflies are much pursued and destroyed by
dragon-flies.

[2] During the winter of 1892-1893 it was met with in great


numbers.

EUCHLOË CHARLONIA (Donzil).


Plate I.—Fig. 4.
This butterfly was seen near Orotava, 500 feet above the sea-level,
during the first week in May by the author, who, however, was not
fortunate enough to secure a specimen. Several specimens of this
species, which is rare in the Canary Islands, have been netted in the
island of Fuerteventura, and two of them have been presented by
Mr. E. H. Hodges, of Rugby, to the British Museum, from which the
illustration has been drawn. It measures in expanse about an inch
and a half. The general colour is yellow, varying in intensity of shade
in different specimens, with black apical markings on the fore wings
and a long black patch on the centre of the upper margin. A full
account of this interesting insect is to be found in Ann. Soc. Ent. Fr.,
1842, p. 197, f. 1, but hitherto it has not been recognized in
Teneriffe as a species belonging to the island. It is found in North
and West Africa.

APORIA CRATÆGI.
This specimen is the rare English Black-veined White butterfly. It has
undoubtedly been netted in Teneriffe, though it has not been
personally observed by the author. In flight its similarity to other
white specimens is so great that it may often be passed unnoticed.
It is said to be local and uncertain in appearance, being seen chiefly
during the summer months about the fields and gardens. The wings
are entirely of a white cream colour, and are alike on both sides, the
veins being black, and the fore-wings having some dusky spots on
them. The caterpillar is black, thickly sprinkled with whitish hairs,
and with a reddish yellow stripe running along each side. It feeds on
various fruit trees, and is believed to be very destructive.

RHODOCERA CLEOBULE.
Plate I.—Fig. 3.
This finely-coloured and beautiful butterfly resembles the English
Brimstone, but is quite a distinct variety, being of squarer form and
having no decided point at the angle of the hind-wings. It is peculiar
to the Islands. The male is a most brilliant sulphur yellow, the fore-
wings being of a deeper shade than the hind ones. The hind-wings
have a deep orange spot about the centre. The female differs from
the male in being of a much paler shade of yellow, with quite a tinge
of green all over it; it also has a small orange spot on the fore-wings
in addition to that on the hind-wings. Both wings have red markings
round them on the outer edge, which form an almost interrupted
fine line of colour. The underside resembles the upper, but is paler.
The antennæ are short and thick, with a reddish tinge, which
becomes deeper at the knob.
It is found from January to June in most localities on and at a little
distance from the coast; gardens and fields seem somewhat
favoured, but it is by no means common anywhere. There seem to
be several broods between the months mentioned above, but the
larva and pupa have not been observed.

COLIAS EDUSA.
Plate I.—Fig. 5 (female).
This specimen is the English Clouded Yellow. The wings measure
from two to two and a half inches across, the female being
somewhat larger than the male. Both sexes have the same broad
black margin on the fore and hind-wings, but the male differs from
the female in having no irregular yellow spots marked on these black
borders, which are seen in the female. The hind-wings of the female
are of a somewhat darker shade of yellow, tinged with green, than
those of the male, and both sexes have a bright orange spot about
the middle of the wing. Beneath, both sexes are alike, the fore-wings
being of a lighter orange with several irregular black spots and a
margin of greenish yellow. The hind-wings are of a uniform green
colour with a red ringed spot about the centre of each, accompanied
by a silver-like dot in the middle. It is found in quantities in most
localities, from the coast to the pine forests, from February to
November. The caterpillar is green, with a stripe of yellow and white,
having several orange dots on it. It is a miscellaneous feeder,
preferring, however, leguminous plants.

COLIAS v. HELICE.
Plate I.—Fig. 6.
A pale yellowish-white variety of the former specimen. It is very rare,
and is found in May and during the summer months, though very
seldom met with in England.[3] It is slightly smaller than the Colias
Edusa, and has been found so small as to measure only an inch
across the wings. Don Ramon Gomez has one in his collection of this
size. The markings vary considerably, and the bright orange spot in
the centre of the hind-wing, as seen in the illustration, is replaced
occasionally by a pure white one. The male has hitherto not been
found.

[3]In the summer of 1892 many were taken.

LYCÆNA BÆTICA.
A commonly found blue butterfly, measuring from one to one and a
half inches across the wings. It is rarely met with in England. The
insect has a slender tail at the lower angle of each hind-wing,
surmounted by two black dots. The margins of both wings have a
slight black or dark brown band. The under-sides of both wings are
of a grey-brown colour streaked and slightly spotted all over with
faint white lines. On the lower angle of each hind-wing the two black
spots on the upper side are replaced by two black ones dusted with
silver, and surrounded by a bright orange ring which is broader at
the top than at the bottom.
The antennæ are brown, slightly sprinkled with white. It is found on
the rough fields (especially where the Lupine grows), barrancos, and
hedge-rows, between March and August. Specimens netted early in
the year are not so large as those found during May, and in the
summer months.

LYCÆNA WEBSIANA.
Plate I.—Figs. 7 and 8.
This is a smaller blue butterfly than that just described, measuring
about one inch across the wings. It is peculiar to the Islands, and is
known by some lovers of Entomology as the “Peak Blue.” It is not,
however, found on the Peak alone, but is netted in barrancos and
gardens at a much lower altitude; it frequents the pine forests in
large numbers, and has been also found on the south coast of the
Island of Teneriffe, at Guimar (see Appendix B), so it may be fairly
considered to be widely dispersed over the Island. It is undoubtedly
found in the greatest numbers in the elevated zone of the pine
forests, where, however, owing to the extremely slippery nature of
the ground, it is difficult to net. The male is of a beautiful metallic
blue colour; the female of a much browner blue. The upperside of
the male, and the underside of the female, are shown in the
illustrations.
The fore-wings of the underside in both sexes are alike, being of an
orange tawny colour, with a white uneven spot on the top margin of
each wing, and five or six somewhat indistinct brown spots at the
outer edge, interspersed with white.
The hind-wings are of an ashy brown, with a longitudinal, irregular
silver white line down each, both wings being minutely dotted with
white. Five or six brown spots, dusted with silver, are seen at the
margin of the hind-wings. It usually appears in March, though it has
been seen at an earlier date. The larva and pupa have not hitherto
been found.

LYCÆNA LYSIMON.
This is the smallest specimen of blue butterfly found in Teneriffe,
being not quite one inch in expanse. The female is rather a browner
blue than the male. The colouring on the upperside is of a most
beautiful uniform blue, all the wings having a margin of brown; and
a slight white fringe at the edges. The underside of all the wings is
grey, rather freely dotted over with darker spots, encircled by greyish
white. It is very commonly found on all grassy fields and lanes, and
quantities flutter quickly along the grass-grown streets of Orotava
from April to August.
It is not an inhabitant of England, but is found in the south of
France, Spain, greater part of Africa, Western Asia, and the East
Indies. The caterpillar and chrysalis have not been observed.

LYCÆNA ASTRARCHE v. ÆSTIVA.


Plate II.—Fig. 6.
A small dark copper, the expanse of wings being about one inch, or
rather more. It is not found in England. On the upperside on all the
wings there is a marginal band of bright copper, the fore-wings have
a black spot about the centre of each. A fringe of white edges all the
four wings. The under widely differs from the upper side in colouring
and markings. The ground colour is light grey, freely dotted over
with black spots encircled by white. All four wings have the same
bright marginal copper band as seen on the upper side. The
antennæ are black or dark brown, finely dotted with white. It is
somewhat rarely found in fields and barrancos on high ground, but
may be met with in larger quantities in the pine forests. The time of
its appearance is from April to September. When comparing the
Teneriffe specimen of this butterfly with those of other countries at
South Kensington, it was noticed that the marginal copper band was
broader on the Teneriffe specimen, and it may be possible that it
should be reckoned as a new variety.

POLYOMMATUS or CHRYSOPHANUS PHLÆAS.


A copper butterfly, and a common English specimen, measuring from
one to one and a half inches across the wings. The fore-wings are of
a bright copper red, with large square black spots distinctly marked,
and an outer band of brown. The hind-wings are dark brown, having
a marginal copper band on the outer edge, which in some
specimens is surmounted by a few blue spots. The underside of the
fore-wings is pale copper, the hind-wings being grey, with minute
black or dark brown spots, and traces of a marginal band of copper.
It is commonly found from February to September in most places in
Teneriffe, up to the altitude of the pine forests. The larva feeds on a
variety of Rumex (dock or sorrel). Some specimens have been found
much darker in colour than those described above, the difference
being so great as to suggest the possibility of a distinct variety.

THECLA RUBI.
This small butterfly is called in England the Green Hair Streak, It is
said to have been netted in the Island during the summer months,
and its appearance is believed to be well authenticated. The larva is
green, with a yellow line on the back, bordered with darker, and
followed by a line of pale triangular spots, and a yellow line on the
sides: it lives on brambles, &c. The fly expands about one inch; it is
of a uniform brown colour above, and a uniform green below, with a
row of white dots on the underside of the hind-wings.

DANAIS PLEXIPPUS, formerly ARCHIPPUS.


Plate II.—Fig. 1.
The largest butterfly found in the Islands, measuring from four to
four and a half inches across the wings.
The larva is very bright in colour, having transverse bands of blackish
violet, gold, and white alternately. It has four black horns or fleshy
spikes along its back, and when full grown measures about two
inches in length, and it is rather stout and smooth. The pupa, green
when first turned, and suspending itself by the tail only, has a bright
gold band half-way round its base, and a series of gold spots
encircling its head. Shortly before emerging to a butterfly, it turns to
a dark brown. The caterpillar never suspends itself to the plant on
which it feeds, but goes to some of the higher grasses near it, or it
prefers still better a mallow plant, from the leaves of which as many
as sixteen beautiful bright green and gold chrysalides have been
seen hanging, forming quite a picture under the illumination of the
glorious sun of Teneriffe. It lives and feeds gregariously on the
“Arbol de Seda,” [4] a plant bearing a very bright red and gold flower.
Many specimens were reared from quite small caterpillars in the
breeding-cages. They were easy to keep, but especial care must be
taken in providing them with fresh food, and great attention ought
to be paid to ventilation, or some disappointment may be
experienced in the number that die during the pupa state for no
apparent reason. A little of the morning sun is beneficial to them, as
they are found, when in a natural state, in the most sunny localities.

[4] Asclepias cuvassavica.

A brood seems to emerge about every three months in most years


from February to September. The butterfly frequents flower-gardens
and fields near the coast, not often being found more than seven or
eight hundred feet above the sea. It is of a rich orange tawny colour,
rather heavily veined with black or dark brown. All four wings have a
broad black border, with two lines of whitish yellow dots along the
margin. There is a large apical patch of blackish brown on each fore-
wing, with seven large yellow and white spots on the tip. There is
not a great difference between the upper and the under side, except
that on the latter the white marginal spots are larger, and there is
more white on the black-feathered body.
The insect looks splendidly bright and flashing as it soars along with
a steady flight from tree to tree on the “Carretera,” and it must be
quickly netted, or it soon rises out of reach. These butterflies are
distasteful to birds, as also are the three following varieties
belonging to the same family. For this reason the family of Danais is
“mimicked” by butterflies of other species, the butterfly next
described (Danais Chrysippus) being, for instance, copied closely by
several African and Indian species of butterflies and even some
moths.
The Danais Plexippus is a very common butterfly in North America,
and has within the last few years become widely dispersed, some
specimens having been found in England in 1877 and subsequently.

DANAIS CHRYSIPPUS.
Plate II.—Fig. 2.
This butterfly is widely dispersed over Europe, Asia, and Africa, but it
is not found in England. It is of the same colour as the last described
specimen, but is not so large, measuring in expanse from two and a
half to three and a half inches. The tips of the fore-wings are broadly
marked with black, shading off to brown, crossed with a band of
white spots. Four of these spots are of a quadrilateral form, and
much larger than the rest. The outer margins of all four wings are
bordered with black, freely dotted with white. There are three black
spots on the centre of the hind-wings of the female; the male has
four, the fourth, which is largest, being placed under the principal
vein. The under is similar in markings and colouring to the upper
side, but the white spots are more pronounced, and the tawny
yellow somewhat paler; the apex of each fore-wing is moreover
tipped with yellow, instead of being black like the upperside. The
larva is very similar to that of the Plexippus. It is somewhat smaller,
however, has six fleshy horns instead of four, and the transverse
gold and black stripes are interspersed with white spots instead of
stripes. It feeds gregariously with the above variety on the “Arbol de
Seda,” and appears at the same time, in the same locality, and in
equal numbers. When it changes to the pupa state it resembles
closely the bright green chrysalis of its companion, only it is not
quite so large.

DANAIS ALCIPPOIDES.
Plate II.—Fig. 3.
This butterfly, a variety of the Chrysippus, is rare in Teneriffe. It is
found commonly in Africa and Western Asia, and is a transition
variety between the Chrysippus and Alcippus. It has whitish hind-
wings, rather silvery looking, with orange markings within the black
border. The hind-wings have less white upon them than those of the
Alcippus. It is similar in all respects and habits, mode of feeding,
etc., to the Chrysippus, and is found gregariously with it. When kept
collectively, about one in fifty of the chrysalides proves to be of this
variety. The caterpillars of the three varieties of Danais described are
about four weeks before turning to chrysalides, and remain in that
state from two to three weeks before emerging to the imago.

DANAIS DORIPPUS v. KLUGII.


This is the fourth variety of the genus Danais, and is authentically
claimed as one of the Teneriffe butterflies, though by no means
commonly found. It varies from the Chrysippus in having no brown
apical patch on the fore-wings, and it also has no band of white
spots across them. It measures from two and a half to three and a
half inches across the wings. It is not an inhabitant of England, but
is commonly found in North Africa and Western Asia.

ARGYNNIS MAIA (Cram), or PANDORA.


Plate III.—Figs. 1 and 2.
This butterfly is one of the most beautiful Fritillarys, and is also one
of the largest of Teneriffe butterflies, measuring in expanse from
three and a half to four inches.
It mostly frequents woods and meadows, not often being met with
below an altitude of fifteen hundred feet above the sea. It is found
in South Europe, and is also met with in Africa. The time of its
appearance commences in May, and continues during the summer
months. The larva is purplish-brown with black markings; it feeds on
heartsease. The upper and under side differ greatly, as may be seen
in the illustrations. The prevailing colour of the upper surface is a
beautiful bronze green, tinged with yellow on the fore-wings. The
bronze green colour is freely marked all over by velvety black oblong
spots, dashes, and lines, the margin of each wing having a
continuous scalloped line of black. The body and hind-wings are very
feathered and downy. The underside of the fore-wings is a brilliant
pink-red and black colour, with an apical patch of green, having
yellow markings. The hind-wings are green with a long irregular
stripe of silver down the centre of each, the stripe being fringed on
the outer edge by five silver dots. There is a marginal silver band
with a fine yellow line running along the outer edge of the hind-
wings. The body is green on the upper, and buff-yellow on the
under-side, the legs being of the latter colour. There is not much
difference between the male and female.

ARGYNNIS LATHONIA.
Plate III.—Figs. 3 and 4.
This exquisite butterfly, which is about two inches in expanse, is
known in England, where it is accounted a great rarity, by the
common name Queen of Spain Fritillary, and it is not very commonly
found in Teneriffe. The caterpillar is a greyish brown with a white
dorsal line, spotted with black, and having two brownish lines on the
sides. The spines are reddish and the legs yellow. It feeds on the
heartsease, violet, etc. The upper surface is a tawny orange colour
with many distinct rounded black spots. On the under-side the hind-
wings are brownish yellow with very large oval silver spots
interspersed with smaller ones. The fore-wings have black spots of
various sizes, and five or six apical silver spots. The butterfly is
found mostly on high ground in barrancos; but also in fields and
gardens from the months of March to September, though in some
years it appears earlier. It flits quickly along the paths in the
barrancos, settling at short distances, very often just out of reach of
the net, and this liveliness often necessitates a long walk after a
specimen. The antennæ are furnished with a round thick nob at the
end. There is no very marked difference in the male and female.

PYRAMEIS ATALANTA.
Plate III.—Fig. 7.
This richly-coloured butterfly, known in England as the Red Admiral,
is very rare in the Canary Islands. The ground-colour of the upper
surface of the fore-wings is a velvety black, shading off to brown at
the base. A bright red oblique band crosses the wings, and four
large oblong white spots, with four or five smaller ones, are grouped
on the apex. These again are bordered by several faint blue spots,
quite at the tip. The hind-wings are blackish brown, with a broad red
margin, in which are four black dots, and some blue spots are
marked on the lower angle of the wings. On the underside the fore-
wings are black, with several steely blue lines, the red band across
the centre being clearly defined. The apex of the wings is brownish
yellow, marked with white. The hind-wings are most beautifully
variegated with steely blue, black, and buff. The antennæ are long
and slender, abruptly forming a knot at the end, which is tipped with
white. The larva is dusky green in colour, with a yellow line running
down its back and sides; it is sparingly coloured with short stubby
hairs, and is found gregariously on the nettle-leaf. Gold spots are
freely sprinkled over the brown chrysalis. The caterpillar stage lasts
five or six weeks, the butterfly appearing in another three or four.
The larva suspends itself by the tail, often wrapping itself in a nettle-
leaf, on which it feeds. If the pupa is gathered from the nettles for
breeding, it should be fastened in the cage in the same position,
head downwards. Disappointment is often experienced in the
number of butterflies that emerge from the chrysalis state, so many
being attacked by ants, &c.
The caterpillars are found gregariously with the Callirhoe, which is
the commonest species of Pyrameis found in the Islands. Among
many reared, three only proved to be Atalanta butterflies. It is found
in Teneriffe from January to June.

PYRAMEIS CALLIRHOE, or VULCANIA.


Plate III.—Fig. 6.
This is the most common butterfly of the Pyrameis genus found in
the Islands. It is similar in colouring to the last described, but it has
a much broader red oblique indented stripe on the fore-wings. The
white apical markings are not so many or large, and it has no blue
spots on the tips of the fore-wings.
The habits and locality of the caterpillar and chrysalis are so like
those of the Atalanta, that description is not needed.
In rearing many specimens, two butterflies proved to have bright
yellow on the hind-wings in place of the red band. Whether they are
a distinct variety or not, cannot at present be positively stated.[5]

[5]See Appendix C.

PYRAMEIS CARDUI.
Plate II.—Fig. 5.
This insect, which is the English Painted Lady, might at first sight be
taken for a faded Atalanta. The caterpillar lives generally solitary on
hollyhock, nettle, or mallow, curling itself up in a leaf It is of a grey-
brown colour, thickly sprinkled with hairs, a yellow line fringed by
reddish dots runs along each side. It is found in most localities up to
a considerable elevation, from February till well on into the summer.
The butterfly is of a tawny red colour, shading off to brown at the
base of the fore-wings, with dark markings and oblong black spots.
The apex of the wings is marked and edged in white, similar to the
Atalanta. The hind-wings are of the same tawny red colour, having a
line of five round black spots running along each lower margin. The
fore-wings are marked on the under-side as above, the colour,
however, being redder. The hind-wings are pale buff, olive brown,
and white, having four or five blue-black eyes near the lower
margin, the two centre eyes being smaller than the others, which
are circled by black and white. Its flight is very swift, and its erratic
and rapid gyrations from side to side make it a difficult specimen to
net.

PYRAMEIS v. HUNTERA.
Plate II.—Fig. 4.
This is a scarce variety in Teneriffe of the butterfly just described. It
is commonly found in America, and some few insects have been
taken in England. It is similar in colouring to the Cardui, but
somewhat brighter. The flight of the insect is steadier, and this,
together with the brightness in colour, distinguishes it from others of
the same family when seen flying in company. It is found in
barrancos and gardens, and has been netted in a locality about 600
feet above the sea near Orotava, together with the last two
butterflies described. All three specimens were seen flitting in
company, the Callirhoe and Cardui predominating in number, with a
few specimens of the Huntera dispersed among them. The upper
surface is brick-red, marked with black, the fore-wings having a dark
apical patch, with several white spots. The hind-wings have five blue
spots, encircled by black, near the lower margin. Beneath, the fore-
wings are of a most beautiful red colour, interspersed with black,
grey-brown, and white, and having two eyes on the apex. The hind-
wings are of a lovely grey-brown tinge, liberally veined with white,
having a whitish uneven band down the centre. This band has two
large eyes, with blue centres outside it. On the edge of the wings
three grey-blue lines are seen, making the tout ensemble a most
exquisite reverse, and the greatest contrast to the upper surface. It
is usually found from April to August. Though faded and small
specimens were found earlier, the beauty of the insect is not seen till
April. The caterpillar is brown, sparingly covered with hairs, and has
bright red spots down its sides. It is rather larger than the Cardui
larva.

PARARGE XIPHIOIDES.
Plate III.—Fig. 5.
This is not an English butterfly, though it is somewhat similar to the
Speckled Wood Argus (Parage Ægeria). It is very commonly found in
the Islands in most localities up to three or four thousand feet above
the sea. It measures in expanse from two and a half to three inches.
Those found early in the year are of a smaller and duller colour than
those netted later on. It is of a rich brown colour, the fore-wings
being freely marked with orange-yellow spots. The hind-wings are
plentifully feathered at the base, and have a long dash of yellow
down them, with three dark eyes near the margin, which is scalloped
with faint white. The under-side of the fore-wings is lighter in colour
than the surface, though similar in markings. The hind-wings are of
a uniform olive-brown shade, with a long uneven silvery stripe half-
way down the centre. There is no very decided knob on the end of
the antennæ, which only thicken slightly towards the end.

EPINEPHELE HISPULLA, or FORTUNATA


(Alph.).
This brown butterfly resembles the English Large Meadow Brown (E.
Janira), but is of a richer colour and larger size, measuring in
expanse about two and a half to three inches. The female, which
differs largely from the male in colour and markings, is of an ashy-
brown colour, the fore-wings being orange-tawny, leaving only an
uneven marginal band of grey-brown. There is an apical eye of
black, with a small white centre. The hind-wings are ashy-grey, with
a marginal orange-tawny band. The body and base of the lower
wings are freely feathered. The under-side is similar in colouring,
only lighter; the apical eyes are more strongly marked; the hind-
wings are of an orange-brown tint, the orange band being slightly
defined on this side. The male has no orange-tawny markings on the
surface, only a slight shade of yellow being seen on the fore-wings,
shimmering through the uniform brown colour of the insect. There is
a small black eye, with a white central dot on the apex of each fore-
wing. On the under-side the fore-wings of the male are orange-
tawny, the black eye being larger and more pronounced than on the
surface. The hind-wings of the male are of a uniform olive-brown
colour. It is found in barrancos, meadows and rough places, from the
coast up to a moderately high altitude, from April to September; the
male appears first in the greatest numbers, and towards June the
female is also found in great quantities. The caterpillar has not been
observed.

HIPPARCHIA STATILINUS.
Plate II.—Fig. 7.
This is a brown butterfly common in many parts of Southern and
Central Europe, though not found in England. It is a rare insect in
Teneriffe, and is only met with high up in the mountains, chiefly at
Vilaflor, and on the south part of the island, about July and August.
It measures in expanse from two to three inches, and is of a uniform
brown colour, having a few white markings, which vary much in
different specimens, on the fore-wings. Two large brown spots are
seen at the outer margin of each fore-wing, interspersed with small
white spots. The hind-wings are brown, shading to lighter colour at
the base. The under-side is prettily mottled, and streaked with grey-
brown, the two dark spots seen on the margin being well defined.
The larva and chrysalis have not been observed.

HESPERIA ACTÆON.
Plate II.—Fig. 8.
This is a small Skipper, the only member of this family found in
Teneriffe. It resembles the English Lulworth Skipper, and frequents
damp places near the water-courses, though somewhat partial and
scarce. In a limited spot near Orotava it has been found in
quantities; and at Tacoronti, where butterflies abound, some have
been taken. The whole surface is of an orange-bronze colour with
slight brown markings. The antennæ are short and club-like; the
head is large, and the body thickish. It is found from April till June,
but solitary specimens are sometimes met with earlier in the year.
LIST OF BUTTERFLIES FOUND IN TENERIFFE.

NAME OF BUTTERFLY. REMARKS ON LOCALITIES,


ETC.
* 1 Pieris Cheiranthi Only in Canary Islands.
* 2 Pieris Wollastoni Canary Islands and
Madeira.
3 Pieris Rapæ England (Common White).
4 Pieris Daplidice England; rare (Bath White).
* 5 Euchloë Charlonia Not in England; N. and W.
Africa.
6 Aporia Cratægi England; rare (Black-veined
White).
* 7 Rhodocera Cleobule Not in England; peculiar to
the Islands.
* 8 Colias Edusa England (Clouded Yellow).
* 9 Colias v. Helice England; rare.
10 Lycæna Bætica England; very rare (Tailed
Blue).
*11 Lycæna Webbiana Only in Canary Islands.
12 Lycæna Lysimon Not in England.
*13 Lycæna Astrarche v.
Æstiva Not in England.
14 Polyommatus or
Chrysophanus Phlæas England (Common Copper).
15 Thecla Rubi England (Green Hair
Streak).
*16 Danais Plexippus
(formerly Archippus) England; very rare.
*17 Danais Chrysippus Not in England.
*18 Danais Alcippoides Not in England.
19 Danais Dorippus Not in England.
*20 Argynnis Maia (Cram), or In Canary Islands, N.
Pandora Africa, and S. Europe.
*21 Argynnis Lathonia England; rare (Queen of
Spain Fritillary).
*22 Pyrameis (formerly
Vanessa) Atalanta England (Red Admiral).
*23 Pyrameis Callirhoe or
Vulcania Not in England.
*24 Pyrameis Cardui England (Painted Lady).
*25 Pyrameis v. Huntera England; very rare;
common in America.
*26 Pararge Xiphiodes Not in England.
27 Epinephele Hispulla or
Fortunata (Alph.) Not in England.
*28 Hipparchia Statilinus Not in England.
*29 Hesperia Actæon England; local (Lulworth
Skipper).
* Marked thus are illustrated.
Part II.
MOTHS.

ACHERONTIA ATROPOS.
Plate IV.—Fig. 1.
This is the largest moth found in the Canary Islands, known as the
Death’s Head, very rarely met with in England.
It measures from five to six inches in expanse. The ground-colour of
the fore-wings is brown, varied with zig-zag lines of whitish yellow
and light brown. There is a white dot in the centre of each, and they
are dusted all over with minute white dots. The hind-wings are
orange, with two black marginal bands on the lower edge. The head
is dark brown or black, marked with a pale-brown skull. The body is
orange, with a longitudinal band of bluish grey down the centre,
increasing in width towards the base. Six bands of black, broadest
near the head, cross the body. The antennæ are rather short and
thick, tipped with white. The caterpillar measures about four inches
in length, and is of a most gorgeous green and yellow colour,
alternate transverse bands of these colours running along the sides.
It has eight small eyes in a line below the transverse bands, and a
horn on its tail. It feeds on the potato, the pupa making a cell for
itself underground, and appearing in the largest numbers between
May and July; but as a fresh crop of potatoes is planted every three
months in the Canaries, the caterpillars are found in small numbers
all the year round.
When bred in captivity the pupa is delicate, quite five out of ten
dying in their cases.

SPHINX CONVOLVULI or BATATÆ.


This moth is found in England, and all over Europe. It is a large
moth, measuring about five inches across the wings. All four wings
are of a variegated grey-brown colour, the body having a longitudinal
grey stripe, increasing in width at the base, and five stripes of pink
and black across it alternately. The antennæ are somewhat longer
and more slender than those of the Death’s Head moth. They are
feathered, and grey in colour, terminating in a sharp point. The
insect is provided with a very long proboscis, which one sees it
inserting into the centre of the flowers at dusk. During the winter
months it is met with commonly in some years. The caterpillar,
which measures four inches in length, feeds on the sweet potato in
the fields, and on the petunia and phlox in gardens. It is of a brown-
grey colour, shading to green on the back, having black longitudinal
stripes along the back, and transverse black and white stripes
surmounted by white spots at the sides. It is a night-feeder, hiding
itself under the leaves or in the ground at day-time, and constructing
the pupa-case underground. It is delicate and difficult to rear in
captivity, like the Atropos.

DEILEPHILA TITHYMALI.
Plate IV.—Fig. 4.
This beautiful moth is peculiar to the Canary Islands, although allied
species are found over the greater part of Europe.[6] It expands
from three to three and a half inches. The fore-wings are silvery
grey in colour, having dark olive-grey markings, and a long stripe of
this colour, increasing in width towards the body, from the apex to
the base. The hind-wings are a rich pink, having a marginal band of
dark brown, and a fine white line on the outer edge. The antennæ,
which are white, are thick and feathered. The head and body, thickly
feathered with white, are of an olive brown colour. Two bands of
black cross the top of the abdomen, which tapers off to a point, with
bands of alternate white and olive brown slightly marked with black.
The caterpillar is easily found on the Euphorbia where it feeds
gregariously. It is a beautiful dark pink, the horn being of this colour.
The dark pink is interspersed with dusky green and greyish black
spots, and the caterpillar, when at full size, attains a length of about
four inches. It is found from January till the end of May, but in the
greatest numbers in April, whilst the Euphorbia is in its prime. The
road-side between Rambla and Icod is a particularly favoured spot.
About one or two inches of dried earth prepared as already
mentioned are required for the larva to make its slight case in,
though when in a natural state it buries itself much deeper, and the
pupa is difficult to find. Some were fed and reared on a species of
milk-wort. They thrived, but eventually turned into small moths of a
paler colour than usual. The pupa varies much in the time of turning
to the moth stage, according to the weather,—from six weeks, the
usual time, to three months. Some caterpillars obtained in January
did not become moths till the end of March; others taken at full
growth on March 15th effected their last change to the moth during
the last week in April and first week in May. The pupa when it first
turns is of a beautiful shaded green colour with yellowish markings,
but it changes to a uniform brown in a few days. The caterpillar is
sometimes affected by a disease which consists of a small red
fungus growing on the body, generally towards the tail. One small
brood was entirely lost from this disease, which seemed to be
contagious. As a rule, however, the larvæ are easy to keep, and the
chrysalides hatch well and strongly. When numbers are kept, an old
wine-case should be substituted for the smaller breeding-cages
already mentioned, the mosquito-netting being used in the same
way. A little sun is beneficial to them every day in the morning.
When kept too long in the sun, however, they cease to feed,
although when in a natural state sunny localities are most favoured.
They are not night-feeders only.

[6]See Appendix D.

CHŒROCAMPA CELERIO.
Plate IV.—Fig. 2.
(Sharp Winged Hawk-Moth.)
This beautiful moth is somewhat allied to the last described, the
colour being similar, but the body is longer and more tapering. It is
found in England, and in most countries where the vine grows, on
which it feeds. The fore-wings are greyish brown with a silvery grey
stripe from the apex to the base; the outer lower margin is bordered
by a similar stripe. The hind-wings are of a rosy pink colour, veined
with, and having a marginal band of brown. The body is feathered,
and has a series of five short silver streaks down each side. The
antennæ are greyish white, not so long as those of the Tithymali.
From three to four inches is the length of the beautiful bright green
caterpillar. This has two dark and two light spots on its head, and a
horn on its tail. A faint yellow longitudinal line runs along each side.
It is rather liable to the attacks of the ichneumon fly, and so it is as
well to search for the eggs before putting it aside for rearing. This
year (1893) some were found in April, this being unusually early, as
it does not appear generally till June, from which date until August it
is very commonly met with in the vineyards. The pupa lies in a
dormant state for four weeks, and then turns to the moth freely and
strongly.

MACROGLOSSA STELLATARUM.
(Humming Bird Hawk-Moth.)
This moth is common in England and most parts of Europe. Its fore-
wings are brown, with faint longitudinal lines of a darker shade; the
hind-wings are orange tawny, fringed with light brown. It measures
in expanse about two inches. The head and body are brown, the
abdomen spotted with black and white, rather liberally feathered.
The antennæ are brown, being thinnest at the base, and gradually
thickening to the extremity. It is seen in the daytime, as well as
evening hovering, with an ever-restless motion of the wing, over
flowers. The caterpillar is green, with a longitudinal white stripe, and
a faint yellow one under the spiracles. The time of its appearance is
from March to September, but it is seen about in greatest numbers
in June.

RHYPARIOIDES RUFESCENS.
Plate IV.—Fig. 5.
This pretty moth is peculiar to the Islands, measuring rather more
than two inches across the wings. It is red in colour, the hind-wings
being brighter than the fore-wings. These latter are marked with
longitudinal dark stripes in the female, dark spots being substituted
for the stripes in the male. The head is dark red, shading off to
lighter red on the richly-feathered body. The antennæ are red, being
thicker and more feathered in the male than the female. The
caterpillars are brown, thickly covered with long silky hairs, and are
found mostly in barrancos, feeding on the dock and sorrel singly.
They are also found in gardens, feeding somewhat indiscriminately
on cabbage or hollyhock. When kept in captivity they can be reared
on cabbage, and after attaining their full size of about one and a half
inches, they make a slight hairy cocoon under a thin covering of
earth. The caterpillar stage lasts about twenty days. They are found
in January and hibernate in the pupa state till well on in the summer,
sometimes as late as October or November, though some taken in
January were brought to England and turned to moths on the 24th
of June following. After being kept for a time the chrysalides become
a very dark brown, almost black, so that there is a temptation to
throw them away as dead, since they show so little life; but on
opening the hard, stick-like skin, the creature is found to be quite
fresh.

DASYCHIRA FORTUNATA.
Plate IV.—Fig. 11.
In colour a dull grey moth. The fore-wings are ash-coloured,
variegated with whitish on the upper side. The reniform spot is rust-
coloured in the male and whitish in the female. The transverse lines
are black and dentated, the submarginal line maculated. The hind-
wings are grey, with a slight lunule in the middle; the underside
uniform grey. The body is less stout than the D. Fascelina (Linn.).
The abdomen is long in the male and longer in the female. The
antennæ are pectinated in the male, simple in the female. The legs
are thickly clothed with hair, the feet yellowish beneath. Although
the caterpillar has not been described, it presumably has much the
same characteristics as its allies, and is probably greyish, with tufts
of hair on its back; it feeds on the Pinus Canariensis.
This moth is allied to the English, and European species Dasychira
Fascelina (Dark Tussock), but is probably peculiar to the Islands. It
has been described as being found in the Islands of Palma and Hiero
by Rogenhofer in the “Verhandlungen des Kaiserlich-Königlichen
Zoologisch-botanischen Gesellschaft in Wien,” vol. 41 (for 1891), p.
566. The specimen illustrated was drawn from one of two presented
to the South Kensington Museum by the Rev. O. E. Benthall, who
found the chrysalides on trunks of the Canary pine near Guimar,
Teneriffe, about 2,000 feet above the sea, and as far as the author
can ascertain it has not before been recorded as occurring in
Teneriffe.

DEIOPEIA PULCHELLA.
Plate IV.—Fig. 9.
This beautiful little moth, expanding about one and a half inches, is
a very rare insect in Teneriffe at the present time, though two or
three years ago it was found in great abundance near, and along,
the coast during the spring months.[7] It has yellowish white fore-
wings freely spotted with black, alternated with oblong red spots,
not so numerous. The hind-wings are pearl-white, having a small
blackish brown spot towards the top, and a marginal indented
border of the same colour. The thorax and head are speckled with
black and yellow. The body is light pearl-grey. The larva is dark grey
with a broad white stripe on the back and reddish streaks on the
sides. This species is abundant throughout Africa, the South of Asia
and Europe, but a very scarce insect in England. Don Ramon Gomez
kindly supplied the specimen illustrated.

[7]A single specimen was taken by the Rev. O. E. Benthall at


Guimar in 1893.

PSEUDOPHIA TIRHACA (Cram); wrongly called


TYRRHÆA.
Plate IV.—Fig. 3.
This is not an English species, but is met with in Europe and North
Africa. It is not very commonly found in Teneriffe. The fore-wings
are green, with a central reddish-brown spot, the outer margin
having an indented band of the same colour. The body and hind-
wings, richly feathered, are a beautiful straw yellow, the latter
having a dark brown graduated band near the lower margin. It
expands about two inches and a half. The larva is grey, with a pale
grey stripe on the sides, and black spots on the lower surface
between the pro-legs.

CALOCAMPA EXOLETA.
(Sword-Grass Moth.)
This moth is an English species. It measures in expanse between
two and three inches, and is of a soft violet grey tinge, the fore-
wings having a variety of brown markings. The caterpillar feeds on
the Euphorbia, and has been found gregariously with the Tithymali
on that plant. It is met with, however, on peas and potatoes, and
can be reared on the leaves of any of these plants. The larva is
bright green, with two lines of black and white spots down each side
of the back. These are bordered by a yellow stripe (sometimes,
however, absent), and it has a broken red line on each side. The
caterpillar attains a length of about three inches. Some were kept in
the same breeding cage with the Tithymali, but their habits were
entirely different. When the Exoleta caterpillar ceased to feed, it did
not immediately attain the pupa state, but was restless and lively,
remaining as a caterpillar from six to eight weeks, gradually
shrinking and losing its colour, until it turned to the pupa. It made a
fragile shell of fine earth, oval in form, and buried itself a short
distance under the surface. Full-sized caterpillars, taken on the 20th
of March, ceased feeding and turned to the pupa state from the 1st
to the 20th of May, emerging to the moth on the 15th of June. In
some specimens the process of turning to the pupa took place on
the journey to England in a box, the caterpillars being covered lightly
with cotton-wool.

TRIPHÆNA PRONUBA.
(Common Yellow Underwing.)
This is a common moth in England and Europe, but is rather a
scarce species in Teneriffe. It expands a little more than two inches.
The fore-wings are dark brown, having a few irregular markings of a
lighter shade. The hind-wings are bright yellow, with a dark brown
marginal band on the lower edge. The body is a somewhat lighter
brown, and the antennæ are long and fine. The caterpillar is brown,
and it feeds on a variety of low-growing plants in the barrancos, and
may also be found on the potato. It commences to appear in the
early spring.

PLUSIA AURIFERA.
Plate IV.—Fig. 6.

You might also like