AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Programmieren allgemein Ip-Protokoll und (CRC-16) Berechnung... Und ich versteh nix.
Thema durchsuchen
Ansicht
Themen-Optionen

Ip-Protokoll und (CRC-16) Berechnung... Und ich versteh nix.

Ein Thema von Kedariodakon · begonnen am 9. Feb 2005 · letzter Beitrag vom 14. Feb 2005
 
Basilikum

Registriert seit: 9. Aug 2003
389 Beiträge
 
Delphi 7 Professional
 
#9

Re: Ip-Protokoll und (CRC-16) Berechnung... Und ich versteh

  Alt 14. Feb 2005, 13:28
Zitat von Kedariodakon:

1. Was ist PWords???
2. Was ist PBytes???
3. Kommt in Packet mein Byte Array? Wenn ja warum arbeitest du dann mit Pointern?
4. Kommt in Bytes die Länge des Byte Arrays? Wenn ja ein Word reicht aus, da ein Ip-Packet net größer als 1500 Bytes werden kann.


Zitat von Basilikum:
...
- die Checksumme liegt im Packet in Network-Byte-Order vor.... mittels WinSock.NToHS lässt sich ein Word (S-hort) von Network-Byte-Order zu Host-Byte-Order wandeln (WinSock.HToNS für Gegenrichtung)
Bahnhof *tüttüt*

Bye
1.:
Delphi-Quellcode:
type
  PWords = ^TWords;
  TWords = Array[0..high(word)] Of Word;
2.:
Delphi-Quellcode:
type
  PBytes = ^TBytes;
  TBytes = Array[0..high(word)] Of Byte;
3. Packet soll ein Pointer auf das 1. Byte des IP-Header sein

4. Richtig; allerdings verwende ich einheitlich LongWord, wenn es um die Grösse von Pointer-Daten geht

Zitat von Kedariodakon:
Bahnhof *tüttüt*



Delphi-Quellcode:
Const
  cProto: Array[ $00..$2D ] Of Byte =
   ( $45, $00, $00, $28, $A2, $EE, $40, $00, $80, $06, $0E, $55, $C0, $A8, $64, $39,
     $C0, $A8, $64, $02, $06, $4D, $01, $BD, $0A, $62, $36, $C5, $47, $E8, $96, $1E,
     $50, $10, $FC, $FD, $42, $12, $00, $00, $00, $00, $00, $00, $00, $00 );
var
  headerlen : LongWord;
  buf : array[0..$f * 4 - 1] of byte;
  cs : word;
begin
  headerlen:=(cProto[0] and $0f) shl 2;
  move(cProto,buf,headerlen);

  cs:=pwords(@buf)^[5];

  pwords(@buf)^[5]:=0; // checksum feld 0-en vor Berechnung
  pwords(@buf)^[5]:=CalcIPChecksum(@buf,headerlen); // Checksum neu berechnen

  Assert(cs = pwords(@buf)^[5],'Checksum incorrect');
end;
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 14:13 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz