NetSim Source Code Help
Loading...
Searching...
No Matches
WindowScale.c
Go to the documentation of this file.
1/************************************************************************************
2* Copyright (C) 2020 *
3* TETCOS, Bangalore. India *
4* *
5* Tetcos owns the intellectual property rights in the Product and its content. *
6* The copying, redistribution, reselling or publication of any or all of the *
7* Product or its content without express prior written consent of Tetcos is *
8* prohibited. Ownership and / or any other right relating to the software and all *
9* intellectual property rights therein shall remain at all times with Tetcos. *
10* *
11* Author: Shashi Kant Suman *
12* *
13* ---------------------------------------------------------------------------------*/
14#include "main.h"
15#include "TCP.h"
16#include "TCP_Header.h"
17
19{
20 if (opt)
21 {
22 s->tcb->isWindowScaling = true;
23 s->tcb->Snd.Wind_Shift = opt->Shift_cnt;
24 s->tcb->Rcv.Wind_Shift = opt->Shift_cnt;
25 s->tcb->RCV.WND = s->tcb->get_RCVWND(s);
26 }
27 else
28 {
29 s->tcb->isWindowScaling = false;
30 s->tcb->Snd.Wind_Shift = 0;
31 s->tcb->Rcv.Wind_Shift = 0;
32 }
33}
34
36{
37 return s->tcb->isWindowScaling ? s->tcb->Snd.Wind_Shift : 0;
38}
39
41{
42 if (tcp->isWindowScaling)
43 {
44 s->tcb->isWindowScaling = true;
45 s->tcb->Snd.Wind_Shift = tcp->shiftCount;
46 s->tcb->Rcv.Wind_Shift = tcp->shiftCount;
47 }
48}
49
51{
52 UINT32 c = (UINT32)s->tcb->get_WND(s);
53 if (s->tcb->isWindowScaling)
54 {
55 UINT32 r = c << s->tcb->Snd.Wind_Shift;
56 UINT32 mss = s->tcb->get_MSS(s);
57 return max(r, mss);
58 }
59 else
60 return (c);
61}
62
64{
65 if (s->tcb->isWindowScaling)
66 return (UINT16)(s->tcb->SND.WND >> s->tcb->Snd.Wind_Shift);
67 else
68 return (UINT16)(s->tcb->SND.WND);
69}
#define c
#define UINT32
Definition: Linux.h:35
#define UINT16
Definition: Linux.h:33
#define UINT8
Definition: Linux.h:31
#define max(a, b)
Definition: Linux.h:107
void set_window_scaling_option(PNETSIM_SOCKET s, PTCP_DEV_VAR tcp)
Definition: WindowScale.c:40
UINT16 window_scale_get_wnd(PNETSIM_SOCKET s)
Definition: WindowScale.c:63
UINT8 get_shift_count(PNETSIM_SOCKET s)
Definition: WindowScale.c:35
UINT32 window_scale_get_cwnd(PNETSIM_SOCKET s)
Definition: WindowScale.c:50
void set_window_scaling(PNETSIM_SOCKET s, PWsopt opt)
Definition: WindowScale.c:18
PTCB tcb
Definition: TCP.h:132
bool isWindowScaling
Definition: TCP.h:154
UINT8 shiftCount
Definition: TCP.h:155
struct stru_tcp_Transmission_Control_Block::stru_tcb_send_seq_var SND
UINT32(* get_RCVWND)(PNETSIM_SOCKET)
Definition: TCB.h:137
struct stru_tcp_Transmission_Control_Block::stru_tcp_rcv Rcv
UINT16(* get_MSS)(PNETSIM_SOCKET)
Definition: TCB.h:134
struct stru_tcp_Transmission_Control_Block::stru_tcp_snd Snd
struct stru_tcp_Transmission_Control_Block::stru_tcb_recv_seq_var RCV
UINT16(* get_WND)(PNETSIM_SOCKET)
Definition: TCB.h:135