NetSim Source Code Help
Loading...
Searching...
No Matches
TCP_Outgoing.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 PTCB t = s->tcb;
21 UINT32 seq = t->SND.NXT;
22 if (!s->sId)
23 fnNetSimError("SOCKETINTERFACE is NULL for TCP connection %s:%d %s:%d in function %s\n",
24 s->localAddr->ip->str_ip,
25 s->localAddr->port,
26 s->remoteAddr->ip->str_ip,
27 s->remoteAddr->port,
28 __FUNCTION__);
30 if (!p)
31 s->waitFromApp = true; //Enable flag to signal application waiting.
32
34 assert(t->SND.WND >= t->get_MSS(s));
35 while (p)
36 {
38 if (seq + l <= t->SND.WND + t->SND.UNA)
39 {
42 s->isAPPClose = true; //Enable flag to signal application closing
43
44 add_tcp_hdr(pt, s);
45 t->SND.NXT += l;
46 seq += l;
47
49
50 send_to_network(pt, s);
51 add_timeout_event(s, pt);
53 }
54 else
55 break; //No more segment allowed to send
56
58 }
59
60 if (s->isAPPClose)
61 tcp_close(s);
62}
63
65{
68
70
71 if (p)
72 {
74 send_to_network(p, s);
76 }
77}
78
80{
81 bool isSacked = false;
83
84 NetSim_PACKET* p = get_copy_segment_from_queue(q, seq, &isSacked);
85
86 if (s->tcb->isSackPermitted &&
87 isSacked)
88 {
89 //Don't retransmit
91 p = NULL;
92 }
93
94 if (p)
95 {
96 set_highRxt(s, seq);
97 set_rescueRxt(s, seq);
99 send_to_network(p, s);
100 }
101}
#define UINT
Definition: Linux.h:38
#define UINT32
Definition: Linux.h:35
#define fnNetSimError(x,...)
Definition: Linux.h:56
void add_timeout_event(PNETSIM_SOCKET s, NetSim_PACKET *packet)
Definition: RTO.c:63
void set_rescueRxt(PNETSIM_SOCKET s, UINT32 seq)
Definition: SACK.c:48
void set_highRxt(PNETSIM_SOCKET s, UINT32 seq)
Definition: SACK.c:38
NetSim_PACKET * fn_NetSim_Socket_GetPacketFromInterface(ptrSOCKETINTERFACE s, int moveFlag)
NetSim_PACKET * get_copy_segment_from_queue(PTCP_QUEUE queue, UINT32 seqNo, bool *isSacked)
Definition: TCB.c:285
NetSim_PACKET * get_segment_from_queue(PTCP_QUEUE queue, UINT32 seqNo)
Definition: TCB.c:229
void write_congestion_plot(PNETSIM_SOCKET s, NetSim_PACKET *packet)
Definition: TCP.c:276
void send_to_network(NetSim_PACKET *packet, PNETSIM_SOCKET s)
void tcp_close(PNETSIM_SOCKET s)
Definition: TCP_Socket.c:286
UINT32 window_scale_get_cwnd(PNETSIM_SOCKET s)
Definition: WindowScale.c:50
void add_tcp_hdr(NetSim_PACKET *p, PNETSIM_SOCKET s)
Definition: TCP_Packet.c:341
static PTCP_SEGMENT_HDR TCP_GET_SEGMENT_HDR(NetSim_PACKET *packet)
Definition: TCP_Header.h:107
void resend_segment_without_timeout(PNETSIM_SOCKET s, UINT seq)
Definition: TCP_Outgoing.c:79
void send_segment(PNETSIM_SOCKET s)
Definition: TCP_Outgoing.c:18
void resend_segment(PNETSIM_SOCKET s, NetSim_PACKET *expired)
Definition: TCP_Outgoing.c:64
#define fn_NetSim_Packet_FreePacket(pstruPacket)
Definition: main.h:177
struct stru_NetSim_Packet_AppLayer * pstruAppData
Definition: Packet.h:273
bool isAPPClose
Definition: TCP.h:129
bool waitFromApp
Definition: TCP.h:128
PTCB tcb
Definition: TCP.h:132
PSOCKETADDRESS localAddr
Definition: TCP.h:121
PSOCKETADDRESS remoteAddr
Definition: TCP.h:122
PTCP_METRICS tcpMetrics
Definition: TCP.h:140
ptrSOCKETINTERFACE sId
Definition: TCP.h:127
char str_ip[_NETSIM_IP_LEN]
Definition: IP_Addressing.h:54
NETSIM_IPAddress ip
Definition: TCP.h:114
UINT16 port
Definition: TCP.h:115
struct stru_tcp_Transmission_Control_Block::stru_tcb_send_seq_var SND
UINT16(* get_MSS)(PNETSIM_SOCKET)
Definition: TCB.h:134
UINT segmentRetransmitted
Definition: TCP.h:99
UINT segmentSent
Definition: TCP.h:97