• Home
  • Install
  • Cosmos Website
  • Articles
  • Cosmos
  • X#
  • IL2CPU
Show / Hide Table of Contents
  • Cosmos.Core
    • ACPI
    • ACPI.RSDPtr
    • Bootstrap
    • CPU
    • GCImplementation
    • GCTable
    • Global
    • INTs
    • INTs.EFlagsEnum
    • INTs.ExceptionInterruptDelegate
    • INTs.IRQContext
    • INTs.IRQDelegate
    • INTs.MMXContext
    • INTs.TSS
    • IOPort
    • KernelPanics
    • ManagedMemoryBlock
    • MemoryBlock
    • MemoryBlock08
    • MemoryBlock16
    • MemoryBlock32
    • MemoryMapBlock
    • MemoryOperations
    • PIC
    • PIC.Cmd
    • RawMemoryMapBlock
    • VTable
    • VTablesImpl
  • Cosmos.Core.IOGroup
    • ATA
    • PIC
    • PS2Controller
  • Cosmos.Core.Memory
    • Heap
    • HeapLarge
    • HeapMedium
    • HeapSmall
    • ObjectGCStatus
    • RAT
    • RAT.PageType
    • RootSMTBlock
    • SMTBlock
    • SMTPage
  • Cosmos.Core.MemoryGroup
    • AHCI
  • Cosmos.Core.Multiboot
    • Multiboot2
  • Cosmos.Core.Multiboot.Tags
    • AcpiNew
    • AcpiOld
    • BasicMemoryInformation
    • EFI64
    • Framebuffer
    • MB2Tag
    • MemoryMap
  • Cosmos.Core_Asm
    • ArrayClearAsm
    • ArrayGetLengthAsm
    • ArrayImpl
    • ArrayInternalCopyAsm
    • BufferBlockCopyAsm
    • BufferImpl
    • CPUCanReadCPUIDAsm
    • CPUDisableINTsAsm
    • CPUEnableINTsAsm
    • CPUGetEBPValue
    • CPUGetEndOfKernelAsm
    • CPUGetESPValue
    • CPUGetStackStart
    • CPUHaltAsm
    • CPUImpl
    • CPUInitFloatAsm
    • CPUInitSSEAsm
    • CPUReadCPUIDAsm
    • CPUReadModelSpecificRegisterAsm
    • CPUReadTimestampCounterAsm
    • CPUSetESPValue
    • CPUUpdateIDTAsm
    • CPUZeroFillAsm
    • DelegateCtorAsm
    • DelegateGetMulticastInvokeAsm
    • DelegateImpl
    • DelegateInvokeAsm
    • GCImplementationImpl
    • IOPortImpl
    • Multiboot2Impl
    • Multiboot2ImplAsm
    • RuntimeHelpersImpl
  • Cosmos.Core_Asm.MemoryOperations
    • MemoryOperationsCopy128BlocksAsm
    • MemoryOperationsCopy128BytesAsm
    • MemoryOperationsCopy16BytesAsm
    • MemoryOperationsCopy32BytesAsm
    • MemoryOperationsCopy64BytesAsm
    • MemoryOperationsFill16BlocksAsm
  • Cosmos.Debug.Kernel
    • Debugger
    • DebuggerFactory
  • Cosmos.HAL
    • BaudRate
    • Bootstrap
    • CardType
    • ClassID
    • COMPort
    • DataReceivedHandler
    • Device
    • DeviceID
    • Global
    • KeyboardBase
    • KeyboardBase.KeyPressedEventHandler
    • MouseBase
    • MouseBase.MouseChangedEventHandler
    • NetworkDevice
    • PCI
    • PCIBaseAddressBar
    • PCIDevice
    • PCIDevice.Config
    • PCIDevice.DeviceClass
    • PCIDevice.PCIBist
    • PCIDevice.PCICommand
    • PCIDevice.PCIHeaderType
    • PCIDevice.PCIInterruptPIN
    • PCIDeviceBridge
    • PCIDeviceCardbus
    • PCIDeviceNormal
    • PCSpeaker
    • PIT
    • PIT.PITTimer
    • PIT.PITTimer.OnTrigger
    • Power
    • ProgramIF
    • PS2Controller
    • PS2Keyboard
    • PS2Mouse
    • RTC
    • SerialPort
    • SpeakerExtensions
    • SubclassID
    • TextScreen
    • TextScreenBase
    • TextScreenHelpers
    • VendorID
  • Cosmos.HAL.Audio
    • AudioBitDepth
    • AudioBuffer
    • IAudioBufferProvider
    • SampleFormat
  • Cosmos.HAL.BlockDevice
    • AHCI
    • Ata
    • Ata.BusPositionEnum
    • Ata.ControllerIdEnum
    • ATA_PIO
    • ATA_PIO.Cmd
    • ATA_PIO.DvcSelVal
    • ATA_PIO.Ident
    • ATA_PIO.SpecLevel
    • ATA_PIO.Status
    • ATAPI
    • ATAPI.PacketCommands
    • BlockDevice
    • BlockDeviceType
    • EBR
    • EBR.PartInfo
    • GPT
    • GPT.GPartInfo
    • IDE
    • MBR
    • MBR.PartInfo
    • Partition
  • Cosmos.HAL.BlockDevice.Ports
    • SATA
    • SATAPI
    • StoragePort
  • Cosmos.HAL.BlockDevice.Registers
    • AHCISignature
    • ATACommands
    • ATADeviceStatus
    • Base
    • Bases
    • CommandAndStatus
    • CurrentInterfaceSpeedStatus
    • DeviceDetectionStatus
    • FISRegisterD2H
    • FISRegisterH2D
    • FISSize
    • FISType
    • GenericRegisters
    • HBACommandHeader
    • HBACommandTable
    • HBAPRDTEntry
    • InterfacePowerManagementStatus
    • InterruptEnable
    • InterruptStatus
    • PortRegisters
    • PortType
  • Cosmos.HAL.Drivers.Audio
    • AC97
    • AudioDriver
  • Cosmos.HAL.Drivers.Network
    • AMDPCNetII
    • E1000
    • E1000.RXDesc
    • E1000.TXDesc
    • E1000DeviceID
    • RTL8139
  • Cosmos.HAL.Drivers.USB
    • USBHost
  • Cosmos.HAL.Drivers.Video
    • VBEDriver
    • VGADriver
    • VGADriver.ColorDepth
    • VGADriver.ScreenSize
    • VGADriver.TextSize
  • Cosmos.HAL.Drivers.Video.SVGAII
    • Capability
    • FIFO
    • FIFOCommand
    • ID
    • IOPortOffset
    • Register
    • VMWareSVGAII
  • Cosmos.HAL.Network
    • MACAddress
    • NetworkInit
  • Cosmos.System
    • Console
    • ConsoleKeyEx
    • ConsoleKeyExExtensions
    • Durations
    • Global
    • Kernel
    • KeyboardManager
    • KeyEvent
    • KeyEvent.KeyEventType
    • KeyMapping
    • MouseManager
    • MouseState
    • Notes
    • PCSExtensions
    • PCSpeaker
    • Power
    • ScanMapBase
    • VMTools
  • Cosmos.System.Audio
    • AudioManager
    • AudioMixer
    • AudioStream
  • Cosmos.System.Audio.DSP.Processing
    • AudioPostProcessor
    • GainPostProcessor
  • Cosmos.System.Audio.IO
    • AudioBufferReader
    • AudioBufferReadWriteBase
    • AudioBufferWriter
    • MemoryAudioStream
    • SeekableAudioStream
  • Cosmos.System.ExtendedASCII
    • CosmosEncodingProvider
  • Cosmos.System.FileSystem
    • CosmosVFS
    • Disk
    • FileSystem
    • FileSystemFactory
    • ManagedPartition
  • Cosmos.System.FileSystem.FAT
    • FatFileSystemFactory
  • Cosmos.System.FileSystem.FAT.Listing
    • FatDirectoryEntryAttributeConsts
    • FatDirectoryEntryMetadata
    • FatDirectoryEntryMetadata.LongFilenameEntryMetadata
  • Cosmos.System.FileSystem.ISO9660
    • ISO9660FileSystem
    • ISO9660FileSystemFactory
  • Cosmos.System.FileSystem.Listing
    • DirectoryEntry
    • DirectoryEntryTypeEnum
  • Cosmos.System.FileSystem.VFS
    • FileSystemManager
    • VFSBase
    • VFSManager
  • Cosmos.System.Graphics
    • Bitmap
    • Canvas
    • ColorDepth
    • ColorOrder
    • FullScreenCanvas
    • Image
    • ImageFormat
    • Mode
    • SVGAIICanvas
    • VBECanvas
    • VGACanvas
    • VGAScreen
  • Cosmos.System.Graphics.Fonts
    • Font
    • PCScreenFont
    • UnicodeMapping
  • Cosmos.System.Helpers
    • ArrayHelper
  • Cosmos.System.IO
    • ConsoleStream
    • SyncTextReader
  • Cosmos.System.Keyboard
    • KeyEventHelper
  • Cosmos.System.Network
    • EthernetPacket
    • NetworkDebugger
    • NetworkStack
  • Cosmos.System.Network.ARP
    • ARPPacket
  • Cosmos.System.Network.Config
    • DNSConfig
    • IPConfig
    • NetworkConfig
    • NetworkConfiguration
  • Cosmos.System.Network.IPv4
    • Address
    • EndPoint
    • ICMPClient
    • ICMPPacket
    • IPPacket
    • OutgoingBuffer
  • Cosmos.System.Network.IPv4.TCP
    • Flags
    • Status
    • Tcp
    • TCPOption
    • TCPPacket
    • TransmissionControlBlock
  • Cosmos.System.Network.IPv4.UDP
    • UdpClient
    • UDPPacket
  • Cosmos.System.Network.IPv4.UDP.DHCP
    • DHCPClient
    • DHCPOption
    • DHCPPacket
  • Cosmos.System.Network.IPv4.UDP.DNS
    • DNSAnswer
    • DnsClient
    • DNSPacket
    • DNSPacketAnswer
    • DNSPacketAsk
    • DNSQuery
    • ReplyCode
  • Cosmos.System.ScanMaps
    • DEStandardLayout
    • ESStandardLayout
    • FRStandardLayout
    • GBStandardLayout
    • TRStandardLayout
    • US_Dvorak
    • USStandardLayout

