Jump to content

IP Configuration Packet: Difference between revisions

From Transight Wiki
No edit summary
No edit summary
 
(16 intermediate revisions by the same user not shown)
Line 1: Line 1:
{| class="wikitable"
{| class="wikitable"
! style="background-color:#800020; color:white;" | Field
! style="background-color:#680022; color:white;" | Field
! style="background-color:#800020; color:white;" | Size (bits)
! style="background-color:#680022; color:white;" | Size (bits)
! style="background-color:#800020; color:white;" | Bit Range
! style="background-color:#680022; color:white;" | Bit Range
! style="background-color:#800020; color:white;" | Description
! style="background-color:#680022; color:white;" | Description
! style="background-color:#800020; color:white;" | Breakdown
! style="background-color:#680022; color:white;" | Breakdown
|-
|-
! colspan="5" style="background:#D3D3D3;" | Header (10 bytes)
! colspan="5" style="background:#D3D3D3;" | Header (10 bytes)
Line 42: Line 42:
| 75 - 79
| 75 - 79
| Type of packet
| Type of packet
| 02 - OTA Packet
| 05 - IP Configuration Packet
|-
|-
! colspan="5" style="background:#D3D3D3;" | Data
! colspan="5" style="background:#D3D3D3;" | Data
Line 48: Line 48:
| Time
| Time
| 32
| 32
|  
| 80-111
| UTC Timestamp
| UTC Timestamp
| UTC time in seconds
| UTC time in seconds
Line 55: Line 55:
| Time Zone
| Time Zone
| 8
| 8
|  
| 112-119
| Timezone in quarter-hours
| Timezone in quarter-hours
| 22 = +5:30; each unit = 15 min; ranges -48 to 56
| 22 = +5:30; each unit = 15 min; ranges -48 to 56
Line 62: Line 62:
| IP index
| IP index
| 3
| 3
|  
| 120-122
| IP type index
| IP type index
| 0: Transight IP, 1: Customer IP
| 1: Customer IP


|-
|-
| Status
| Status
| 1
| 1
|  
| 123
| OTA status
| IP status
| 0 - Disabled, 1 - Enabled
| 0 - Disabled, 1 - Enabled
|-
|-
| FS mode
| FS mode
| 1
| 1
|  
| 124
| Fuel Sensor mode
| File  System mode
| 0 - FIFO, 1 - LIFO
| 0 - FIFO, 1 - LIFO
|-
|-
| Protocol
| Protocol
| 3
| 3
|  
| 125-127
| Communication protocol
| Communication protocol
| 0 - HTTP, 1 - HTTPS, 2 - TCP, 3 - MQTT
| 0 - HTTP, 1 - HTTPS, 2 - TCP
|-
|-
| Update rate (motion/Ign On)
| Update rate (motion)
| 16
| 16
|  
| 128-143
| Reporting interval while in motion
| Reporting interval while in motion
| In seconds
| In seconds
|-
|-
| Update rate (halt/Ign Off)
| Update rate (halt)
| 16
| 16
|  
| 144-159
| Reporting interval during halt
| Reporting interval during halt
| In seconds
| In Minutes
|-
|-
| Update rate (Sleep)
| Update rate (Sleep)
| 16
| 16
|  
| 160-175
| Sleep mode reporting interval
| Sleep mode reporting interval
| In seconds
| In Minutes
|-
|-
| URL length
| URL length
| 8
| 8
|  
| 176-183
| Length of URL field
| Length of URL field
| In number of bytes
| In number of bytes
Line 111: Line 111:
| URL
| URL
| Varies
| Varies
|  
| 184 (184+N*8-1)
| URL data
| URL data
| Length given by URL length
| Length given by URL length
Line 130: Line 130:
|}
|}
<pre>
<pre>
{
{ "HEX : 2401f0e21aeb7abfd58568abeb09163a000a000100011231332e3233322e31332e3233333a363038342a7d"  "imei": 862942074896044, "packet_type": 5, "no_packets": 1, "dateTime": 1756097289, "timezone": 22, "dateTime_tz": "2025-08-25 10:18:09", "ip_index": 1, "status": 1, "fs_mode": 1, "protocol": 2, "up_rate_ig_on": 10, "up_rate_ig_off": 1, "up_rate_sleep": 1, "url_length": 18, "url": "13.232.13.233:6084", "error_code": 0}
  "HEX": "2401e0e1cabd09208ca56822dde716320005000100028831352e3233352e392e36363a35303333372a82",
</pre>
  "dateTime": 1747115495,
 
  "dateTime_tz": "2025-05-13 11:21:35.000",
 
  "fsMode": 0,
 
  "imei": 860187062240357,
<html lang="en">
  "insert_time": "Tue, 13 May 2025 05:51:37 GMT",
<head>
  "ipIndex": 1,
   <meta charset="UTF-8">
  "packetType": 5,
  <style>
  "protocol": 2,
    body { font-family: Arial, sans-serif; }
  "send_time": "2025-05-13 11:21:35",
    textarea { width: 100%; height: 100px; font-family: monospace; }
  "status": 1,
    button {
  "timezone": 22,
      padding: 10px 20px;
   "upRateIgOff": 1,
      border-radius: 20px;
  "upRateIgOn": 5,
      font-weight: bold;
  "upRateSleep": 2,
      background-color: #680022;
   "url": "15.235.9.66:50337",
      color: white;
  "urlLength": 136
      border: none;
      cursor: pointer;
    }
    button:hover {
      background-color: #4c0019;
    }
    table { width: 100%; border-collapse: collapse; margin-top: 20px; }
    th, td { border: 1px solid #ccc; padding: 8px; text-align: left; }
    th { background-color: #680022; color: white; }
   </style>
</head>
<body>
 
<h2>IP Configuration Packet Parser</h2>
<textarea id="packetInput" placeholder="Paste IP Configuration packet here..."></textarea><br>
<button onclick="parsePacket()">Parse Packet</button>
 
<table id="resultTable">
  <thead><tr><th>Field</th><th>Value</th></tr></thead>
  <tbody></tbody>
</table>
 
<script>
function hexToBits(hex) {
  return hex.match(/.{1,2}/g).map(byte => parseInt(byte, 16).toString(2).padStart(8, '0')).join('');
}
}
</pre>
function bitsToInt(bits) {
  return parseInt(bits, 2);
}
function bitsToSignedInt(bits) {
  const val = parseInt(bits, 2);
  const max = 2 ** bits.length;
  return val >= max / 2 ? val - max : val;
}
function bigIntFromBits(bits) {
  return BigInt('0b' + bits).toString();
}
function bitsToAscii(bits) {
  return bits.match(/.{8}/g).map(b => String.fromCharCode(parseInt(b, 2))).join('');
}
function addRow(label, value) {
  const row = document.createElement("tr");
  row.innerHTML = `<td>${label}</td><td>${value}</td>`;
  document.querySelector("#resultTable tbody").appendChild(row);
}
 
function parsePacket() {
  const hex = document.getElementById("packetInput").value.trim();
  const resultBody = document.querySelector("#resultTable tbody");
  resultBody.innerHTML = "";
 
  if (!hex.startsWith("24")) {
    alert("Invalid packet (must start with 0x24)");
    return;
  }
 
  const bits = hexToBits(hex);
 
  const imei = bigIntFromBits(bits.slice(25, 75)); // Corrected IMEI (50 bits)
  addRow("IMEI", imei);
 
  const packetType = bitsToInt(bits.slice(75, 80)); // 5 bits
  addRow("Packet Type", packetType);
 
  const ts = bitsToInt(bits.slice(80, 112));
  const timezoneRaw = bitsToSignedInt(bits.slice(112, 120));
  const tzOffsetMin = timezoneRaw * 15;
  const localTime = new Date((ts + tzOffsetMin * 60) * 1000).toISOString().replace("T", " ").split(".")[0];
 
  addRow("DateTime (Epoch)", ts);
  addRow("TimeZone", timezoneRaw);
  addRow("DateTime (Local)", localTime);
 
  const ipIndex = bitsToInt(bits.slice(120, 123));  // 2 bits
  const status = bitsToInt(bits.slice(123, 124));  // 1 bit
  const fsMode = bitsToInt(bits.slice(124, 125));  // 1 bit
  const protocol = bitsToInt(bits.slice(125, 128)); // 2 bits
 
  addRow("IP Index", ipIndex);
  addRow("Status", status);
  addRow("FS Mode", fsMode);
  addRow("Protocol", protocol); // 0=HTTP, 1=HTTPS, 2=TCP, 3-MQTT
 
  const rateOn = bitsToInt(bits.slice(128, 144));    // 16 bits
  const rateOff = bitsToInt(bits.slice(144, 160));  // 16 bits
  const rateSleep = bitsToInt(bits.slice(160, 176)); // 16 bits
 
  addRow("Update Rate (Ign ON)", `${rateOn}s`);
  addRow("Update Rate (Ign OFF)", `${rateOff}Min`);
  addRow("Update Rate (Sleep)", `${rateSleep}Min`);
 
  const urlLengthBytes = bitsToInt(bits.slice(176, 184)); // 7 bits = bytes
  const urlBits = bits.slice(184, 184 + urlLengthBytes * 8);
  const url = bitsToAscii(urlBits).split('*')[0]; // Remove garbage after '*'
 
  addRow("URL Length", urlLengthBytes * 1); // actual in bits for output match
  addRow("URL", url);
}
</script>
 
</body>
</html>

Latest revision as of 10:09, 8 September 2025

Field Size (bits) Bit Range Description Breakdown
Header (10 bytes)
Start byte 8 0 - 7 Starting character $ (ASCII value 36)
Data length 12 8 - 19 2-byte length of the data following the header
Number of data packets 5 20 - 24 Number of packets 0–32
IMEI 50 25 - 74 Unique device identifier
Packet type 5 75 - 79 Type of packet 05 - IP Configuration Packet
Data
Time 32 80-111 UTC Timestamp UTC time in seconds
Time Zone 8 112-119 Timezone in quarter-hours 22 = +5:30; each unit = 15 min; ranges -48 to 56
IP index 3 120-122 IP type index 1: Customer IP
Status 1 123 IP status 0 - Disabled, 1 - Enabled
FS mode 1 124 File System mode 0 - FIFO, 1 - LIFO
Protocol 3 125-127 Communication protocol 0 - HTTP, 1 - HTTPS, 2 - TCP
Update rate (motion) 16 128-143 Reporting interval while in motion In seconds
Update rate (halt) 16 144-159 Reporting interval during halt In Minutes
Update rate (Sleep) 16 160-175 Sleep mode reporting interval In Minutes
URL length 8 176-183 Length of URL field In number of bytes
URL Varies 184 (184+N*8-1) URL data Length given by URL length
Tail (2 Bytes)
End Character 8 0 - 7 Ending character * (ASCII value 42)
CRC 8 8 - 15 Checksum 8-bit XOR from $ to * (excluding $ and *)
{ "HEX : 2401f0e21aeb7abfd58568abeb09163a000a000100011231332e3233322e31332e3233333a363038342a7d"  "imei": 862942074896044, "packet_type": 5, "no_packets": 1, "dateTime": 1756097289, "timezone": 22, "dateTime_tz": "2025-08-25 10:18:09", "ip_index": 1, "status": 1, "fs_mode": 1, "protocol": 2, "up_rate_ig_on": 10, "up_rate_ig_off": 1, "up_rate_sleep": 1, "url_length": 18, "url": "13.232.13.233:6084", "error_code": 0}


IP Configuration Packet Parser


FieldValue