sms, engine, imsd: a segment that gets no answer, or an RP-ERROR with cause 41, is sent once more with TP-RD set
A submission whose submit report did not come in time ended as `failed`, and nothing was sent again. The service centre may have the text all the same, and a user who then sends it again delivers it twice: the second submission has a new TP-MR, and the service centre cannot tell that it is a repeat (issue #3, the second of its three cases). TS 23.040 9.2.3.6 has the MS "automatically repeat the SMS-SUBMIT", one to three times, with the same TP-MR and TP-RD set, when no response or an RP-ERROR with an appropriate cause comes, so that the service centre can discard a duplicate. SmsOutbound now sends a segment once more: when either wait runs out, on a final of 408 or 504 (RFC 3261 21.4.9: the server "could not produce a response within a suitable amount of time"; 21.5.5: it "did not receive a timely response from an external server") and on an RP-ERROR with cause 41, temporary failure, or with a value TS 24.011 table 8.4's part 1 does not list, which it has "treated as cause number 41". Of the causes part 1 lists, Annex E-2 says of 41 alone that the MS "may wish to try another short message transfer attempt almost immediately". The repeat is a MESSAGE of its own, under its own Call-ID and the next RP-MR — the shell's counter now goes on after the last RP-MR a message used, one per MESSAGE built — with the same SMS-SUBMIT, TP-RD set by the codec's flag, which nothing set until now. The two waits are longer, so that a repeat does not overtake an answer that is only late: 128 s for the final and 130 s from the final for the report. TS 24.229 table 7.7.1 recommends a UE whose requests name one of the accesses clause 7.7 lists in P-Access-Network-Info a T1 of 2 s and a timer F of 64*T1, and TS 24.341 5.3.1.1 NOTE 1 has an SM-over-IP sender's TR1M set to a value greater than timer F (Jorijn, 2026-11-21). The segment is accepted by an RP-ACK to either attempt — the first attempt's is taken when it comes after the repeat went out — and by the RP-ERROR whose TP-FCS is the duplicate rejection (0xC5) when it answers the repeat and no RP-ERROR has answered the first attempt by then: the service centre is taken to have the first. An RP-ERROR to the first attempt that comes after the repeat went out leaves the segment to the repeat's answer. Any other end of the repeat fails the message, with both attempts' ends in the reason. A final refused with another status and an RP-ERROR with another cause fail the message at once, as before. What the duplicate rejection does not say is which SMS-SUBMIT the service centre holds: one of this subscription's that reached it another way under the same TP-MR can draw the rejection too, and with imsd's first attempt lost the message is then `sent` for a text that never arrived (Jorijn, 2026-11-21: taken as the clause has it). Not done of the clause's repeat: it cannot be switched off, and a failed message is not kept for a user's retransmission under its TP-MR. No member of the Messaging interface changes: `sent` and `failed` come as before, a `failed` later by the waits — with nothing answering, 256 s after the MESSAGE where 1.2.0 said it after 32 s — and texts queued behind the message wait as long. Tested by tests/Engine and tests/Sms (RpCauseIsTemporary over all 128 values; a cross-generated SMS-SUBMIT with TP-RD), and on the dev phone against KPN with the binary of this range's last commit (the fp6 journal's 2026-11-20-issues-2-5 capture, phone-form6, repeat-bench.log): with the phone deaf on its protected server port a text to the own number got its 202 and no submit report, went out again 130 s after the final under the next RP-MR, with the same TP-MR and TP-RD set, and ended `sent`; the message after it took the RP-MR after the repeat's. KPN's service centre did not discard the repeat in that bench, nor in the six before it (one of them with a build that waited 40 s): the repeat got an RP-ACK under a time stamp of its own, and once the port was open again the text came twice, under the two attempts' time stamps: the recipient got the text twice without the user sending it again, and the message was `sent`. 1.2.0 ends a submission whose report does not come as `failed` and sends nothing again. The repeat is sent all the same, on Jorijn's decision of 2026-11-20 with the first of those benches before him: the clause has the MS repeat ("shall") and the service centre discard ("should"), and Android's framework sends its own retries so (AOSP's ImsSmsDispatcher and GsmSMSDispatcher set TP-RD and the earlier TP-MR; the capture's repeat-research).
This commit is contained in:
parent
ef04b473a7
commit
23892e8e81
7 changed files with 670 additions and 123 deletions
|
|
@ -29,9 +29,13 @@
|
|||
// ids (RunToken, SentSmsId, ReceivedSmsId);
|
||||
// SmsOutbound through a
|
||||
// submission (the MESSAGE with the RP-DATA, its 202, the RP-ACK -> sent; a
|
||||
// refused final, an RP-ERROR with its cause, the final's wait and the
|
||||
// report's running out, a failed send, two segments with consecutive
|
||||
// RP-MR/TP-MR, a
|
||||
// refused final, an RP-ERROR with its cause, the segment's one repeat with
|
||||
// TP-RD set — after the final's wait or the report's ran out, a 408 or a
|
||||
// 504 final, an RP-ERROR with cause 41 or an unlisted one — taken,
|
||||
// rejected as a duplicate (after a first attempt that was refused, and
|
||||
// after one that was not), ended in its turn, the first attempt's report
|
||||
// after it, a
|
||||
// failed send, two segments with consecutive RP-MR/TP-MR, a
|
||||
// destination that is no number, no service centre, a submit report before
|
||||
// the MESSAGE's own final, a text past 255 segments) and OnSmsMessage (a
|
||||
// delivery with no gateway for its report, a
|
||||
|
|
@ -1341,7 +1345,7 @@ int main() {
|
|||
auto a = m.Start(100.0);
|
||||
const auto* sent = findSms(a, SmsAction::Type::SendClient);
|
||||
Check(sent && sent->text.starts_with("MESSAGE sip:+31653131313@ims.mnc001.mcc001.3gppnetwork.org;user=phone SIP/2.0\r\n"), "outbound: the MESSAGE goes to the SC's PSI");
|
||||
Check(m.State() == SmsOutbound::Phase::Sending && m.Deadline() == 100.0 + SmsSendTimeout, "outbound: sending, the 32 s wait for the final armed");
|
||||
Check(m.State() == SmsOutbound::Phase::Sending && m.Deadline() == 100.0 + SmsSendTimeout, "outbound: sending, the 128 s wait for the final armed");
|
||||
if (!sent) return 1;
|
||||
const std::string callid(imsd::sip::Header(sent->text, "Call-ID").value_or(""));
|
||||
auto rp = bodyRp(sent->text);
|
||||
|
|
@ -1350,10 +1354,10 @@ int main() {
|
|||
Check(m.TpMrs() == std::vector<std::uint8_t>{10} && m.Segments() == 1, "outbound: one segment");
|
||||
Check(m.OwnsResponse(final(callid, 202, "Accepted")) && !m.OwnsResponse(final("other", 202, "Accepted")), "outbound: owns its own MESSAGE's final only");
|
||||
auto b = m.OnResponse(final(callid, 202, "Accepted"), 202, 101.0);
|
||||
Check(m.State() == SmsOutbound::Phase::AwaitingReport && m.Deadline() == 101.0 + SmsReportTimeout && !hasSms(b, SmsAction::Type::State), "outbound: 202 -> awaiting the submit report, its 40 s wait armed");
|
||||
Check(SmsSendTimeout == 32.0 && SmsReportTimeout == 40.0, "outbound: the wait for the final is 32 s, the one for the submit report 40 s");
|
||||
Check(m.OwnsReport(callid, std::nullopt) && !m.OwnsReport("x@y", 20) && m.OwnsReport("", 20) && !m.OwnsReport("", 21), "outbound: a report is matched by In-Reply-To, else by RP-MR");
|
||||
Check(m.OwnsReport(std::format("x@y, {}", callid), std::nullopt) && m.OwnsReport(std::format("{},x@y", callid), 21) && m.OwnsReport(std::format("z@w , {} ,x@y", callid), 21) && m.OwnsReport(std::format("z@w\t,\t{}", callid), 21) && !m.OwnsReport("x@y, z@w", 20) && !m.OwnsReport(callid + "x", 20) && !m.OwnsReport("x" + callid, 20), "outbound: of an In-Reply-To that lists Call-IDs, ours among them is ours");
|
||||
Check(m.State() == SmsOutbound::Phase::AwaitingReport && m.Deadline() == 101.0 + SmsReportTimeout && !hasSms(b, SmsAction::Type::State), "outbound: 202 -> awaiting the submit report, its 130 s wait armed");
|
||||
Check(SmsSendTimeout == 128.0 && SmsReportTimeout == 130.0, "outbound: the wait for the final is 128 s, the one for the submit report 130 s");
|
||||
Check(m.ReportAttempt(callid, std::nullopt) && !m.ReportAttempt("x@y", 20) && m.ReportAttempt("", 20) && !m.ReportAttempt("", 21), "outbound: a report is matched by In-Reply-To, else by RP-MR");
|
||||
Check(m.ReportAttempt(std::format("x@y, {}", callid), std::nullopt) && m.ReportAttempt(std::format("{},x@y", callid), 21) && m.ReportAttempt(std::format("z@w , {} ,x@y", callid), 21) && m.ReportAttempt(std::format("z@w\t,\t{}", callid), 21) && !m.ReportAttempt("x@y, z@w", 20) && !m.ReportAttempt(callid + "x", 20) && !m.ReportAttempt("x" + callid, 20), "outbound: of an In-Reply-To that lists Call-IDs, ours among them is ours");
|
||||
Rp ack{RpType::AckMt, 20, std::nullopt, *imsd::util::FromHex("010062016122050080"), std::nullopt, std::nullopt};
|
||||
auto d = m.OnReport(ack, 102.0);
|
||||
const auto* st = findSms(d, SmsAction::Type::State);
|
||||
|
|
@ -1376,35 +1380,264 @@ int main() {
|
|||
auto a = m.Start(0.0);
|
||||
const std::string callid(imsd::sip::Header(findSms(a, SmsAction::Type::SendClient)->text, "Call-ID").value_or(""));
|
||||
m.OnResponse(final(callid, 100, "Trying"), 100, 5.0);
|
||||
Check(m.State() == SmsOutbound::Phase::Sending && m.Deadline() == 5.0 + SmsSendTimeout, "outbound: a provisional starts the 32 s wait over");
|
||||
Check(m.State() == SmsOutbound::Phase::Sending && m.Deadline() == 5.0 + SmsSendTimeout, "outbound: a provisional starts the 128 s wait over");
|
||||
m.OnResponse(final(callid, 200, "OK"), 200, 6.0);
|
||||
Rp err{RpType::ErrorMt, 20, std::nullopt, *imsd::util::FromHex("01c30062016122050080"), 28, std::nullopt};
|
||||
auto b = m.OnReport(err, 7.0);
|
||||
const auto* st = findSms(b, SmsAction::Type::State);
|
||||
Check(st && st->state == "failed" && st->reason.contains("RP cause 28 (unidentified subscriber)") && st->reason.contains("TP-FCS 0xc3 (invalid SME address)"), "outbound: an RP-ERROR fails the message with its cause and TP-FCS");
|
||||
}
|
||||
// timeouts and a failed send
|
||||
// the final's wait runs out: the segment goes out once more (TS 23.040 9.2.3.6) — the same SMS-SUBMIT with TP-RD set, in a MESSAGE of its own — and is accepted
|
||||
auto logged = [](const std::vector<SmsAction>& a, std::string_view text) { for (const auto& x : a) if (x.type == SmsAction::Type::Log && x.text == text) return true; return false; };
|
||||
auto callIdOf = [](const SmsAction* a) { return a ? std::string(imsd::sip::Header(a->text, "Call-ID").value_or("")) : std::string(); };
|
||||
const std::string toSc = "to +31612345678 via sip:+31653131313@ims.mnc001.mcc001.3gppnetwork.org;user=phone";
|
||||
const Rp duplicate{RpType::ErrorMt, 21, std::nullopt, *imsd::util::FromHex("01c50062016122050080"), 21, std::nullopt}; // TP-FCS 0xC5, "SM Rejected-Duplicate SM"
|
||||
const Rp temporary{RpType::ErrorMt, 20, std::nullopt, {}, 41, std::nullopt};
|
||||
const Rp permanent{RpType::ErrorMt, 20, std::nullopt, *imsd::util::FromHex("01c30062016122050080"), 28, std::nullopt};
|
||||
Check(SmsAttempts == 2, "outbound: a segment goes out twice at most");
|
||||
{
|
||||
imsd::util::Rng rng(74);
|
||||
SmsOutbound m(c, rng, sub, "ims-sms-4", p);
|
||||
auto a = m.Start(0.0);
|
||||
const auto* first = findSms(a, SmsAction::Type::SendClient);
|
||||
if (!first) return 1;
|
||||
const std::string callid1 = callIdOf(first);
|
||||
const std::uint8_t afterFirst = m.NextRpMr();
|
||||
auto b = m.OnDeadline(128.5);
|
||||
const auto* again = findSms(b, SmsAction::Type::SendClient);
|
||||
Check(again && !hasSms(b, SmsAction::Type::State) && m.State() == SmsOutbound::Phase::Sending && m.Deadline() == 128.5 + SmsSendTimeout, "outbound: no final within 128 s: the segment goes out again, its own 128 s wait armed, no word to the bus");
|
||||
if (!again) return 1;
|
||||
const std::string callid2 = callIdOf(again);
|
||||
const auto rp1 = bodyRp(first->text), rp2 = bodyRp(again->text);
|
||||
Check(rp1 && rp2 && !callid2.empty() && callid2 != callid1 && rp1->mr == 20 && afterFirst == 21 && rp2->mr == 21 && m.NextRpMr() == 22 && again->text.starts_with("MESSAGE sip:+31653131313@ims.mnc001.mcc001.3gppnetwork.org;user=phone SIP/2.0\r\n"), "outbound: the repeat is a MESSAGE of its own to the SC's PSI: another Call-ID, the next RP-MR, and the counter goes on after it");
|
||||
Check(rp1 && rp2 && rp1->tpdu[0] == 0x11 && rp2->tpdu[0] == 0x15 && rp2->tpdu[1] == 10 && rp1->tpdu.size() == rp2->tpdu.size() && std::equal(rp1->tpdu.begin() + 1, rp1->tpdu.end(), rp2->tpdu.begin() + 1), "outbound: the repeat carries the same SMS-SUBMIT — TP-MR 10 — with TP-RD set and no other bit changed");
|
||||
Check(logged(a, std::format("sms ims-sms-4: segment 1/1 {}: MESSAGE sent (RP-MR 20, TP-MR 10, {} bytes)", toSc, rp1->tpdu.size())) && logged(b, "sms ims-sms-4: no answer to the MESSAGE of segment 1/1 within 128 s; sending the segment again, TP-RD set") && logged(b, std::format("sms ims-sms-4: segment 1/1 {}: MESSAGE sent again (RP-MR 21, TP-MR 10 with TP-RD, {} bytes)", toSc, rp2->tpdu.size())), "outbound: the journal's lines of a first attempt, of its end and of the repeat");
|
||||
Check(m.OwnsResponse(final(callid2, 202, "Accepted")) && !m.OwnsResponse(final(callid1, 202, "Accepted")) && m.CallId() == callid2, "outbound: the final in flight is the repeat's; the first attempt's late final is nobody's");
|
||||
Check(m.ReportAttempt(callid1, std::nullopt) == 0u && m.ReportAttempt(callid2, std::nullopt) == 1u && m.ReportAttempt(std::format("{}, {}", callid1, callid2), std::nullopt) == 1u && m.ReportAttempt("", 20) == 0u && m.ReportAttempt("", 21) == 1u && !m.ReportAttempt("", 22) && !m.ReportAttempt("x@y", 21), "outbound: a report is the first attempt's or the repeat's by In-Reply-To — the repeat's when it lists both — else by RP-MR");
|
||||
m.OnResponse(final(callid2, 202, "Accepted"), 202, 129.0);
|
||||
Check(m.State() == SmsOutbound::Phase::AwaitingReport && m.Deadline() == 129.0 + SmsReportTimeout, "outbound: the repeat's 202: its own 130 s wait for the report");
|
||||
auto d = m.OnReport(Rp{RpType::AckMt, 21, std::nullopt, *imsd::util::FromHex("010062016122050080"), std::nullopt, std::nullopt}, 130.0);
|
||||
const auto* st = findSms(d, SmsAction::Type::State);
|
||||
Check(st && st->state == "sent" && st->reason == "1 segment(s) accepted by the SC at 2026-10-16T22:50:00+02:00" && m.Done() && m.Deadline() == 0, "outbound: the repeat's RP-ACK ends the message as sent");
|
||||
}
|
||||
// the report's wait runs out and the repeat is rejected as a duplicate (TP-FCS 0xC5): taken for the first attempt accepted — sent
|
||||
{
|
||||
imsd::util::Rng rng(75);
|
||||
SmsOutbound m(c, rng, sub, "ims-sms-5", p);
|
||||
auto a = m.Start(0.0);
|
||||
const auto* first = findSms(a, SmsAction::Type::SendClient);
|
||||
const std::string callid1 = callIdOf(first);
|
||||
m.OnResponse(final(callid1, 202, "Accepted"), 202, 1.0);
|
||||
auto b = m.OnDeadline(131.5);
|
||||
const auto* again = findSms(b, SmsAction::Type::SendClient);
|
||||
const std::string callid2 = callIdOf(again);
|
||||
Check(!callid2.empty() && logged(b, "sms ims-sms-5: no submit report for segment 1/1 within 130 s of the final; sending the segment again, TP-RD set") && !hasSms(b, SmsAction::Type::State), "outbound: no submit report within 130 s: the segment goes out again");
|
||||
if (!first || !again) return 1;
|
||||
const auto rp1 = bodyRp(first->text), rp2 = bodyRp(again->text);
|
||||
Check(rp1 && rp2 && rp2->mr == 21 && rp1->tpdu[0] == 0x11 && rp2->tpdu[0] == 0x15 && rp1->tpdu.size() == rp2->tpdu.size() && std::equal(rp1->tpdu.begin() + 1, rp1->tpdu.end(), rp2->tpdu.begin() + 1), "outbound: after the report's wait too the repeat carries the same SMS-SUBMIT with TP-RD set and no other bit changed, under the next RP-MR");
|
||||
m.OnResponse(final(callid2, 202, "Accepted"), 202, 132.0);
|
||||
auto d = m.OnReport(duplicate, 133.0, 1);
|
||||
const auto* st = findSms(d, SmsAction::Type::State);
|
||||
Check(st && st->state == "sent" && st->reason == "1 segment(s) accepted by the SC" && m.Done() && logged(d, "sms ims-sms-5: segment 1/1: the repeat was rejected as a duplicate (RP cause 21 (short message transfer rejected), TP-FCS 0xc5 (duplicate short message rejected)): the first attempt is taken for accepted"), "outbound: the repeat rejected as a duplicate: the first attempt is taken for accepted, the message is sent");
|
||||
// the duplicate rejection is read before the RP cause: one that comes with cause 41 is the first attempt accepted, not the repeat refused for now
|
||||
{
|
||||
imsd::util::Rng rng41(175);
|
||||
SmsOutbound m41(c, rng41, sub, "ims-sms-5b", p);
|
||||
const std::string c1 = callIdOf(findSms(m41.Start(0.0), SmsAction::Type::SendClient));
|
||||
m41.OnResponse(final(c1, 202, "Accepted"), 202, 1.0);
|
||||
const std::string c2 = callIdOf(findSms(m41.OnDeadline(131.5), SmsAction::Type::SendClient));
|
||||
m41.OnResponse(final(c2, 202, "Accepted"), 202, 132.0);
|
||||
auto f = m41.OnReport(Rp{RpType::ErrorMt, 21, std::nullopt, duplicate.tpdu, 41, std::nullopt}, 133.0, 1);
|
||||
const auto* st41 = findSms(f, SmsAction::Type::State);
|
||||
Check(st41 && st41->state == "sent" && m41.Done(), "outbound: a duplicate rejection that comes with RP cause 41 is the first attempt accepted");
|
||||
}
|
||||
// the same RP-ERROR to a first attempt, which carried no TP-RD, is a refusal like any other
|
||||
imsd::util::Rng rng2(76);
|
||||
SmsOutbound m2(c, rng2, sub, "ims-sms-6", p);
|
||||
m2.Start(0.0);
|
||||
auto e = m2.OnReport(Rp{RpType::ErrorMt, 20, std::nullopt, duplicate.tpdu, 21, std::nullopt}, 1.0);
|
||||
st = findSms(e, SmsAction::Type::State);
|
||||
Check(st && st->state == "failed" && st->reason == "segment 1/1 refused by the SC: RP cause 21 (short message transfer rejected), TP-FCS 0xc5 (duplicate short message rejected)" && m2.Done() && !hasSms(e, SmsAction::Type::SendClient), "outbound: a duplicate rejection of a first attempt is a refusal like any other: with RP cause 21, failed");
|
||||
}
|
||||
// both attempts end without the SC's word: failed, the reason naming both ends
|
||||
{
|
||||
imsd::util::Rng rng(77);
|
||||
SmsOutbound m(c, rng, sub, "ims-sms-22", p);
|
||||
m.Start(0.0);
|
||||
auto a = m.OnDeadline();
|
||||
const auto* st = findSms(a, SmsAction::Type::State);
|
||||
Check(st && st->state == "failed" && st->reason.contains("no answer to the MESSAGE"), "outbound: no final within the wait fails it");
|
||||
imsd::util::Rng rng2(75);
|
||||
SmsOutbound m2(c, rng2, sub, "ims-sms-5", p);
|
||||
auto b = m2.Start(0.0);
|
||||
const std::string callid(imsd::sip::Header(findSms(b, SmsAction::Type::SendClient)->text, "Call-ID").value_or(""));
|
||||
m2.OnResponse(final(callid, 202, "Accepted"), 202, 1.0);
|
||||
auto d = m2.OnDeadline();
|
||||
st = findSms(d, SmsAction::Type::State);
|
||||
Check(st && st->state == "failed" && st->reason.contains("no submit report"), "outbound: no submit report within its wait fails it");
|
||||
imsd::util::Rng rng3(76);
|
||||
const std::string callid2 = callIdOf(findSms(m.OnDeadline(128.5), SmsAction::Type::SendClient));
|
||||
m.OnResponse(final(callid2, 202, "Accepted"), 202, 129.0);
|
||||
auto d = m.OnDeadline(259.5);
|
||||
const auto* st = findSms(d, SmsAction::Type::State);
|
||||
Check(st && st->state == "failed" && st->reason == "no submit report for segment 1/1 within 130 s of the final; the first attempt: no answer to the MESSAGE of segment 1/1 within 128 s" && m.Done() && m.Deadline() == 0 && !hasSms(d, SmsAction::Type::SendClient), "outbound: the repeat's wait run out too: failed, the reason has the repeat's end and the first attempt's");
|
||||
Check(m.OnDeadline(260.0).empty() && m.OnReport(temporary, 261.0).empty(), "outbound: an ended message takes no deadline and no report");
|
||||
}
|
||||
// the first attempt's RP-ACK after the repeat went out — named by In-Reply-To, or by its RP-MR: the SC has the segment
|
||||
for (bool byCallId : {true, false}) {
|
||||
imsd::util::Rng rng(78);
|
||||
SmsOutbound m(c, rng, sub, "ims-sms-23", p);
|
||||
const std::string callid1 = callIdOf(findSms(m.Start(0.0), SmsAction::Type::SendClient));
|
||||
m.OnResponse(final(callid1, 202, "Accepted"), 202, 1.0);
|
||||
m.OnDeadline(131.5);
|
||||
const auto attempt = m.ReportAttempt(byCallId ? callid1 : std::string(), 20);
|
||||
Check(attempt == 0u, "outbound: the report is the first attempt's");
|
||||
auto d = m.OnReport(Rp{RpType::AckMt, 20, std::nullopt, *imsd::util::FromHex("010062016122050080"), std::nullopt, std::nullopt}, 135.0, attempt);
|
||||
const auto* st = findSms(d, SmsAction::Type::State);
|
||||
Check(st && st->state == "sent" && st->reason == "1 segment(s) accepted by the SC at 2026-10-16T22:50:00+02:00" && m.Done() && logged(d, "sms ims-sms-23: segment 1/1: the first attempt's submit report came after the repeat went out: accepted"), std::format("outbound: the first attempt's RP-ACK after the repeat went out, taken by {}: sent", byCallId ? "In-Reply-To" : "RP-MR"));
|
||||
}
|
||||
// an RP-ERROR whose cause invites another attempt at once: the repeat; the same to the repeat: failed, both ends in the reason
|
||||
{
|
||||
imsd::util::Rng rng(79);
|
||||
SmsOutbound m(c, rng, sub, "ims-sms-24", p);
|
||||
const std::string callid1 = callIdOf(findSms(m.Start(0.0), SmsAction::Type::SendClient));
|
||||
m.OnResponse(final(callid1, 202, "Accepted"), 202, 1.0);
|
||||
auto b = m.OnReport(temporary, 2.0);
|
||||
const std::string callid2 = callIdOf(findSms(b, SmsAction::Type::SendClient));
|
||||
Check(!callid2.empty() && !hasSms(b, SmsAction::Type::State) && m.State() == SmsOutbound::Phase::Sending && m.Deadline() == 2.0 + SmsSendTimeout && logged(b, "sms ims-sms-24: segment 1/1 refused by the SC: RP cause 41 (temporary failure); sending the segment again, TP-RD set"), "outbound: an RP-ERROR with cause 41: the segment goes out again");
|
||||
auto d = m.OnReport(Rp{RpType::ErrorMt, 21, std::nullopt, {}, 41, std::nullopt}, 4.0); // no attempt named: the one in flight, the repeat
|
||||
const auto* st = findSms(d, SmsAction::Type::State);
|
||||
Check(st && st->state == "failed" && st->reason == "segment 1/1 refused by the SC: RP cause 41 (temporary failure); the first attempt: segment 1/1 refused by the SC: RP cause 41 (temporary failure)" && m.Done() && !hasSms(d, SmsAction::Type::SendClient), "outbound: cause 41 to the repeat fails the message, both ends in the reason");
|
||||
// causes 38, 42 and 47 are refusals: no repeat (TS 24.011 Annex E-2 has an immediate reattempt after 38 "not likely to be successful")
|
||||
for (std::uint8_t cause : {38, 42, 47}) {
|
||||
imsd::util::Rng rngN(79);
|
||||
SmsOutbound n(c, rngN, sub, "ims-sms-32", p);
|
||||
n.Start(0.0);
|
||||
auto e = n.OnReport(Rp{RpType::ErrorMt, 20, std::nullopt, {}, cause, std::nullopt}, 1.0);
|
||||
st = findSms(e, SmsAction::Type::State);
|
||||
Check(st && st->state == "failed" && n.Done() && !hasSms(e, SmsAction::Type::SendClient), std::format("outbound: an RP-ERROR with cause {} fails the message at once", cause));
|
||||
}
|
||||
// a value table 8.4's part 1 does not list is read as cause 41: the repeat follows
|
||||
for (std::uint8_t cause : {0, 2}) {
|
||||
imsd::util::Rng rngU(79);
|
||||
SmsOutbound u(c, rngU, sub, "ims-sms-33", p);
|
||||
u.Start(0.0);
|
||||
auto e = u.OnReport(Rp{RpType::ErrorMt, 20, std::nullopt, {}, cause, std::nullopt}, 1.0);
|
||||
Check(hasSms(e, SmsAction::Type::SendClient) && !hasSms(e, SmsAction::Type::State) && u.State() == SmsOutbound::Phase::Sending, std::format("outbound: an RP-ERROR with cause {}, which part 1 does not list, sends the segment again", cause));
|
||||
}
|
||||
}
|
||||
// a duplicate rejection of the repeat after an RP-ERROR has refused the first attempt is a refusal: the first attempt is not what the service centre has
|
||||
{
|
||||
imsd::util::Rng rng(87);
|
||||
SmsOutbound m(c, rng, sub, "ims-sms-33", p);
|
||||
const std::string callid1 = callIdOf(findSms(m.Start(0.0), SmsAction::Type::SendClient));
|
||||
m.OnResponse(final(callid1, 202, "Accepted"), 202, 1.0);
|
||||
const std::string callid2 = callIdOf(findSms(m.OnReport(temporary, 2.0), SmsAction::Type::SendClient));
|
||||
m.OnResponse(final(callid2, 202, "Accepted"), 202, 3.0);
|
||||
auto d = m.OnReport(duplicate, 4.0, 1);
|
||||
const auto* st = findSms(d, SmsAction::Type::State);
|
||||
Check(st && st->state == "failed" && st->reason == "segment 1/1 refused by the SC: RP cause 21 (short message transfer rejected), TP-FCS 0xc5 (duplicate short message rejected); the first attempt: segment 1/1 refused by the SC: RP cause 41 (temporary failure)" && m.Done() && !hasSms(d, SmsAction::Type::SendClient), "outbound: the repeat rejected as a duplicate after the first attempt's RP-ERROR: failed, both refusals in the reason");
|
||||
}
|
||||
// an RP-ERROR to the first attempt after its repeat went out, whatever its cause: the repeat's answer ends the segment
|
||||
for (std::uint8_t cause : {41, 28}) {
|
||||
const Rp refusal = cause == 41 ? temporary : permanent;
|
||||
const std::string words = cause == 41 ? "RP cause 41 (temporary failure)" : "RP cause 28 (unidentified subscriber), TP-FCS 0xc3 (invalid SME address)";
|
||||
auto repeated = [&](SmsOutbound& m) {
|
||||
m.Start(0.0);
|
||||
const std::string callid2 = callIdOf(findSms(m.OnDeadline(128.5), SmsAction::Type::SendClient));
|
||||
auto late = m.OnReport(refusal, 129.0, 0);
|
||||
Check(late.size() == 1 && logged(late, std::format("sms {}: segment 1/1 refused by the SC: {}, in the first attempt's report, which came after the repeat went out: the repeat's decides", m.Id(), words)) && m.State() == SmsOutbound::Phase::Sending && m.CallId() == callid2 && m.Deadline() == 128.5 + SmsSendTimeout, std::format("outbound: an RP-ERROR with cause {} to the first attempt after the repeat went out is logged and leaves the repeat in flight", cause));
|
||||
return callid2;
|
||||
};
|
||||
// the repeat accepted: sent
|
||||
imsd::util::Rng rng(88);
|
||||
SmsOutbound m(c, rng, sub, "ims-sms-34", p);
|
||||
repeated(m);
|
||||
auto d = m.OnReport(Rp{RpType::AckMt, 21, std::nullopt, {}, std::nullopt, std::nullopt}, 130.0);
|
||||
const auto* st = findSms(d, SmsAction::Type::State);
|
||||
Check(st && st->state == "sent" && m.Done(), std::format("outbound: the repeat's RP-ACK after the first attempt's late RP-ERROR (cause {}): sent", cause));
|
||||
// the repeat's own wait run out: failed, the first attempt's refusal in the reason
|
||||
imsd::util::Rng rng2(89);
|
||||
SmsOutbound m2(c, rng2, sub, "ims-sms-35", p);
|
||||
repeated(m2);
|
||||
auto e = m2.OnDeadline(257.0);
|
||||
st = findSms(e, SmsAction::Type::State);
|
||||
Check(st && st->state == "failed" && st->reason == std::format("no answer to the MESSAGE of segment 1/1 within 128 s; the first attempt: segment 1/1 refused by the SC: {}, in a report that came after the repeat went out", words) && m2.Done(), std::format("outbound: the repeat unanswered after the first attempt's late RP-ERROR (cause {}): failed, that refusal as the first attempt's end", cause));
|
||||
// the repeat rejected as a duplicate: the first attempt has been refused, so a refusal
|
||||
imsd::util::Rng rng3(90);
|
||||
SmsOutbound m3(c, rng3, sub, "ims-sms-36", p);
|
||||
repeated(m3);
|
||||
auto f = m3.OnReport(duplicate, 130.0, 1);
|
||||
st = findSms(f, SmsAction::Type::State);
|
||||
Check(st && st->state == "failed" && st->reason == std::format("segment 1/1 refused by the SC: RP cause 21 (short message transfer rejected), TP-FCS 0xc5 (duplicate short message rejected); the first attempt: segment 1/1 refused by the SC: {}, in a report that came after the repeat went out", words) && m3.Done(), std::format("outbound: the repeat rejected as a duplicate after the first attempt's late RP-ERROR (cause {}): failed", cause));
|
||||
}
|
||||
// a first attempt's RP-ERROR is forgotten with its segment: the next segment's repeat, rejected as a duplicate, is accepted
|
||||
{
|
||||
imsd::util::Rng rng(91);
|
||||
SmsOutbound::Params two = p; two.text = std::string(200, 'x');
|
||||
SmsOutbound m(c, rng, sub, "ims-sms-37", two);
|
||||
m.Start(0.0);
|
||||
m.OnReport(temporary, 1.0); // segment 1: refused, sent again
|
||||
auto b = m.OnReport(Rp{RpType::AckMt, 21, std::nullopt, {}, std::nullopt, std::nullopt}, 2.0); // its repeat accepted: segment 2 goes out
|
||||
Check(hasSms(b, SmsAction::Type::SendClient) && !hasSms(b, SmsAction::Type::State) && m.ReportAttempt("", 22) == 0u, "outbound: the first segment accepted through its repeat, the second in flight");
|
||||
m.OnDeadline(130.5); // segment 2: no final, sent again
|
||||
auto d = m.OnReport(Rp{RpType::ErrorMt, 23, std::nullopt, duplicate.tpdu, 21, std::nullopt}, 131.0, 1);
|
||||
const auto* st = findSms(d, SmsAction::Type::State);
|
||||
Check(st && st->state == "sent" && st->reason == "2 segment(s) accepted by the SC" && m.Done(), "outbound: the second segment's repeat rejected as a duplicate is accepted: the first segment's RP-ERROR does not weigh on it");
|
||||
}
|
||||
// a final of 408 or 504 leaves the MESSAGE's fate as open as no final: the repeat; any other refusal fails at once
|
||||
for (int code : {408, 504, 403, 480, 500, 503}) {
|
||||
imsd::util::Rng rng(81);
|
||||
SmsOutbound m(c, rng, sub, "ims-sms-26", p);
|
||||
const std::string callid1 = callIdOf(findSms(m.Start(0.0), SmsAction::Type::SendClient));
|
||||
auto b = m.OnResponse(final(callid1, code, "Refused"), code, 1.0);
|
||||
const auto* st = findSms(b, SmsAction::Type::State);
|
||||
if (code == 408 || code == 504)
|
||||
Check(!st && hasSms(b, SmsAction::Type::SendClient) && m.State() == SmsOutbound::Phase::Sending && m.Deadline() == 1.0 + SmsSendTimeout && logged(b, std::format("sms ims-sms-26: segment 1/1 refused: {} Refused; sending the segment again, TP-RD set", code)), std::format("outbound: a {} final: the segment goes out again", code));
|
||||
else
|
||||
Check(st && st->state == "failed" && st->reason == std::format("segment 1/1 refused: {} Refused", code) && m.Done() && !hasSms(b, SmsAction::Type::SendClient), std::format("outbound: a {} final fails the message at once", code));
|
||||
}
|
||||
// the repeat's own 408: failed; and a repeat the flow could not send
|
||||
{
|
||||
imsd::util::Rng rng(82);
|
||||
SmsOutbound m(c, rng, sub, "ims-sms-27", p);
|
||||
m.Start(0.0);
|
||||
const std::string callid2 = callIdOf(findSms(m.OnDeadline(128.5), SmsAction::Type::SendClient));
|
||||
auto b = m.OnResponse(final(callid2, 408, "Request Timeout"), 408, 136.0);
|
||||
const auto* st = findSms(b, SmsAction::Type::State);
|
||||
Check(st && st->state == "failed" && st->reason == "segment 1/1 refused: 408 Request Timeout; the first attempt: no answer to the MESSAGE of segment 1/1 within 128 s" && !hasSms(b, SmsAction::Type::SendClient), "outbound: the repeat's own 408 fails the message: a segment goes out twice at most");
|
||||
imsd::util::Rng rng2(83);
|
||||
SmsOutbound m2(c, rng2, sub, "ims-sms-28", p);
|
||||
m2.Start(0.0);
|
||||
m2.OnDeadline(128.5);
|
||||
auto e = m2.OnSendFailed();
|
||||
st = findSms(e, SmsAction::Type::State);
|
||||
Check(st && st->state == "failed" && st->reason == "segment 1/1 not sent: the flow to the P-CSCF is down; the first attempt: no answer to the MESSAGE of segment 1/1 within 128 s" && m2.Done() && m2.Deadline() == 0, "outbound: a repeat the flow could not send fails the message");
|
||||
imsd::util::Rng rng3(84);
|
||||
SmsOutbound m3(c, rng3, sub, "ims-sms-6", p);
|
||||
m3.Start(0.0);
|
||||
auto e = m3.OnSendFailed();
|
||||
auto f = m3.OnSendFailed();
|
||||
st = findSms(f, SmsAction::Type::State);
|
||||
Check(st && st->state == "failed" && st->reason == "segment 1/1 not sent: the flow to the P-CSCF is down", "outbound: a failed send fails it");
|
||||
}
|
||||
// two segments, each sent again once: the four MESSAGEs take the RP-MRs in the order they go out; the second segment starts without TP-RD
|
||||
{
|
||||
imsd::util::Rng rng(85);
|
||||
SmsOutbound::Params two = p; two.text = std::string(200, 'x');
|
||||
SmsOutbound m(c, rng, sub, "ims-sms-29", two);
|
||||
const auto s1 = bodyRp(findSms(m.Start(0.0), SmsAction::Type::SendClient)->text);
|
||||
const auto s1again = bodyRp(findSms(m.OnDeadline(128.5), SmsAction::Type::SendClient)->text);
|
||||
auto b = m.OnReport(duplicate, 129.0, 1);
|
||||
const auto* seg2 = findSms(b, SmsAction::Type::SendClient);
|
||||
if (!seg2) return 1;
|
||||
const auto s2 = bodyRp(seg2->text);
|
||||
auto b2 = m.OnDeadline(257.5);
|
||||
const auto* seg2again = findSms(b2, SmsAction::Type::SendClient);
|
||||
Check(seg2again != nullptr, "outbound: the second segment starts as a first attempt and is sent again in its turn");
|
||||
if (!seg2again) return 1;
|
||||
const auto s2again = bodyRp(seg2again->text);
|
||||
Check(s1 && s1again && s2 && s2again && s1->mr == 20 && s1again->mr == 21 && s2->mr == 22 && s2again->mr == 23 && m.NextRpMr() == 24, "outbound: of two segments each sent again, the four MESSAGEs take RP-MR 20 to 23 as they go out, and the counter goes on at 24");
|
||||
Check(s1->tpdu[1] == 10 && s1again->tpdu[1] == 10 && s2->tpdu[1] == 11 && s2again->tpdu[1] == 11 && !(s1->tpdu[0] & 0x04) && (s1again->tpdu[0] & 0x04) && !(s2->tpdu[0] & 0x04) && (s2again->tpdu[0] & 0x04) && (s2again->tpdu[0] & 0x40), "outbound: each repeat has its segment's TP-MR and TP-RD; the second segment's first attempt has no TP-RD");
|
||||
Check(!hasSms(b, SmsAction::Type::State) && m.ReportAttempt("", 22) == 0u && m.ReportAttempt("", 23) == 1u && !m.ReportAttempt("", 20) && !m.ReportAttempt("", 21), "outbound: the first segment's RP-MRs are no longer the message's once the second is in flight");
|
||||
// an attempt number past the segment's latest is taken for the latest: the duplicate rejection still counts for the repeat
|
||||
auto d = m.OnReport(Rp{RpType::ErrorMt, 23, std::nullopt, duplicate.tpdu, 21, std::nullopt}, 258.0, 7);
|
||||
const auto* st = findSms(d, SmsAction::Type::State);
|
||||
Check(st && st->state == "sent" && st->reason == "2 segment(s) accepted by the SC" && m.Done(), "outbound: both segments accepted through their repeats: sent");
|
||||
// and with one attempt made, such a number is the first attempt's: no duplicate rule
|
||||
imsd::util::Rng rng2(86);
|
||||
SmsOutbound m2(c, rng2, sub, "ims-sms-31", p);
|
||||
m2.Start(0.0);
|
||||
auto e = m2.OnReport(Rp{RpType::ErrorMt, 20, std::nullopt, duplicate.tpdu, 21, std::nullopt}, 1.0, 7);
|
||||
st = findSms(e, SmsAction::Type::State);
|
||||
Check(st && st->state == "failed" && st->reason.contains("flow to the P-CSCF is down"), "outbound: a failed send fails it");
|
||||
Check(st && st->state == "failed" && m2.Done(), "outbound: a report numbered past the only attempt is that attempt's");
|
||||
}
|
||||
// two segments: the second goes after the first's RP-ACK, with the next RP-MR and TP-MR
|
||||
{
|
||||
|
|
@ -1424,7 +1657,7 @@ int main() {
|
|||
Check(callid2 != callid, "outbound: a Call-ID of its own per segment");
|
||||
auto rp = bodyRp(second->text);
|
||||
Check(rp && rp->mr == 21 && rp->tpdu[1] == 11 && (rp->tpdu[0] & 0x40), "outbound: segment 2 has RP-MR 21, TP-MR 11 and a user-data header");
|
||||
Check(m.OwnsReport("", 21) && !m.OwnsReport("", 20), "outbound: the report in flight is the second segment's");
|
||||
Check(m.ReportAttempt("", 21) && !m.ReportAttempt("", 20), "outbound: the report in flight is the second segment's");
|
||||
m.OnResponse(final(callid2, 202, "Accepted"), 202, 3.0);
|
||||
auto d = m.OnReport(Rp{RpType::AckMt, 21, std::nullopt, {}, std::nullopt, std::nullopt}, 4.0);
|
||||
const auto* st = findSms(d, SmsAction::Type::State);
|
||||
|
|
@ -1438,7 +1671,7 @@ int main() {
|
|||
SmsOutbound m(c, rng, sub, "ims-sms-8", bad);
|
||||
auto a = m.Start(0.0);
|
||||
const auto* st = findSms(a, SmsAction::Type::State);
|
||||
Check(st && st->state == "failed" && st->reason == "'nobody' is not a number" && m.Done() && !hasSms(a, SmsAction::Type::SendClient), "outbound: a destination that is no number fails at once");
|
||||
Check(st && st->state == "failed" && st->reason == "'nobody' is not a number" && m.Done() && !hasSms(a, SmsAction::Type::SendClient) && m.NextRpMr() == 20, "outbound: a destination that is no number fails at once, no RP-MR taken");
|
||||
SmsOutbound::Params longNumber = p;
|
||||
longNumber.number = "+" + std::string(21, '3');
|
||||
imsd::util::Rng rngL(80);
|
||||
|
|
@ -1509,7 +1742,7 @@ int main() {
|
|||
Check(e.post.size() == 1 && e.post[0].state == "sent" && !e.forget, "order: sent with nothing held");
|
||||
order.Report("ims-sms-4", SmsStateDeliveryPending, "congestion", true);
|
||||
order.Report("ims-sms-4", SmsStateDelivered, "received by the SME", true);
|
||||
e = order.Submission("ims-sms-4", SmsStateFailed, "no submit report for segment 2/2 within 40 s of the final");
|
||||
e = order.Submission("ims-sms-4", SmsStateFailed, "no submit report for segment 2/2 within 130 s of the final");
|
||||
Check(e.post.size() == 2 && e.post[0].state == "sent" && e.post[0].reason.starts_with("every segment reported delivered by the SC; no submit report") && e.post[1].state == "delivered" && e.post[1].reason == "received by the SME" && !e.forget, "order: a failed after every segment was reported delivered is sent and delivered (the latest held word counts)");
|
||||
order.Report("ims-sms-5", SmsStateDeliveryPending, "congestion", true);
|
||||
e = order.Submission("ims-sms-5", SmsStateFailed, "segment 2/2 refused by the SC: RP cause 38");
|
||||
|
|
@ -1693,7 +1926,7 @@ int main() {
|
|||
SmsOutbound m(c, rng, sub, "ims-sms-11", p);
|
||||
auto a = m.Start(0.0);
|
||||
const std::string callid(imsd::sip::Header(findSms(a, SmsAction::Type::SendClient)->text, "Call-ID").value_or(""));
|
||||
Check(m.State() == SmsOutbound::Phase::Sending && m.OwnsReport(callid, std::nullopt), "outbound: a report is owned while the MESSAGE's final is still due");
|
||||
Check(m.State() == SmsOutbound::Phase::Sending && m.ReportAttempt(callid, std::nullopt), "outbound: a report is owned while the MESSAGE's final is still due");
|
||||
auto r = OnSmsMessage(c, rng, inbound("0314", std::format("In-Reply-To: {}\r\n", callid)), re, &m, sub, 1.0);
|
||||
const auto* st = findSms(r.actions, SmsAction::Type::State);
|
||||
Check(r.response.starts_with("SIP/2.0 200 OK") && st && st->state == "sent" && m.Done() && !m.OwnsResponse(final(callid, 202, "Accepted")), "outbound: the early RP-ACK ends the message as sent; the late 202 is nobody's");
|
||||
|
|
@ -1752,6 +1985,22 @@ int main() {
|
|||
const auto* st = findSms(r.actions, SmsAction::Type::State);
|
||||
Check(r.response.starts_with("SIP/2.0 200 OK") && st && st->state == "sent" && m.Done() && r.reportCallId.empty(), "inbound: a submit report without In-Reply-To reaches the message in flight by RP-MR");
|
||||
}
|
||||
// submit reports while a segment's repeat is in flight, through OnSmsMessage: the first attempt's RP-ACK is taken by its In-Reply-To; then the repeat's own report finds the message ended and is ours on record
|
||||
{
|
||||
imsd::util::Rng rng(94);
|
||||
Reassembler re;
|
||||
SmsOutbound m(c, rng, sub, "ims-sms-30", p);
|
||||
const std::string callid1(imsd::sip::Header(findSms(m.Start(0.0), SmsAction::Type::SendClient)->text, "Call-ID").value_or(""));
|
||||
m.OnResponse(final(callid1, 202, "Accepted"), 202, 1.0);
|
||||
auto again = m.OnDeadline(131.5);
|
||||
const std::string callid2(imsd::sip::Header(findSms(again, SmsAction::Type::SendClient)->text, "Call-ID").value_or(""));
|
||||
auto r = OnSmsMessage(c, rng, inbound("0314", std::format("In-Reply-To: {}\r\n", callid1)), re, &m, sub, 135.0);
|
||||
const auto* st = findSms(r.actions, SmsAction::Type::State);
|
||||
Check(r.response.starts_with("SIP/2.0 200 OK\r\n") && st && st->state == "sent" && m.Done(), "inbound: the first attempt's RP-ACK, come while the repeat is in flight, ends the message as sent");
|
||||
auto r2 = OnSmsMessage(c, rng, inbound("05150115410A01C50062016122050080", std::format("In-Reply-To: {}\r\n", callid2)), re, nullptr, sub, 136.0);
|
||||
const auto* l2 = findSms(r2.actions, SmsAction::Type::Log);
|
||||
Check(r2.response.starts_with("SIP/2.0 200 OK\r\n") && r2.actions.size() == 1 && l2 && l2->text == std::format("submit report (RP-ERROR, RP cause 21 (short message transfer rejected), TP-FCS 0xc5 (duplicate short message rejected)) In-Reply-To {}: sms ims-sms-30's segment 1/1, no longer in flight; 200", callid2), "inbound: the repeat's duplicate rejection after the message ended: 200 and its line");
|
||||
}
|
||||
// a submit report for the message in flight; one for nobody
|
||||
{
|
||||
imsd::util::Rng rng(83);
|
||||
|
|
@ -1774,10 +2023,21 @@ int main() {
|
|||
auto a3 = m3.Start(10.0);
|
||||
const std::string callid3(imsd::sip::Header(findSms(a3, SmsAction::Type::SendClient)->text, "Call-ID").value_or(""));
|
||||
m3.OnResponse(final(callid3, 202, "Accepted"), 202, 11.0);
|
||||
m3.OnDeadline();
|
||||
auto r5 = OnSmsMessage(c, rng, inbound("05140126410A01C30062016122050080", std::format("In-Reply-To: {}\r\n", callid3)), re, &m3, sub, 60.0);
|
||||
m3.OnDeadline(141.5); // the segment goes out again
|
||||
m3.OnDeadline(270.0); // and the repeat gets no final
|
||||
auto r5 = OnSmsMessage(c, rng, inbound("05140126410A01C30062016122050080", std::format("In-Reply-To: {}\r\n", callid3)), re, &m3, sub, 276.0);
|
||||
const auto* l5 = findSms(r5.actions, SmsAction::Type::Log);
|
||||
Check(m3.Done() && r5.response.starts_with("SIP/2.0 200 OK\r\n") && r5.actions.size() == 1 && l5 && l5->text == std::format("submit report (RP-ERROR, RP cause 38 (network out of order), TP-FCS 0xc3 (invalid SME address)) In-Reply-To {}: sms ims-sms-13's segment 1/1, no longer in flight; 200", callid3), "inbound: an RP-ERROR for our own MESSAGE after its wait ended the message: 200, its cause and TP-FCS in the line");
|
||||
Check(m3.Done() && r5.response.starts_with("SIP/2.0 200 OK\r\n") && r5.actions.size() == 1 && l5 && l5->text == std::format("submit report (RP-ERROR, RP cause 38 (network out of order), TP-FCS 0xc3 (invalid SME address)) In-Reply-To {}: sms ims-sms-13's segment 1/1, no longer in flight; 200", callid3), "inbound: an RP-ERROR for our own MESSAGE after both attempts' waits ended the message: 200, its cause and TP-FCS in the line");
|
||||
// a repeat rejected as a duplicate ends the message as sent; the first attempt's RP-ERROR, come after that, finds it no longer in flight: 200 and its line, `sent` stands
|
||||
SmsOutbound m4(c, rng, sub, "ims-sms-14", p);
|
||||
const std::string callid4(imsd::sip::Header(findSms(m4.Start(300.0), SmsAction::Type::SendClient)->text, "Call-ID").value_or(""));
|
||||
m4.OnResponse(final(callid4, 202, "Accepted"), 202, 301.0);
|
||||
const std::string repeat4(imsd::sip::Header(findSms(m4.OnDeadline(431.5), SmsAction::Type::SendClient)->text, "Call-ID").value_or(""));
|
||||
auto dup4 = OnSmsMessage(c, rng, inbound("05150115410A01C50062016122050080", std::format("In-Reply-To: {}\r\n", repeat4)), re, &m4, sub, 432.0);
|
||||
const auto* st4 = findSms(dup4.actions, SmsAction::Type::State);
|
||||
auto r6 = OnSmsMessage(c, rng, inbound("0514011C410A01C30062016122050080", std::format("In-Reply-To: {}\r\n", callid4)), re, &m4, sub, 433.0);
|
||||
const auto* l6 = findSms(r6.actions, SmsAction::Type::Log);
|
||||
Check(st4 && st4->state == "sent" && m4.Done() && r6.response.starts_with("SIP/2.0 200 OK\r\n") && r6.actions.size() == 1 && l6 && l6->text == std::format("submit report (RP-ERROR, RP cause 28 (unidentified subscriber), TP-FCS 0xc3 (invalid SME address)) In-Reply-To {}: sms ims-sms-14's segment 1/1, no longer in flight; 200", callid4), "inbound: the first attempt's RP-ERROR after its repeat was rejected as a duplicate: the message stays sent, 200 and the refusal's line");
|
||||
auto r3 = OnSmsMessage(c, rng, inbound("0314"), re, nullptr, sub, 4.0);
|
||||
Check(r3.response.starts_with("SIP/2.0 200 OK") && hasSms(r3.actions, SmsAction::Type::Log) && !hasSms(r3.actions, SmsAction::Type::SendClient), "inbound: a report without In-Reply-To for no message: 200 and the log");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,8 +9,10 @@
|
|||
// you?" PDU and vectors cross-generated by the fp6 journal's Python
|
||||
// reference: a header with fill bits, a 16-bit concatenation reference, a
|
||||
// class-0 message, port-addressed 8-bit data, an alphanumeric sender, a
|
||||
// negative time zone), SMS-STATUS-REPORT and SMS-SUBMIT-REPORT, the
|
||||
// RP-DATA / RP-ACK / RP-ERROR messages both ways, EF_SMSP with the KPN
|
||||
// negative time zone), SMS-STATUS-REPORT and SMS-SUBMIT-REPORT (the
|
||||
// duplicate rejection's TP-FCS among its causes), the
|
||||
// RP-DATA / RP-ACK / RP-ERROR messages both ways, which RP causes of a
|
||||
// submission invite a repeat, EF_SMSP with the KPN
|
||||
// SIM's record, qmicli's hex dump, and the reassembly of a concatenated
|
||||
// message.
|
||||
import std;
|
||||
|
|
@ -136,6 +138,12 @@ namespace {
|
|||
Check(to.size() == 1, "SUBMIT with a status report requested: one segment");
|
||||
if (!to.empty()) Eq(to[0], "31010A9113163254760000A902C834", "SMS-SUBMIT: status report requested, TP-VP A9, an even number of digits");
|
||||
|
||||
Submit r = o;
|
||||
r.rejectDuplicates = true;
|
||||
auto tr = BuildSubmits(r, "Hi", 0);
|
||||
Check(tr.size() == 1, "SUBMIT with TP-RD: one segment");
|
||||
if (!tr.empty()) Eq(tr[0], "35010A9113163254760000A902C834", "SMS-SUBMIT with TP-RD: bit 2 of the first octet set, the rest as without it");
|
||||
|
||||
Submit c{"+31612345678", 10};
|
||||
std::string longText(153, 'A');
|
||||
longText += std::string(8, 'B');
|
||||
|
|
@ -145,6 +153,12 @@ namespace {
|
|||
Eq(tc[0], "410A0B911316325476F80000A00500032A020182C16030180C0683C16030180C0683C16030180C0683C16030180C0683C16030180C0683C16030180C0683C16030180C0683C16030180C0683C16030180C0683C16030180C0683C16030180C0683C16030180C0683C16030180C0683C16030180C0683C16030180C0683C16030180C0683C16030180C0683C16030180C0683C16030180C0683", "segment 1/2: UDHI, the concatenation header, 153 septets after one fill bit, TP-MR 10");
|
||||
Eq(tc[1], "410B0B911316325476F800000F0500032A02028442A15028140A01", "segment 2/2: TP-MR 11, 8 septets");
|
||||
}
|
||||
auto tw = BuildSubmits(c, Rep("ü", 70) + "❤", 0x2A);
|
||||
Check(tw.size() == 2, "71 UCS-2 characters: two segments");
|
||||
if (tw.size() == 2) {
|
||||
Eq(tw[0], "410A0B911316325476F800088C0500032A0201" + Rep("00FC", 67), "UCS-2 segment 1/2: TP-MR 10, the header and 67 characters in 140 octets");
|
||||
Eq(tw[1], "410B0B911316325476F800080E0500032A020200FC00FC00FC2764", "UCS-2 segment 2/2: TP-MR 11, the header and four characters");
|
||||
}
|
||||
Check(BuildSubmits(c, std::string(160, 'A'), 1).size() == 1, "160 characters fit one message");
|
||||
Check(BuildSubmits(c, std::string(161, 'A'), 1).size() == 2, "161 characters need two");
|
||||
Check(BuildSubmits(c, Rep("ü", 70) + "❤", 1).size() == 2, "71 UCS-2 characters need two");
|
||||
|
|
@ -293,6 +307,8 @@ namespace {
|
|||
Check(udhi && udhi->failureCause == 0xC3, "TP-UDHI (bit 6) is no unused bit: the cause as sent");
|
||||
EqS(ScTimeStamp(Hex("621AF12205A0A0")), "2026-01-10T22:50:00+00:00", "SCTS: a semi-octet that is no digit reads as 0, in the zone too (9.2.3.11)");
|
||||
EqS(FailureCauseText(0xC3), "invalid SME address", "TP-FCS C3");
|
||||
Check(FcsDuplicateRejected == 0xC5, "TP-FCS C5 is the duplicate rejection (9.2.3.22)");
|
||||
EqS(FailureCauseText(FcsDuplicateRejected), "duplicate short message rejected", "TP-FCS C5 in words");
|
||||
Eq(DeliverReportAck(), "0000", "SMS-DELIVER-REPORT for RP-ACK");
|
||||
Eq(DeliverReportError(0xFF), "00FF00", "SMS-DELIVER-REPORT for RP-ERROR");
|
||||
}
|
||||
|
|
@ -317,6 +333,15 @@ namespace {
|
|||
auto errMt = ParseRp(Hex("052A011C410A01C30062016122050080"));
|
||||
Check(errMt && errMt->type == RpType::ErrorMt && errMt->cause == 28 && !errMt->diagnostic && errMt->tpdu.size() == 10, "RP-ERROR network to MS with a submit report");
|
||||
EqS(RpCauseText(28), "unidentified subscriber", "RP cause 28");
|
||||
// a submission's RP-ERROR invites another attempt at once for cause 41 (TS 24.011 Annex E-2) and for a value table 8.4's part 1 does not list (treated as 41)
|
||||
{
|
||||
const std::set<int> listed{1, 8, 10, 11, 21, 27, 28, 29, 30, 38, 41, 42, 47, 50, 69, 81, 95, 96, 97, 98, 99, 111, 127};
|
||||
bool asTabled = true;
|
||||
for (int cause = 0; cause < 128; cause++)
|
||||
if (RpCauseIsTemporary(static_cast<std::uint8_t>(cause)) != (cause == 41 || !listed.contains(cause))) asTabled = false;
|
||||
Check(asTabled && listed.size() == 23, "RpCauseIsTemporary over the 128 cause values: 41, and whatever part 1's 23 do not list");
|
||||
Check(RpCauseIsTemporary(41) && RpCauseIsTemporary(0x80 | 41) && !RpCauseIsTemporary(28) && !RpCauseIsTemporary(0x80 | 28) && RpCauseIsTemporary(2) && !RpCauseIsTemporary(11), "RpCauseIsTemporary: the extension bit is no part of the value; an unlisted 2 invites a repeat, the reserved 11 is listed");
|
||||
}
|
||||
auto diag = ParseRp(Hex("0507022611"));
|
||||
Check(diag && diag->cause == 38 && diag->diagnostic == 0x11 && diag->tpdu.empty(), "RP-ERROR with a diagnostic octet");
|
||||
Check(!ParseRp(Hex("05")), "one byte: nothing");
|
||||
|
|
|
|||
Loading…
Reference in a new issue