Class Tcp

Used to manage the TCP state machine. Handle received packets according to current TCP connection Status. Also contains TCB (Transmission Control Block) information.

Inheritance
System.Object
Tcp
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Cosmos.System.Network.IPv4.TCP
Assembly: Cosmos.System2.dll
Syntax
public class Tcp
Remarks

See RFC 793 for more information.

Constructors

| Improve this Doc View Source

Tcp(UInt16, UInt16, Address, Address)

Declaration
public Tcp(ushort localPort, ushort remotePort, Address localIp, Address remoteIp)
Parameters
Type Name Description
System.UInt16 localPort
System.UInt16 remotePort
Address localIp
Address remoteIp

Fields

| Improve this Doc View Source

Connections

A list of currently active connections.

Declaration
public static List<Tcp> Connections
Field Value
Type Description
System.Collections.Generic.List<Tcp>
| Improve this Doc View Source

DynamicPortStart

Declaration
public static ushort DynamicPortStart
Field Value
Type Description
System.UInt16
| Improve this Doc View Source

LocalEndPoint

The local end-point.

Declaration
public EndPoint LocalEndPoint
Field Value
Type Description
EndPoint
| Improve this Doc View Source

RemoteEndPoint

The remote end-point.

Declaration
public EndPoint RemoteEndPoint
Field Value
Type Description
EndPoint
| Improve this Doc View Source

