The gateway, a numbered door
Session numbers, gaps requested, resent orders counted once, and securing the front door.
Lesson 29 min
By the end of this lesson
- Spot a numbering gap in a session and say which messages to request
- Explain how an increasing identifier makes a resent order be ignored
- Calculate the number of messages refused by a rate limit
The access gateway is the venue's door. A door does two things: it lets in those who are allowed, and it loses nothing of what they bring. What you will learn here: a gateway numbers every message of a session, asks for the missing ones and ignores those that arrive twice.
A session, a run of numbers
The FIX Trading Community defines a session as "a bidirectional stream of ordered messages", with a continuous series of sequence numbers starting at 1 (FIX, session layer). Nasdaq's SoupBinTCP protocol, published in full, does the same: the client counts the messages received and, after a disconnection, logs back in announcing the next number it expects; it thus receives every message in order (SoupBinTCP 3.00).
Access gateway
The component that opens and watches members' sessions, checks their identity and the numbering of their messages, then passes those messages, translated, to the rest of the venue.
The number is there to show what is missing. If the gateway expects 3 and receives 4, a message was lost in between. In FIX it then sends a resend request (ResendRequest, type 2); the other side resends the messages flagged "possible duplicate" (PossDupFlag, field 43) or a message that fills the gap (Cboe FIX specification, message recovery). The developer track describes the FIX messages of an order (Order life cycle and the FIX protocol).
Sent by the brokerage firm
Processed by the gateway
EtatSession
Logon · seq 1
Opening the session
The gateway expects message 3 and receives 4. Why does it not process 4 straight away?
A resent order counts once
After a disconnection, the member does not know whether its last message arrived. If it resends it and the gateway processes it twice, it buys twice. Nasdaq handles this in its OUCH protocol: each order carries an identifier, the UserRefNum, unique and strictly increasing during the day; the system ignores a request whose identifier is lower than the last one processed, treating it as a retransmission, so any inbound message can be resent safely (OUCH 5.0, 2025).
/** Design choice, inspired by OUCH: strictly increasing client identifier. */
interface Message { seq: number; idClient: number }
class Session {
private attendu = 1
private enAttente = new Map<number, Message>()
private dernierId = 0
recevoir(m: Message): Message[] | { renvoyer: number } {
if (m.seq < this.attendu) return [] // already received: ignored
if (m.seq > this.attendu) {
const premierTrou = this.enAttente.size === 0
this.enAttente.set(m.seq, m)
// gap: ask for the missing one, once only
return premierTrou ? { renvoyer: this.attendu } : []
}
const prets: Message[] = []
let suivant: Message | undefined = m
while (suivant) {
this.attendu++
if (suivant.idClient > this.dernierId) {
this.dernierId = suivant.idClient
prets.push(suivant)
} // otherwise: order already seen, resent to be safe
suivant = this.enAttente.get(this.attendu)
this.enAttente.delete(this.attendu)
}
return prets
}
}
A session of seven messagesFictional
A fictional brokerage firm sends messages 1 to 7; 4 is lost. The order identifiers are 101, 102, 103, 104, 105, 106 and, after a disconnection, 106 again.
- Messages 1, 2, 3: processed; the gateway expects 4.
- Message 5: 5 > 4, set aside; resend request from 4.
- Message 6: set aside too (the request has already gone, we do not send one per message).
- Message 4 resent: processed, then 5 and 6 come out of the waiting area; the gateway expects 7.
- Message 7, identifier 106: already seen, ignored. Orders actually passed on: 6, not 7.
The door is also a wall
The gateway is the only point where the outside world touches the venue. For its API, the BVMAC requires confidentiality and integrity of exchanges, strong authentication and access management, encryption in transit (TLS), rate limiting, lists of authorised IP addresses and audit logs of requests (tender no. 023/16/BVMAC/DD/05-25). Its general rules already provide connection IP addresses reserved in advance to switch members to the backup site (RG BVMAC 2025, art. 137).
In Europe, a venue must set a maximum number of orders per second for each member and be able to suspend its access (Delegated Regulation (EU) 2017/584, art. 18), and protect itself against unauthorised access and data tampering (art. 23).
A rate limitFictional
Design choice: 50 messages per second per member. A fictional brokerage firm sends 80 messages in the same second.
- Accepted: the first 50, in number order.
- Refused: 80 − 50 = 30, each with a reject message giving the reason.
- Other members see no slowdown: the limit protects the shared queue.
Finally, the gateway watches for silence. In SoupBinTCP, each side sends a heartbeat whenever a second passes without data, and the server typically closes the connection of a client silent for 15 seconds (SoupBinTCP 3.00). A dead connection thus shows within seconds, not at the end of the session.
Name three gateway protections and what each one prevents.
Your turn
Read next: Nasdaq, OUCH 5.0 Order Entry Specification (2025)
A question? Ask your teacher, or an AI assistant, giving it the title of this lesson.