TITLE: Bounded Hamming distance
QUESTION [5 upvotes]: Definition 1. For each $n\in\mathbb{Z}^+$, the $n$-dimensional Hamming cube is the set of ordered $n$-tuples of $\lbrace 0,1\rbrace$, denoted by $\lbrace 0,1\rbrace ^n$.
Definition 2. The binary operation that turns $\lbrace 0,1\rbrace ^n$ into a group is $\oplus$ (XOR), which is bitwise addition reduced modulo $2$.
Definition 3. The sum of the digits of an element of $\lbrace 0,1\rbrace ^n$ is its Hamming weight. The Hamming weight of the XOR of two elements is the Hamming distance $h$ between them. In fact, $h$ is a metric on $\lbrace 0,1\rbrace ^n$.
Question. Given integers $0\le a\le b\le n$, what is known regarding maximal subsets $S$ of $\lbrace 0,1\rbrace^n$ such that: $\forall x,y\in S: a\le h(x,y)\le b$ ? Specifically, is anything known about bounds on cardinality, or exact cardinality, or even construction of these maximal sets?
I expect that the full answer is not known but I would be happy to read replies about, or receive direction toward resources for, special cases. For example, if $n$ is even and if $a=b=\frac{n}{2}$, then we turn to Hadamard matrices.

REPLY [6 votes]: My previous answer is already too long, and this is too much to include in a comment. But I found a paper that studies the problem you asked here:
R. M. Roth, G. Seroussi, Bounds for binary codes with narrow distance distributions, IEEE Transactions on Information Theory 58 (2007) 2760-2768
It seems a lot of interesting things are proved here. Among others, one of their propositions states that

Let $\mathcal{C}$ be an $(n,M,d)$ binary code of length $n$ and minimum distance $d$ with exactly $M$ codewords. Assume that the largest Hamming distance between two codewords $\boldsymbol{c}, \boldsymbol{c}' \in \mathcal{C}$ is $d_{\text{max}}$. Denote by $d_a$ and $d_g$ the arithmetic and geometric means respectively, of $d$ and $d_{\text{max}}$, i.e.,
$$d_a = \frac{d+d_{\text{max}}}{2} \quad \text{and} \quad d_g = \sqrt{dd_{\text{max}}}.$$
  Then
$$1-\frac{1}{M} \leq \begin{cases} \left(1-\frac{1}{n}\right)\left(\frac{d_a}{d_g}\right)^2 \quad &\text{if }\ 2d_a \not\in \{n+1, n+2\},\\\\ \frac{n}{d_g^2}\left(d_a- \frac{n+1}{4}\right) &\text{if }\ 2d_a \in \{n+1, n+2\}.\end{cases}$$

They also study equidistant codes, constant-weight codes, and self-complementary codes.
If you don't have access to the journal, a preprint is available on the first author's website:
http://www.cs.technion.ac.il/~ronny/PUB/2007/variance.pdf