Status

The connection status.

Declaration
public Status Status
Field Value
Type Description
Status
| Improve this Doc View Source

Table

String / enum correspondance (used for debugging)

Declaration
public static readonly string[] Table
Field Value
Type Description
System.String[]
| Improve this Doc View Source

TcpWindowSize

The TCP window size.

Declaration
public const ushort TcpWindowSize = 8192
Field Value
Type Description
System.UInt16

Properties

| Improve this Doc View Source

Data

The received data buffer.

Declaration
public byte[] Data { get; set; }
Property Value
Type Description
System.Byte[]
| Improve this Doc View Source

TCB

The connection Transmission Control Block.

Declaration
public TransmissionControlBlock TCB { get; set; }
Property Value
Type Description
TransmissionControlBlock

Methods

| Improve this Doc View Source

GetDynamicPort(Int32)

gets a random port

Declaration
public static ushort GetDynamicPort(int tries = 10)
Parameters
Type Name Description
System.Int32 tries
Returns
Type Description
System.UInt16
| Improve this Doc View Source

ProcessCloseWait(TCPPacket)

Process Close_WAIT Status.

Declaration
public void ProcessCloseWait(TCPPacket packet)
Parameters
Type Name Description
TCPPacket packet

Packet to receive.

| Improve this Doc View Source

