Skip to content

[WIP]gnrc_tcp#2827

Closed
brummer-simon wants to merge 1 commit intoRIOT-OS:masterfrom
brummer-simon:devel-ng_tcp
Closed

[WIP]gnrc_tcp#2827
brummer-simon wants to merge 1 commit intoRIOT-OS:masterfrom
brummer-simon:devel-ng_tcp

Conversation

@brummer-simon
Copy link
Copy Markdown
Member

Current State of ng_tcp. This Branch is currently under heavy development. Your comments on the current state are very welcome :).

This PR is intendend for reference in the NSTF Todo List.

@OlegHahm OlegHahm added Area: network Area: Networking State: WIP State: The PR is still work-in-progress and its code is not in its final presentable form yet Type: new feature The issue requests / The PR implemements a new feature for RIOT NSTF labels Apr 18, 2015
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For readability and documentation I would prefer to put each enum into a single line.

@OlegHahm
Copy link
Copy Markdown
Member

@cgundogan, maybe you are interested, too.

@miri64
Copy link
Copy Markdown
Member

miri64 commented Apr 18, 2015

Please don't use sub-directories in tests (except unittests). See e.g. thread and vtimer tests.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ifdefs should not be necessary here

@miri64 miri64 added this to the Network Stack Task Force milestone Apr 18, 2015
@miri64 miri64 mentioned this pull request Apr 18, 2015
36 tasks
@miri64 miri64 assigned cgundogan and unassigned miri64 Jun 2, 2015
@OlegHahm
Copy link
Copy Markdown
Member

OlegHahm commented Aug 8, 2015

@brummer-simon, what's the latest on this one?

@brummer-simon
Copy link
Copy Markdown
Member Author

Currently I am running in a bunch of problems with implementing TCP. I suspect the cause of it in RIOTs scheduling model and timer implementation. The non-premetive scheduling model seems to be the biggest obstacle because RFC 793 assumes a premetive scheduler.

Currently I'll write it down and upload the pdf up for discussion.

@OlegHahm
Copy link
Copy Markdown
Member

The non-premetive scheduling model seems to be the biggest obstacle because RFC 793 assumes a premetive scheduler.

Huh? Since when does RIOT has a non-preemptive scheduler? Don't confuse the fact that RIOT's scheduler works without timeslices to interrupt threads periodically with the fact threads are preemptible.

@brummer-simon
Copy link
Copy Markdown
Member Author

Okay. Still the Problem is, main Function runs as long as it doesn't put itself to sleep or wait for a message or what ever. After that TCP is able to do actual work. And this is a Problem. The TCP-Thread must be able react on incomming data as soon as possible, independently from userspace.

As far as is see it this is currently a huge obstacle and i am not sure how to solve it.

@kaspar030
Copy link
Copy Markdown
Contributor

kaspar030 commented Aug 11, 2015 via email

@brummer-simon
Copy link
Copy Markdown
Member Author

Okay as general scheduling questing. If my TCP-Thread has a higher priority than my main-Thread and the TCP-Thread is currently waiting for a message, the main thread is running.

If a message for the tcp thread commes in, will there be a context switch to the tcp thread as soon as the message comes in or after the main thread puts it self to sleep ?

@OlegHahm
Copy link
Copy Markdown
Member

If a message for the tcp thread commes in, will there be a context switch to the tcp thread as soon as the message comes in or after the main thread puts it self to sleep ?

As soon as the message comes in.

@brummer-simon
Copy link
Copy Markdown
Member Author

Ah okay. Then I see why its not a non-premptive scheduler. Still i'll have to figure out where exactly my Problem is.

@OlegHahm
Copy link
Copy Markdown
Member

Let us know as soon as you've figured out what the problem is. Maybe we can help.

@kaspar030
Copy link
Copy Markdown
Contributor

kaspar030 commented Aug 11, 2015 via email

@brummer-simon
Copy link
Copy Markdown
Member Author

Native and the samr-xpro board.

@kaspar030
Copy link
Copy Markdown
Contributor

kaspar030 commented Aug 11, 2015 via email

@brummer-simon
Copy link
Copy Markdown
Member Author

Yes and Yes. Currently I focus more on Bugfixing on native.

@jnohlgard
Copy link
Copy Markdown
Member

Also note that in order to give a thread a higher priority means that you
assign it a lower number for the priority value IIRC.
On Aug 11, 2015 11:57 AM, "Kaspar Schleiser" notifications@github.com
wrote:

Okay. Still the Problem is, main Function runs as long as it doesn't put
itself to sleep or wait for a message or what ever. After that TCP is able
to do actual work. And this is a Problem. The TCP-Thread must be able react
on incomming data as soon as possible, independently from userspace.

Give TCP a higher priority (lower priority value) than main, if your
main does busy-waiting.


Reply to this email directly or view it on GitHub
#2827 (comment).

@brummer-simon
Copy link
Copy Markdown
Member Author

Okay followup question about scheduling.

My main thread is waiting for a message. the tcp thread is running and it is sending a message to the main thread.

The priority of the tcp thread is higher than main(a lower number). After the message was sent from tcp to main, main takes over. That means the priority is raised after getting a message from a higher prioritzed thread. Is that right?

Ist there somehow a tutorial how the scheduler behaves?

@OlegHahm
Copy link
Copy Markdown
Member

The priority of the tcp thread is higher than main(a lower number). After the message was sent from tcp to main, main takes over. That means the priority is raised after getting a message from a higher prioritzed thread. Is that right?

