Skip to content
This repository was archived by the owner on Apr 29, 2020. It is now read-only.

Commit a90537c

Browse files
committed
Updating analysis with:
- Restructured model description. - New cost value in utility function (unfinished -- analysis needs to be updated to reflect this). License: MIT Signed-off-by: David Grisham <dgrisham@mines.edu>
1 parent 025a345 commit a90537c

File tree

2 files changed

+123
-87
lines changed

2 files changed

+123
-87
lines changed

analysis/prelim_strategy_analysis.md

Lines changed: 123 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
---
2-
title: Bitswap Analysis
2+
title: 'Bitswap: Model and Preliminary Analysis'
33
subtitle: 3 Strategies
44
author: David Grisham
55
header-includes:
66
- \usepackage{mathtools}
7+
- \usepackage{amsmath}
78
- \usepackage{multirow,array}
89
- \usepackage{float}
910
- \restylefloat{table}
1011
- \DeclarePairedDelimiter\abs{\lvert}{\rvert}
1112
- \newcommand{\Network}{\ensuremath{\mathcal{N}}}
12-
- \newcommand{\Nbhd}[1]{\mathcal{N}_{#1}}
13+
- \newcommand{\Nbhd}[1]{\ensuremath{\mathcal{N}_{#1}}}
1314
...
1415

1516
**TODO**: Ensure periods at the end of all bullet points/lists are consistent
@@ -18,11 +19,29 @@ header-includes:
1819

1920
---
2021

21-
In this paper, we analyze 3 strategies for a simple 2-player Bitswap infinitely
22-
repeated game. We start by defining the system in the most general case, then do
23-
an analysis on a system subject to simplifying constraints.
22+
Introduction
23+
============
24+
25+
**TODO**: review this section
26+
27+
The InterPlanetary File System (IPFS) is a peer-to-peer data distribution
28+
protocol \[**TODO: cite**\] for sharing hypermedia. IPFS draws inspiration from
29+
powerful techniques such as distributed hash tables, sharding, content-addressed
30+
data, linked data, and self-certified file systems. At a high level, an IPFS
31+
network may be thought of as a Git repository shared in a BitTorrent-like swarm.
32+
IPFS has many potential applications, including sharing files within a corporate
33+
context, library archival, and, perhaps the most ambitious one, replacing HTTP
34+
as the primary file distribution protocol used on the Internet.
2435

2536
Bitswap is the data exchange protocol for the InterPlanetary File System (IPFS).
37+
Bitswap's most direct influence is BitTorrent \[**TODO: cite**\] -- like a
38+
BitTorrent client, Bitswap determines how to effectively allocate resources
39+
(e.g. bandwidth) to peers. In this work, we primarily focus on Bitswap from a
40+
game-theoretic perspective. **TODO: finish this off somehow, transition to next
41+
section**
42+
43+
**TODO: get info in the below paragraph somewhere (if it needs to be)**
44+
2645
Our model is meant to reflect this use case of Bitswap as the decision engine
2746
implemented by each user in a peer-to-peer distributed file system. In this
2847
distributed file system of many users, each user is connect to a set of peers
@@ -37,116 +56,121 @@ $1$ sends the same amount of data to both $2$ and $3$ over that time), then peer
3756
$1$ might allocate $\frac{2}{3}$ of its bandwidth to peer $2$ and $\frac{1}{3}$
3857
to peer $3$ at time $t$.
3958

40-
**TODO**: necessary to explicitly mention strategies here? trying to stay
41-
informal, but might still be a good idea
59+
System Model
60+
============
4261

43-
System
44-
======
62+
Network Graph
63+
-------------
4564

46-
We have a network \Network of $\abs{\Network}$ users. The terms *users* and
47-
*players* will be used somewhat interchangeably, depending on context; the term
48-
*peers* is used similarly, but primarily refers to users who are connected (and
49-
thus participate as players in the same Bitswap game). Each of the users has a
50-
neighborhood of peers, which is the set of users they are connected to. Each
51-
pair of peers plays an infinitely repeated Bitswap game. The resource that users
52-
have to offer to their peers is bandwidth. We make the following simplifying
53-
assumptions about user's bandwidth:
65+
We model an IPFS swarm as a network \Network of $\abs{\Network}$ users. The
66+
graphical representation consists of
5467

55-
1. All users have the same amount of bandwidth to offer.
56-
2. A single user has the same amount of bandwidth to offer at each time step.
68+
- *nodes* representing users;
69+
- an *edge* representing a peering between two users; and
70+
- *unweighted*, *undirected* edges.
5771

58-
In other words, bandwidth is constant both in peer-space and in time. **TODO**:
59-
worth saying it this way, or is 'peer-space' confusing?
72+
A user's *neighborhood* is their set of peers, i.e. the set of nodes that the
73+
user is connected to by an edge. User $i$'s neighborhood is denoted by
74+
$\Nbhd{i} \subseteq \Network$.
6075

61-
We also make the assumption that *all users always have unique data that all of
62-
their peers want*. So, whenever a peer plays $R$, they'll always have some data
63-
to send to all of their peers. This, of course, contrasts a more realistic
64-
scenario where a peer chooses to reciprocate but simply does not have anything
65-
that their peers want at the current time.
76+
**TODO: anything else to add here?**
6677

67-
Actions and Utility Functions
68-
-----------------------------
78+
Game Formulation
79+
----------------
6980

70-
**TODO**: ensure lower bound for $t$ is consistently 0 (and not typo'd as 1)
81+
**TODO: may want to update all references 'bandwidth' with 'data'**
7182

72-
A player has two possible actions: reciprocate ($R$) or defect ($D$). The
73-
utility function for player $i$ at time $t$ $u_i^t$:
83+
All users in the network participate in the Bitswap game. The Bitswap game is an
84+
*infinitely repeated*, *zero-sum* (**TODO: complete or incomplete info?**) game
85+
where users exchange bandwidth. The game is separated into discrete *rounds*
86+
with an individual round denoted by $t$, where $t$ is a non-negative integer.
87+
The game model has the following properties:
7488

75-
$$
76-
u_i^t = \sum_{j \in \Nbhd{i}} \delta_{a_j^{t}R}\
77-
S_j(d_{ji}^t\,,\,\mathbf{d}_j^{-i,t})\ B
78-
\:-\:\delta_{a_i^t R}\ B \\
79-
$$
80-
81-
where
89+
- The *players* are the IPFS users in the network \Network.
90+
- $a_i^t \in \{R, D\}$ is the *action* user $i$ takes in round $t$, where $R$
91+
and $D$ represent reciprocation and defection, respectively. When a user
92+
reciprocates, they allocate resources toward sending data to their peers;
93+
when the user defects, they do not send data to their peers.
8294

83-
- $\Nbhd{i} \subseteq \Network$ is the neighborhood of user $i$ (i.e. the set
84-
of peers $i$ is connected to)
85-
- $a_i^t \in \{R, D\}$ is the action user $i$ takes in round $t$
86-
- $\delta{ij}$ is the kronecker delta function
87-
- $d_{ji}^t$ is the reputation of user $i$ as viewed by peer $j$ (also
88-
referred to as the *debt ratio* from $i$ to $j$) in round $t$
89-
- $\mathbf{d}_j^{-i,t} = (d_{jk}^t \mid \forall k \in \Nbhd{j}, k \neq i)$ is
90-
the vector of debt ratios for all of user $j$'s peers (as viewed by peer
91-
$j$) in round $t$, *excluding* peer $i$
92-
- $S_j(d_{ij}^t, \mathbf{d}_j^{-i,t}) \in \{0, 1\}$ is the *reciprocation
93-
function* of user $j$. This function considers the relative reputation of
94-
peer $i$ to the rest of $j$'s peers, and returns a weight for peer $i$. This
95-
weight is used to determine what proportion of $j$'s bandwidth to allocate
96-
to peer $i$ in round $t$.
97-
- $B > 0$ is the (constant) amount of bandwidth that a user has to offer in a
98-
given round
99-
100-
The terms *strategy* and *reciprocation function* are defined as:
101-
102-
- A *strategy* is meant in the standard game-theoretical sense, which is a
103-
predetermined set of actions that a user will take in a game (potentially
104-
dependent on that user's previous payoffs, the actions of its peers, etc.).
105-
- A *reciprocation function* is a term used to specify the weighting function
106-
that a user uses when running the Bitswap protocol to determine how much
107-
bandwidth it wants to allocate to each of its peers whenever it's playing
108-
the $R$ strategy.
95+
We also include two simplifying constraints:
10996

110-
Putting this all together, we see that the utility of peer $i$ in round $t$ is
111-
the total amount of bandwidth that $i$ is allocated by its neighboring peers,
112-
minus the amount of bandwidth that $i$ provides to its peers. If $i$
113-
reciprocates, then we say that they provide a total of $B$ bandwidth to the
114-
network; otherwise (when $i$ defects), $i$ provides $0$ bandwidth in that round.
97+
1. Each user has the same amount of bandwidth to distribute among their peers
98+
in every round.
99+
2. All users always have unique data that all of their peers want. So, when a
100+
user allocates bandwidth to a particular peer, that bandwidth can always be
101+
fully utilized.
115102

116-
We can write the debt ratio $d_{ij}$ in terms of the number of bits exchanged
117-
between peers $i$ and $j$:
103+
We define $b_{ji}^t$ as the total number of bits sent from user $j$ to peer $i$
104+
from round $0$ to $t-1$. Then we can define the *debt ratio* $d_{ji}$ from user
105+
$j$ to peer $i$ as
118106

119107
$$
120108
d_{ji}^t = \frac{b_{ji}^{t-1}}{b_{ij}^{t-1}\:+\:1}
121109
$$
122110

123-
where $b_{ij}^{t-1}$ is the total number of bits sent from $i$ to $j$ from round
124-
$0$ through round $t-1$ (so, all rounds prior to round $t$).
111+
$d_{ji}^t$ can be thought of as peer $i$'s reputation in the eyes of user $j$.
112+
This reputation is then considered by user $j$'s *reputation function*
113+
$S_j(d_{ji}^t, \mathbf{d}_j^{-i,t}) \in \{0, 1\}$, where
114+
$\mathbf{d}_j^{-i,t} = (d_{jk}^t \mid \forall k \in \Nbhd{j}, k \neq i)$ is the
115+
vector of debt ratios for all of user $j$'s peers in round $t$ *excluding* peer
116+
$i$. The reputation function considers the relative reputation of peer $i$ to
117+
the rest of $j$'s peers, and returns a weight for peer $i$. This weight is used
118+
to determine what proportion of $j$'s bandwidth to allocate to peer $i$ in round
119+
$t$. A specific example of a reciprocation function is given in Section
120+
\ref{analysis}.
125121

126-
We can define $b_{ij}^t$ in terms of $b_{ij}^{t}$ and $\delta_{a_i^t R}$ as
127-
follows:
122+
We can now formally define $b_{ij}^t$ recursively using the debt ratio and the
123+
kronecker delta function $\delta_{ij}$:
128124

129125
$$
130-
b_{ij}^t = b_{ij}^{t-1}\:+\:
131-
\delta_{a_i^{t-1} R}\ S_i(d_{ij}^t\,,\,\mathbf{d}_i^{-j,t})\ B
126+
b_{ij}^t =
127+
\begin{cases}
128+
0 & t = 0 \\
129+
b_{ij}^{t-1}\:+\:
130+
\delta_{a_i^{t-1} R}\ S_i(d_{ij}^t\,,\,\mathbf{d}_i^{-j,t})\ B & \text{otherwise} \\
131+
\end{cases}
132132
$$
133133

134-
So, the total number of bits sent from $i$ to $j$ increases by
135-
$S_i(d_{ij}^t, \mathbf{d}_i^{-j,t}) B$ (the proportion of $i$'s total bandwidth
136-
that $i$ allocates to $j$) if and only if peer $i$ reciprocated in round $t-1$
137-
(i.e., $a_i^{t-1} = R \implies \delta_{a_i^{t-1} R} = 1$).
134+
Considering the recursive case of this definition, we see that the total number
135+
of bits sent from $i$ to $j$ increases by $S_i(d_{ij}^t, \mathbf{d}_i^{-j,t}) B$
136+
(the proportion of $i$'s total bandwidth that $i$ allocates to $j$ in round $t$)
137+
if and only if peer $i$ reciprocated in round $t-1$ (i.e.,
138+
$a_i^{t-1} = R \implies \delta_{a_i^{t-1} R} = 1$).
138139

139-
Now we can write $d_{ij}^{t+1}$ in terms of values from round $t$.
140+
Putting all of this together, we define the utility function for player $i$ at
141+
time $t$:
140142

141143
$$
142-
d_{ij}^{t+1} = \frac{b_{ij}^{t}\:+\:
143-
\delta_{a_i^t R}\ S_i(d_{ij}^t\,,\,\mathbf{d}_i^{-j,t})\ B}
144-
{b_{ji}^t\:+\:\delta_{a_j^t R}\ S_j(d_{ji}^t\,,\,\mathbf{d}_j^{-i,t})
145-
\ B\:+\:1}
144+
u_i^t = \sum_{j \in \Nbhd{i}} \delta_{a_j^{t}R}\
145+
S_j(d_{ji}^t\,,\,\mathbf{d}_j^{-i,t})\ B
146+
\:-\:\delta_{a_i^t R}\ c \\
146147
$$
147148

149+
where
150+
151+
- $B > 0$ is the amount of bandwidth that a user has to offer in a given
152+
round.
153+
- $c > 0$ is the cost of reciprocating.
154+
155+
Putting this all together, we see that the utility of peer $i$ in round $t$ is
156+
the total amount of bandwidth that $i$ is allocated by its neighboring peers,
157+
minus the cost to $i$ for providing data to its peers (if it does so). If $i$
158+
reciprocates, then we say that they provide a total of $B$ bandwidth to its
159+
neighborhood \Nbhd{i}; otherwise (when $i$ defects), $i$ provides $0$ bandwidth
160+
in that round.
161+
162+
**TODO: fit the following sentences somewhere (or remove it)** We start by
163+
defining the system in the most general case, then do an analysis on a system
164+
subject to simplifying constraints.
165+
166+
**TODO**: ensure lower bound for $t$ is consistently 0 (and not typo'd as 1)
167+
148168
Analysis
149169
========
170+
\label{analysis}
171+
172+
**TODO: (continue from here) update all of analysis to reflect new utility
173+
function**
150174

151175
For the purposes of this analysis, we make an additional assumption: each user's
152176
neighborhood is constant -- so any given pair of peers is connected for the
@@ -160,7 +184,7 @@ S_j(d_{ji}^t\,,\,\mathbf{d}_j^{-i,t}) = \frac{d_{ji}^t}
160184
{\sum_{k \in \Nbhd{j}} d_{jk}^t}
161185
$$
162186

163-
We make the additional caveat that $d_{ji}^0\ \forall\ i, j \in \Network$ --
187+
We make the additional caveat that $d_{ji}^0 = 1\ \forall\ i, j \in \Network$ --
164188
think of this as an initial optimistic send for bootstrapping purposes
165189
(otherwise, peers would never send each other anything). (**TODO**: best place
166190
to say this?)
@@ -680,3 +704,15 @@ that should arise under more general conditions. In particular, having (1) a
680704
network with more users and larger peer sets peer user, as well as (2) longer
681705
peer-to-peer histories (rather than just single-round lookbehinds), should
682706
result in interesting peer dynamics that are not illustrated in this analysis.
707+
708+
BACKUP
709+
------
710+
711+
Now we can write $d_{ij}^{t+1}$ in terms of values from round $t$.
712+
713+
$$
714+
d_{ij}^{t+1} = \frac{b_{ij}^{t}\:+\:
715+
\delta_{a_i^t R}\ S_i(d_{ij}^t\,,\,\mathbf{d}_i^{-j,t})\ B}
716+
{b_{ji}^t\:+\:\delta_{a_j^t R}\ S_j(d_{ji}^t\,,\,\mathbf{d}_j^{-i,t})
717+
\ B\:+\:1}
718+
$$
9.36 KB
Binary file not shown.

0 commit comments

Comments
 (0)