ProcessClosing(TCPPacket)

Process CLOSING Status.

Declaration
public void ProcessClosing(TCPPacket packet)
Parameters
Type Name Description
TCPPacket packet

Packet to receive.

| Improve this Doc View Source

ProcessEstablished(TCPPacket)

Processes a ESTABLISHED state TCP packet.

Declaration
public void ProcessEstablished(TCPPacket packet)
Parameters
Type Name Description
TCPPacket packet

The received packet.

| Improve this Doc View Source

ProcessFinWait1(TCPPacket)

Process FIN_WAIT1 Status.

Declaration
public void ProcessFinWait1(TCPPacket packet)
Parameters
Type Name Description
TCPPacket packet

Packet to receive.

| Improve this Doc View Source

ProcessFinWait2(TCPPacket)

Process FIN_WAIT2 Status.

Declaration
public void ProcessFinWait2(TCPPacket packet)
Parameters
Type Name Description
TCPPacket packet

Packet to receive.

| Improve this Doc View Source

ProcessListen(TCPPacket)

Processes a TCP LISTEN state packet and updates the connection status accordingly.

Declaration
public void ProcessListen(TCPPacket packet)
Parameters
Type Name Description
TCPPacket packet

The incoming TCP packet.

Remarks

This method handles various types of incoming TCP packets during the LISTEN state and updates the status of the connection accordingly. If an RST packet is received, the packet is passed and no action is taken. If a FIN packet is received, the TCP connection is closed. If an ACK packet is received, the TCP connection is established. If a SYN packet is received, the TCP connection is moved to the SYN_RECEIVED state and an empty packet with the SYN and ACK flags set is sent back.

| Improve this Doc View Source

ProcessSynReceived(TCPPacket)

Processes a TCP SYN_RECEIVED state packet and updates the connection status accordingly.

Declaration
public void ProcessSynReceived(TCPPacket packet)
Parameters
Type Name Description
TCPPacket packet

The incoming TCP packet.

Remarks

This method handles an incoming TCP packet during the SYN_RECEIVED state and updates the status of the connection accordingly. If an ACK packet is received with a valid AckNumber, the TCP connection is established. If the AckNumber is invalid, a reset packet is sent back with the AckNumber set to the invalid value.

| Improve this Doc View Source

ProcessSynSent(TCPPacket)

Processes a SYN_SENT state TCP packet and updates the connection state accordingly.

Declaration
public void ProcessSynSent(TCPPacket packet)
Parameters
Type Name Description
TCPPacket packet

The TCP packet to process.

Remarks

If the packet has the SYN flag set, the method sets the initial receive sequence number and responds with an ACK packet if the ACK flag is also set. If the SYN flag is set but not the ACK flag, the method closes the connection and sends an error message. If the packet has only the ACK flag set, the method checks whether the acknowledgment number is within the valid range and updates the send and receive sequence numbers. If the packet has the FIN flag set, the method closes the connection. If the packet has the RST flag set, the method also closes the connection and sends an error message.

| Improve this Doc View Source

RemoveConnection(UInt16, UInt16, Address, Address)

Removes a TCP connection object that matches the specified local and remote ports and addresses.

Declaration
public static void RemoveConnection(ushort localPort, ushort remotePort, Address localIp, Address remoteIp)
Parameters
Type Name Description
System.UInt16 localPort

The local port number of the connection.

System.UInt16 remotePort

The remote port number of the connection.

Address localIp

The local IP address of the connection.

Address remoteIp

The remote IP address of the connection.

Remarks

If a connection is found that matches the local and remote ports and addresses, it will be removed from the list of connections.

| Improve this Doc View Source

SendEmptyPacket(Flags)

Sends an empty packet.

Declaration
public void SendEmptyPacket(Flags flag)
Parameters
Type Name Description
Flags flag
| Improve this Doc View Source

WaitStatus(Status)

Waits for a new TCP connection status (blocking).

Declaration
public bool WaitStatus(Status status)
Parameters
Type Name Description
Status status
Returns
Type Description
System.Boolean
| Improve this Doc View Source

WaitStatus(Status, Int32)

Waits for a new TCP connection status.

Declaration
public bool WaitStatus(Status status, int timeout)
Parameters
Type Name Description
Status status
System.Int32 timeout
Returns
Type Description
System.Boolean
  • Improve this Doc
  • View Source
☀
☾
In This Article
Back to top
☀
☾