Not quite. After TCP thread sent the message to main thread, TCP will keep running. Just the main thread will change its state to PENDING, i.e. it will continue to run as soon as no thread with a higher priority is in the run queue.

Ist there somehow a tutorial how the scheduler behaves?

I'm not sure. At least there should be something in @kaspar030's thesis IIRC.

DipSwitch added a commit to DipSwitch/RIOT that referenced this pull request Aug 22, 2015
DipSwitch added a commit to DipSwitch/RIOT that referenced this pull request Aug 25, 2015
@DipSwitch
Copy link
Copy Markdown
Member

The segfault has to do with the the nomac driver releases the packet back to the packet buffer if it has send it. Then new data is wrote over the previous gnrc_pktsnip_t however the TCP tcb uses that the now overwritten pointers cur_pkt and cur_tcp_hdr to try and resend the data.

The SYN/ACK still is invalid though, the TCP header is correct but although gncr_ipv6.c sets the src address. When the packet is send however the src address, next header and payload are invalid / not set.

Any ideas?

@DipSwitch
Copy link
Copy Markdown
Member

Related to issue: #3707

When we want to keep the packet for the retry timer etc. however when used is set to 1 the response would be valid but the packet is overwritten by another packet and when TCP tries to resend it, it would resend an overwritten packet.

However when you set the used count to 2 since you want to keep a copy of the packet in the retry queue an invalid IPv6 header would be send.

@brummer-simon
Copy link
Copy Markdown
Member Author

Okay I pulled the current Master and DipSwitchs Branch that did the whole renaming(Thanks by the Way:) ) and squashed the hole thing.

I'll try to get the handshake going

@DipSwitch
Copy link
Copy Markdown
Member

The handshake is working :) I think we can start sending data :D

@OlegHahm
Copy link
Copy Markdown
Member

Nice. 😎

@brummer-simon
Copy link
Copy Markdown
Member Author

My original goal was to implement the connection termination first, to make sure the fsm work as it should be. But as i wrote yesterday, I focus the next months on my Bachelor Thesis.

@brummer-simon
Copy link
Copy Markdown
Member Author

Oh the merge included a lot files that aren't involved in the hole tcp thing. I'll fix that in the afternoon.

@DipSwitch
Copy link
Copy Markdown
Member

Both are even important :) good luck with your thesis!

@miri64
Copy link
Copy Markdown
Member

miri64 commented Aug 26, 2015

@DipSwitch please comment in the PR not the commit. Comments in commits get easily lost.

@miri64
Copy link
Copy Markdown
Member

miri64 commented Aug 26, 2015

You probably need to rebase to current master. There are a lot of changes in here now, that are actually a part of master already.

@DipSwitch
Copy link
Copy Markdown
Member

I rebased and forced updated, sorry not the best way possible...

If you do close implementation, I'll see if I can start with send in my free time ^_^

@brummer-simon
Copy link
Copy Markdown
Member Author

Yes I'll implement the close operation. Over the next weeks.

@miri64 miri64 modified the milestones: Release 2015.08, Network Stack Task Force, Release NEXT MAJOR Sep 2, 2015
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/ng/gnrc/

@cgundogan cgundogan changed the title [WIP]ng_tcp [WIP]gnrc_tcp Oct 8, 2015
@OlegHahm
Copy link
Copy Markdown
Member

The last time I tried (about 1 month ago), I was not able to get the test application to send anything (not even the handshake packets).
As far as I can see, what would be the "eventloop" (as it is called in other gnrc modules) corresponds to the _fsm function here. However, this seems not to implement a common event loop for all TCP connections, but just for one connection. This would require every TCP connection to run its own thread which is most likely a bad idea. I would advice to use a central eventloop (just similar to what other gnrc modules do) and make all calls to TCP based on gnrc netapi calls.

Some more "formal" comments:

  • Defining such a long function as the current _fsm() static inside a header is IMO not a good style. Please move this to a C file.
  • The code could need some uncrustifying

@brummer-simon
Copy link
Copy Markdown
Member Author

Hi Oleg,

currently i'am doing buzy spliting the static includes into thier own c-Files, and doing some renaming. For your concern with the _fsm corresponance.

TCPs statemaschine must be able to do translations, without the users interaction, in case a FIN-Packet was received. Moving from ESTABLISHED to CLOSE_WAIT. The Eventloop interacts only in case of Packet reception with the FSM. The Transmission control blocks are organized as a linked list. If the eventloop receives a packet, it looks for the receivers pid. The pid is part of an tcb as well. The eventloop searches for the receivers tcb and calls the fsm-function with this specific tcb.

Long story short, only one eventloop is needed for multiple connections.

@OlegHahm OlegHahm removed this from the Release 2015.12 milestone Nov 28, 2015
@OlegHahm OlegHahm modified the milestone: Release 2016.03 Dec 8, 2015
@brummer-simon
Copy link
Copy Markdown
Member Author

Merge fuckup lead to this pull request: #4744

@cgundogan
Copy link
Copy Markdown
Member

closed in favor of #4744

@cgundogan cgundogan closed this Feb 4, 2016
@brummer-simon brummer-simon deleted the devel-ng_tcp branch February 4, 2016 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: network Area: Networking State: WIP State: The PR is still work-in-progress and its code is not in its final presentable form yet Type: new feature The issue requests / The PR implemements a new feature for RIOT

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants